aspect-ratio

Mosaic of images HTML/CSS

蹲街弑〆低调 提交于 2019-11-27 00:51:36
I want to make an image layout with portrait images inside a div with a fixed aspect ratio of 3:2 . The size of images is 327x491px . The main issue is unwanted spaces between images. How do I align images as a mosaic using only HTML/CSS ? HTML : <div id="pictures1" class="_pictures1 grid"> <div class="_pictures1-01"><div style="width:125px;height: 188px; background: red;"><img src="" width="125" height="188" alt="" /></div></div> <div class="_pictures1-02"><div style="width:192px;height: 288px;background: green;"><img src="" width="192" height="288" alt="" /></div></div> ... SO ON ... </div>

Maintain div aspect ratio according to height

旧巷老猫 提交于 2019-11-26 22:44:44
I need to maintain the width of an element as a percentage of its height . So as the height changes, the width is updated. The opposite is achievable by using a % value for padding-top, but padding-left as a percentage will be a percentage of the width of an object, not its height. So with markup like this: <div class="box"> <div class="inner"></div> </div> I'd like to use something like this: .box { position: absolute; margin-top: 50%; bottom: 0; } .inner { padding-left: 200%; } To ensure the box's aspect ratio is maintained according to it's height . The height is fluid because of it's %

VideoView to match parent height and keep aspect ratio

一世执手 提交于 2019-11-26 22:14:01
I have a VideoView which is set up like this: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/player" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <VideoView android:id="@+id/video" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_centerInParent="true" android:layout_centerVertical="true" /> <ProgressBar android:id="@+id/loader" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout

Proportionally resize iframe to fit in a DIV using jQuery

我怕爱的太早我们不能终老 提交于 2019-11-26 21:41:35
问题 I have an iframe of a video inside a div, like so: <div class="media"> <iframe> </div> I set the DIV's size dynamically on window resize. I want to scale the iframe to fit inside the div, while maintaining it's aspect ratio . Most of the code out there deals with scaling images, which is easier. This is what I have so far, but it doesn't work: jQuery.fn.fitToParent = function() { this.each(function() { var width = jQuery(this).width(); var height = jQuery(this).height(); var parentWidth =

Padding-bottom/top in flexbox layout

微笑、不失礼 提交于 2019-11-26 21:34:47
I have a flexbox layout containing two items. One of them uses padding-bottom : #flexBox { border: 1px solid red; width: 50%; margin: 0 auto; padding: 1em; display: flex; flex-direction: column; } #text { border: 1px solid green; padding: .5em; } #padding { margin: 1em 0; border: 1px solid blue; padding-bottom: 56.25%; /* intrinsic aspect ratio */ height: 0; } <div id='flexBox'> <div id='padding'></div> <div id='text'>Some text</div> </div> The blue element maintains its aspect ratio according to its width when the page is resized. This works with Chrome and IE and looks like : However, in

How to scale SVG image to fill browser window?

六眼飞鱼酱① 提交于 2019-11-26 19:35:25
This seems like it ought to be easy, but I'm just not getting something. I want to make an HTML page containing a single SVG image that automatically scales to fit the browser window, without any scrolling and while preserving its aspect ratio. For example, at the moment I have a 1024x768 SVG image; if the browser viewport is 1980x1000 then I want the image to display at 1333x1000 (fill vertically, centred horizontally). If the browser was 800x1000 then I want it to display at 800x600 (fill horizontally, centred vertically). Currently I have it defined like so: <body style="height: 100%"> <div

Resize a WPF window, but maintain proportions?

*爱你&永不变心* 提交于 2019-11-26 17:45:28
问题 I have a user resizable WPF Window that I want to constrain the resizing so the aspect ratio of the window stays constant. Ideally I would like to constrain mouse location when the window is being resized by dragging a corner to positions that maintain the proper aspect ration. If an edge is resized with the mouse, the other dimension should change at the same time. Is there a simple way to do this or a good on-line example that anyone knows of? If no better solutions come up, I'll post what

Square DIV where height is equal to viewport

我是研究僧i 提交于 2019-11-26 17:38:41
问题 I need to create a DIV where width=height , and height=100% of the viewport (which, obviously, is variable). In other words, a perfectly square DIV that calculates it's dimensions based on the height of the viewport . Elements within that DIV will take their dimensions as percentages of the parent-DIV's height & width. It seems to me like this should be simple to do in CSS , but I've gotten stuck with it! Any pointers would be much appreciated. 回答1: You can do this with jquery (or pure

What's the algorithm to calculate aspect ratio?

你离开我真会死。 提交于 2019-11-26 17:01:55
I plan to use it with JavaScript to crop an image to fit the entire window. Edit : I'll be using a 3rd party component that only accepts the aspect ratio in the format like: 4:3 , 16:9 . paxdiablo I gather you're looking for an usable aspect ratio integer:integer solution like 16:9 rather than a float:1 solution like 1.77778:1 . If so, what you need to do is find the greatest common divisor (GCD) and divide both values by that. The GCD is the highest number that evenly divides both numbers. So the GCD for 6 and 10 is 2, the GCD for 44 and 99 is 11. For example, a 1024x768 monitor has a GCD of

OpenGL stretched shapes - aspect ratio

折月煮酒 提交于 2019-11-26 15:55:01
问题 I got my openGL view at a size of (lets say..) 800(width)x600(height). Then i got a 2D object of coords: 0.0 , 0.0 0.1 , 0.0 0.1 , 0.1 0.0 , 0.1 this, as you understand is supposed to be a square (based on analogy). But on my openGL view prints this stretched. Now, i understand why this is happening. Its basically because im working on the default matrix of -1,1. And since my resolution of 800x600 doesnt have an aspect ratio of 1, my shape is getting stretched. Now im more interested on how