aspect-ratio

CSS-only way to set a div to 90% width and 3:1 aspect ratio [duplicate]

我的梦境 提交于 2019-12-22 11:35:21
问题 This question already has answers here : Maintain the aspect ratio of a div with CSS (23 answers) Closed 4 years ago . I have a div that I want to set to 90% of its parent container's width, and I want its height to be set so as to achieve a specific aspect ratio, say 3:1. .mydiv { width: 90% height: 30%(of-width); } Is there any way to do this that does not involve JavaScript? 回答1: If your container div has a fixed width, then your 90% width div has as well a fixed width. Look which is this

Stretch html5 video without keeping aspect ratio in jQuery

我的梦境 提交于 2019-12-22 11:11:19
问题 HTML5 videos have intrinsic aspect ratios and tend to keep it, no matter what your CSS tells them to do. I have a responsive video container that isn't 16:9, and I'd like the videos inside it to stretch to 100% width and 100% height, even if it breaks their original aspect ratio. I've read about the CSS object-fit: fill property, which would solve my problem, but there's still a long way to go before modern browsers support it. So I guess I must turn to JavaScript to achieve what I need. I

CSS: Keeping a div's height relative to its width [duplicate]

别等时光非礼了梦想. 提交于 2019-12-22 01:57:34
问题 This question already has answers here : Maintain the aspect ratio of a div with CSS (23 answers) Closed 4 years ago . My question is very similar to this question: CSS: 100% width or height while keeping aspect ratio? I have a div whose position is fixed. The width of the div must be 100% and its height exactly 1/6th of its width . Is there a -webkit-calc() way of doing this? Note: JS solutions are not preferred as a zoom/orientation change can affect the width/height. 回答1: Is this what you

Using just CSS, crop .img keeping aspect without distortion

回眸只為那壹抹淺笑 提交于 2019-12-21 05:21:12
问题 I have an image that has been placed inside a div. The div is 600 width and has a variable height. I want my image to sit at the top of the div. If I make the width 590 the issue is that the image is then too high in terms of design and it looks too dominant on the page (because its ratio is roughly 4:3 etc). So I want to make the image 590 by 200. If i use... .img { width: 590px; max-height: 200px; } ...then the image sits inside the div exactly how I want it. However, the photo itself is

Using just CSS, crop .img keeping aspect without distortion

落花浮王杯 提交于 2019-12-21 05:21:07
问题 I have an image that has been placed inside a div. The div is 600 width and has a variable height. I want my image to sit at the top of the div. If I make the width 590 the issue is that the image is then too high in terms of design and it looks too dominant on the page (because its ratio is roughly 4:3 etc). So I want to make the image 590 by 200. If i use... .img { width: 590px; max-height: 200px; } ...then the image sits inside the div exactly how I want it. However, the photo itself is

ImageMagick change aspect ratio without scaling the image

妖精的绣舞 提交于 2019-12-21 04:17:10
问题 I have a large number of images that can be any dimension that I need make into the same aspect ratio (basically square). So if one image is 100x300 the output should be 300x300. What I don't want is the image scaled or stretched in any way. I just want a background color (white) applied to the sides of the image, then the original image centered (either vertically or horizontally depending on the original aspect ratio). I've played around with a couple different convert commands, but I have

How to calculate Android screen aspect ratio mathematically

北慕城南 提交于 2019-12-21 03:47:15
问题 One of the device screen properties that Android lets an app query is it's aspect ratio. In the examples that I have seen this property seems to have only two values - long and notlong . I am trying to reverse engineer the logic being used by Android to classify a device as having one of the two aspect ratios. To get some official data to work with, I referred to the values provided by the device definitions included in the AVD Manager tool in Android Studio, and combined that with my own

16:9 aspect ratio with fixed width

烂漫一生 提交于 2019-12-19 14:05:13
问题 If I were to embed a YouTube video for example <iframe width="560" src="http://www.youtube.com/embed/25LBTSUEU0A" class="player" frameborder="0" allowfullscreen></iframe> Using jQuery would I set a height with an aspect ration of 16:9 so if the width is 560 the height should be 315px. I have this jquery to set a height but I dont know how to apply the 16:9 ratio $('.player').parent().attr('width', ':9ratio'); or can this be done neatly using css? 回答1: Aspect ratio is just width:height. So if

How do I crop an Axes3D plot with square aspect ratio?

倾然丶 夕夏残阳落幕 提交于 2019-12-19 05:05:05
问题 Here's a barebones example: import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure() f = fig.add_subplot(2, 1, 1, projection='3d') t = fig.add_subplot(2, 1, 2, projection='3d') # axes for d in {f, t}: d.plot([-1, 1], [0, 0], [0, 0], color='k', alpha=0.8, lw=2) d.plot([0, 0], [-1, 1], [0, 0], color='k', alpha=0.8, lw=2) d.plot([0, 0], [0, 0], [-1, 1], color='k', alpha=0.8, lw=2) f.dist = t.dist = 5.2 # 10 is default plt.tight_layout() f.set_aspect('equal') t

Objective C: How to fix aspect ratio of image (and not change to fit imageview frame)

♀尐吖头ヾ 提交于 2019-12-18 11:47:16
问题 I am using the UIImagePickerController to select images for my app. However I am facing some challenges with regards to maintaining aspect ratio of the selected images For example, I have a raw image on the phone as follows (not square image): After selecting the image on iphone via the 'move and scale' page to crop image, the result is as follows: (aspect ratio is still maintained here) My app will display the selected image in a UIImageView with a square frame (200 x 200). After setting the