Adjust layout images and size - html

I'm trying to adjust the images and size depending the page size to doesn't go outside the grid, but I couldn't make it.
I tried add theses lines below in CSS but it bugged the others images
img{
width: 100%;
max-width: 800px;
}
The content should adjust the size of the image, but it isn't working
The image going outside the grid:
You can see the live preview here

Just give max-width for image to 100%
img {
max-width: 100%;
}

do the exact opposite you are doing
img {
width:800px; /* this is optional */
max-width: 100%;
}
OP's comment:
I already dropped it (the width:800px), but it messed with the images at right sidebar.
Then create a class something like img-resposive and for that class apply max-width: 100%. And use that class in images you want/need to

I suggest if you are trying responsive design, use 50em; instead of 800px
They are both equal (except when window is resized.)

Related

How to stretch images to fill a figure tag

I am building a grid of images and I have a list of figure tags with one image inside each one.
Images are different in size so if I set
max-width: 100%;
height: auto;
they don't look the same.
How can I make all images to fit the figure to be all the same size? it is OK for me to stretch the images that does not fit perfectly.
thanks
Use objectfit on img tag with contain or cover properties
figure img {
object-fit: contain;//contain the image you can use cover to fill the div with image
width: 200px;//desire width
height: 200px;//desire height
}
Please follow the styles in css.. but i think this is not a correct rule to stretch the image.. we can use background image in css instead of stretch..
css
figure img {
width: 100%;
height: auto;
}

HTML&CSS - Resize all my images

I have a folder full of thousands of image and I want to show those images.
I've done that already, but my problem here is wit hthe size of the images.
The images in my folder are totally different format and size.
I've succeeded to resize them all but whenever I do that, when I change the browser size they don't resize aswell, they stay like I told them to.
What I want to do is put a maximum size that if the browser is big enough they are this size. But if the browser shrinks, they react instantly to that and change size.
I've tried for 2 hours now and I can't find a way to do that.
PS: I'm using bootstrap
Thanks ! :)
How about this? The images will be a maximum size of 1000 pixels, but will be 100% of the browser width otherwise.
img {
width: 100%;
max-width: 1000px;
}
The following should give you what you're looking for:
img {
height: 100%;
width: auto;
max-height: (put max height here in px)px;
}
As long as your images aren't smaller than their containers, this will work.
Add class="img-responsive" to your <img> tag. See this for details.
you could use the class img-responsive, that bootstrap offers
http://getbootstrap.com/css/#images-responsive
Your answer is this JSFIDDLE.
img {
display: block;
width: 100%;
max-width: 800px;
}

How do I get the content (mostly images) to scale or resize with the window size on tumblr?

My blog/website is iamdonle.com
An example of what I want is 13thwitness.com
The images on mine doesn't scale and a scroll bar will appear. On his website the images get smaller with the window. I'm sure it's simple but I'm a noob. Please help!
You images are scaling down, but your logo is not!
Try:
.logo {
max-width: 100%;
}
First, you'll need to make sure your container is able to scale. Right now it has a set width of 1150px, this needs to be either a max-width or percentage based.
First, remove the width declared on #container and add this CSS:
#container {
max-width: 1150px;
padding: 5px 30px 0;
}
Then you'll need to remove the width declared for your header. You can do this by either removing the line completely (line 82 of your CSS file) or by overriding it in your 'Custom CSS' field box in the Customization screen by doing:
#header {
width: 100%;
}
Then, as others have mentioned, you'll need to add a max-width to your logo as well.
#header img {
max-width: 100%;
}
Note: when I viewed the blog you were using the "Quite Big" theme, the code above only applies to that theme.

Responsive web design and resizing images

Repsonsive web design works great on most html elements excepts images.I find it a mess. When resizing viewports, you cannot use resizing percentages on an image since it will take on the parent element width and height right. You need to set fixed widths and heights for images...Or am I missing something?
So how exactly do you do a responsive design involving images whose container element/parent will stretch above its native width and shrink below its native width?
Thank you
The done thing in responsive design is to set this in your css for images and some other elements:
img, embed, object, video {
max-width:100%;
height:auto;
}
Then in your html the image simply takes up the size of it's container.
You do not set the image size itself you just let it grow/shrink itself.
well - you can write: .selector img{width: 100%; height: auto;} and then use the size of the div it is in to determine it's scale. or you can also set the image as a background and use similar methods and maybe even mess around with background-size: cover. i'll make a jsfiddle...
.image-w img {
display: block;
width: 100%;
height: auto;
}
What I have done on my site is this:
page stuff....
div class=picr>
img src="/Images/Home/MountainPine.jpg" alt="Mountain Pine" id="mountainpine" >
<p>Caption about mountain pine</p>
/div>
Then in CSS
pic, pic6 {
float: left;
}
...
.pic, .picr {
width: 37%;
}
#content img {
width: 100% ;
}
So the div class is styled, and the picture is set to fill it. By using the div, then I can also style within the .pic classes to be distinctive from the body text.

Responsive image max height 100% doesnt work in firefox

i'm currently trying to make an image resize depending on the browser dimensions. I've managed to get the image to resize horizontally, if I make the browser window narrow the image will resize proportionally just fine. However when I resize the window vertically, Firefox just doesn't seem to want to do it! The code is pretty simple
<body>
<div id="content">
<img src="images/abc.jpg">
</div>
</body>
and the CSS:
#content {
height: 100%;
padding: 50px;
}
#content img{
max-height:100%;
max-width: 100%;
}
Another issue is that the image does seem to resize vertically in chrome, but i have to drag the bottom of the browser well over the image before it start doing this. I'd rather the image start to rezise as soon as the bottom content padding "hits" the bottom of the image so to speak. Hope this is making sense.
Any help much appreciated
try this, taken from Twitter bootstrap 2
html,body{height:100%;}
#content {padding: 5%;}
#content img {
max-height: 100%;/* Part 1: Set a maxium relative to the parent */
width: auto\9;
/* IE7-8 need help adjusting responsive images */
max-width: auto;
/* Part 2: Scale the height according to the width, otherwise you get stretching */
vertical-align: middle;
border: 0;
-ms-interpolation-mode: bicubic;
}
Because height could potentially go on forever, you cant set the height of anything relative to the browser window to be a function of percent. What i'm saying is that you will need to put it inside of something with a fixed height to use a per-cent value. Good Luck!
-b
You've only specified the "max-height" and "max-width" properties.
If you don't specify the actual "width" or "height" properties, the image initialy takes the width and height of its physical dimensions (if not larger than the specified max-height and max-width).
Said that, the behaviour you've noticed, is correct.
The answer is, as already mentioned, to specify also a initial width or height property, dependig wether your image is portrait or landscape.
Is that what you want?
I actually just added a height to html and body, so that #contents height doesn't get to high.
body, html {
height: 100%;
margin: 0;
padding: 0;
}
(And box-sizing: border-box to #content, because it seems like you'd want that)