aspect-ratio

When using padding-top to retain aspect ratio for fluid layout, how do I vertically center text to background image?

久未见 提交于 2020-01-23 19:46:54
问题 I have not been able to find a solution to this and am willing to change whatever I need to as long as I can keep a couple things. The entire list element needs to be a link, the text within that link needs to be centered to the list item which has a background image. I need this fluid so I choose to use the padding-top to maintain the aspect ratio and to create the correct height. With using that padding top to create the height, I can not for the life of me figure out how to get the text

How to keep a div contained within the viewport whilst maintaining aspect ratio

…衆ロ難τιáo~ 提交于 2020-01-14 12:46:13
问题 There exists a square div that is an arbitrary percent wide (and the same amount high) that needs to scale with the window. It must stay within the bounds of the viewport (ie: not clipping outside) and maintain its square shape - essentially duplicating the background-size: contain; feature of CSS. I need to support iOS Safari v3.2, so I can't use vw/vh/vmin/vmax and would strongly prefer a CSS-only solution. 回答1: You can set it using :after in CSS DEMO http://jsfiddle.net/kevinPHPkevin/5tzk3

Forcing aspect ratio with CSS doesn't work on Safari

非 Y 不嫁゛ 提交于 2020-01-13 13:49:48
问题 The following code works well in Firefox and Chrome, but doesn't in Safari (tested on Mac and iPad): http://jsfiddle.net/eFd87/. <div id="wrapper"> <div id="content"> <img src="http://farm3.staticflickr.com/2783/4106818782_cc6610db2c.jpg"> </div> </div> #wrapper { position: relative; padding-bottom: 33.33%; /* Set ratio here */ height: 0; } #content { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: green; text-align: center; } #content img { max-height: 100%; }​

Libgdx camera/scaling issue

爷,独闯天下 提交于 2020-01-11 12:51:30
问题 This is just a really quick post wondering what i have done wrong? I want the background to be filled on the whole screen with whatever screen sizes i have but this does not make it work. Here is all the code: // Variables Jump game; OrthographicCamera cam; SpriteBatch sb; // Variables public SplashScreen(Jump game) { this.game = game; cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.translate(cam.viewportWidth / 2, cam.viewportHeight / 2); sb = new

Libgdx camera/scaling issue

隐身守侯 提交于 2020-01-11 12:50:31
问题 This is just a really quick post wondering what i have done wrong? I want the background to be filled on the whole screen with whatever screen sizes i have but this does not make it work. Here is all the code: // Variables Jump game; OrthographicCamera cam; SpriteBatch sb; // Variables public SplashScreen(Jump game) { this.game = game; cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.translate(cam.viewportWidth / 2, cam.viewportHeight / 2); sb = new

height: auto on SVG not working

笑着哭i 提交于 2020-01-10 17:41:04
问题 I am trying to use an SVG sprite sheet using the "symbol" method detailed here. http://css-tricks.com/svg-sprites-use-better-icon-fonts/ My HTML is very simple. <svg><use xlink:href="/images/iconSprite.svg#camera"/></svg> And here is an example symbol from the SVG file <symbol viewBox="0 0 24 24" id="clock"><g transform="translate(0 -1028.4)"><path d="M22.085 1035.955a10.997 10.997-23.5 1 1-20.17 8.77 10.997 10.997-23.5 1 1 20.17-8.77z" fill="#1abc9c"/><path d="M21 1040.335a9 9 0 1 1-18 0 9 9

LibGDX: How to draw in the area of the black bars of a FitViewport?

烈酒焚心 提交于 2020-01-04 05:35:08
问题 I got a FitViewport with a virtual width and virtual height. When the screen got another aspect ratio than my virtual resolution black bars are added. I want to draw something inside these letterboxes. I tried to do it that way, but only objects "inside" my virtual resolution are drawn, objects "outside" are just not visible: viewport = new FitViewport(VIRTUAL_WIDTH, VIRTUAL_HEIGHT, cam); viewport.apply(); batch.setProjectionMatrix(cam.combined); batch.begin(); batch.draw(texture, viewport

How to keep image aspect ratio inside a %width div?

蓝咒 提交于 2020-01-04 02:12:24
问题 I'm sorry to ask this again, but my search has not revealed anything that I have been able to implement. I have an image inside a div with the following styles: <div class="thumb grid_6"> <img src="img/test2.jpg" alt="flavin" /> </div> .grid_6 { width: 50%; } .thumb img { display: block; max-width:100%; max-height: 100px; width:100%; I'd like the image height to be locked at 100px, with the width remaining at 50%. Ideally the image would keep its aspect ratio, and just crop to the required

Maintain aspect ratio and font size based on browser height and width?

我的未来我决定 提交于 2020-01-02 19:22:47
问题 The code below is attached to window.onresize = resize; . The baseWidth and baseHeight are read on load as a basis for the calculations. The main variable is defined just by setting it to the main html node. The font is set on a block element to cause all of the em based elements within it to resize in kind. When the width or height of the browser is changed then the ratio is recalculated. Please see demo to understand what I achieve with JS but would like to find a pure CSS solution: http:/

Dimensions of usable space in window (action bar and margin excluded)

大憨熊 提交于 2020-01-02 08:56:20
问题 Disclaimer: I rewrote most of this question, including its title, because I partially figured it out. I'd like to maximize the size of the button on all screen sizes, because it looks silly when it is to small. It should look similar to this: (Sadly, I cannot include a picture, because my reputation is too low.) But if I turn the orientation of the device, for example, the button matches it's parents width, becoming ugly proportioned. (Sadly, I cannot include a picture, because my reputation