fluid portrait images with max height - html

I'm having some issues with fluid images when using a max height. I'm trying to bound the image in a box that is at most 450x450 or any arbitrary box thats not in the same aspect ratio as the image. What's happening is that the width of the image is being restricted to 450px but the height is not and the image is overflowing the wrapper div.
my code is:
<div class="wrapper">
<div class="container">
<img src="http://i.imgur.com/iw4yOa0.jpg"/>
</div>
</div>
see http://jsfiddle.net/5fuZ5/ for full code and css.
I know I could achieve this by using jquery but I need a responsive solution that doesn't require javascript.

OK i've got a similar issue and could find nothing to help. My situation is that i have a single column of images that are fluid (fit their container 100% in width) works fine for landscape images but portrait are huge as its the width being fitted, therefore tall and skinny image (portrait) is having its width fit to container thus making it massively tall.
My solution was to think about the container, if in the instance of a portrait image i set the container to be 50% of the landscape container then when i fit the images width (when portrait) to a smaller container i get them proportional (ish).
So wat you want is 2 containers to use, one for portrait and landscape, the landscape one will be the maximum width you want so 450px. Now make your portrait container half a width so 225px (half of the width) if all your images are the same aspect ratio then they should all match nicely and give you a structured grid - or if single column the portrait images will be more or less as tall as the landscape images are wide.
If you want to see this working (for a short time) I'll leave this link up so you can see how i solved it. The example is an email (please don't moan about poor coding, its not finished) template I'm making, where i have a single column of images (its responsive) both portrait and landscape - use a class on the table that contains the portrait image (class=portrait) but this could easily be a div.
http://www.sink140.com/sf-test/single.html
My main point is to stop thinking about trying to control the height, just control the container, let the image fill it, and by adjusting the width of the container (making it smaller) you naturally reduce the height of the image.
Aspect ratio of the images in general will ensure you can predict the layout as you have a baseline of sorts - portrait images relate to the landscape ones.
Hope this helps or at least give you another idea.

Related

Scaling parent div and all it's children while maintaining parent's aspect ratio

I'm trying to create two sections website. First is a part with inputs and the second one is 'preview part' showing these informations in adjusted way.
The important part is that the preview part is supposed to keep A4 page aspect ratio, while the input part can be stretched freely. How can I scale the preview with all children components so that it always fits screen width while keeping it's aspect ratio? I'm using bootstrap.
website on desktop - no problem
website on smaller screens - without scaling width of the page is to big

Keep same size to all devices. HTML & CSS

I was wondering how to keep the size of an element (f.ex a cube) on all devices. And when you resize the browser window the element will keep the same "form", but become smaller. What i mean is so when you resize the browser window horizontally, the element (f.ex cube) will keep the same "form". So it wont be more wide than tall.
I know i got to use percentage and not px on the with and height. But when i do that, the element will of course still be the percentage of the current device or screen. I am very bad at describing, so i'm going to give an example instead: When i made a calculator with HTML and CSS on school it fitted the screen perfectly. But the screen on the school is squared (same width as height). And the screen at home is rectangled (not the same width as height). So the calculator at home is to wide. You understand now? If you didn't please let me know.
Here's a picture of how it looks like on my screen home: Full sized browser window home Resized smaller in width window: Smaller in width browser window at home
And sorry for bad describing.. And english.
I dont know if I get what you mean, but if you do mean "keep aspect ratio" you should try this.
Wrap your element in another container, use padding bottom on the container and make your element occupy all its space.

Zurb's Foundation: disable image resize

I use Foundation 6 and have some images in two column groups.
When i resize the browser viewport from 1200px width to 1024px width the big image gets smaller, the width shrinks see pictures below.
Is there a way to permit that?
I would prefer a constant distance between the big image and the small image, to set a fix "B" value (second image) that is independent of the user's viewport.
See full webpage can be seen on https://fadendaten.herokuapp.com/t/categories/clothing
Its because your class .product-teaser-column has fixed width. Change that and it will be responsive again.
.product-teaser-column {
width: 470px;
}

HTML Image resizing and scaling without loss of quality

So I have a horizontal banner that I defined via a div. This div has a width of the full window and fix height of 500px for the time being. How can I scale an background image (2048 x 1283) to fill the div entirely without loss of picture quality? How would I do the same if the div height was relative to the window size, perhaps 25% or 50%? I want this to work when the window is resized.
Well you will never loss picture quality because you are keeping rendering the same picture over different sizes. You have to understand that responsive background its a hard topic since the picture will never display exactly how you want to, since different devices will have different display resolution, as example if you are seeing the same responsive image in your iphone portrait format (vertically) will look smaller in height than if you see in the same device but in landscape format (horizontal).
Any way heres is a question that can help you in your journey of responsive backgrounds Responsive css background images
cheers.
--- EDIT
if you want to achieve a full background http://css-tricks.com/perfect-full-page-background-image/ see this information.

Flex 4.5.1 - Mobile Image Covering Entire screen

I want to have an image that has to cover the entire screen or at least one of the sides so that it keeps its aspect ratio.
How do I do that considering the various screen sizes and DPI?
FlexGlobals.topLevelApplication.screen
returns the screen rectangle, and
FlexGlobals.topLevelApplication.applicationDPI
returns the DPI of the application.
But in Flex you can simply set an s:Image control's width to 100% of the view, then it will cover your screen. (and dont set the height, Flex will figure it out for you)