I have two <div>
: left and contents. These two are inside wrapper div that has min-width:960px;
. left has fixed width, but I want to make content flexible with min width of 700px and if screen is wider, stick it to the right bound of screen.
CSS:
#wrapper
{
min-width:960px;
margin-left:auto;
margin-right:auto;
}
#left
{
width:200px;
float:left;
background-color:antiquewhite;
margin-left:10px;
}
#content
{
min-width:700px;
margin-left:10px;
width:auto;
float:left;
background-color:AppWorkspace;
}
JSFiddle: http://jsfiddle.net/Zvt2j/
Answer: Use the CSS max-width Property You can simply use the CSS max-width property to auto-resize a large image so that it can fit into a smaller width <div> container while maintaining its aspect ratio.
To auto-resize an image or a video to fit in a div container use object-fit property. It is used to specify how an image or video fits in the container. object-fit property: This property is used to specify how an image or video resize and fit the container.
It is very easy to auto-size images to fit into a div container. In this tutorial, we will learn about the CSS properties used to auto-size the image. The width and height properties can be used to auto-resize the image so that it fits into the div container. Do not use explicit height and width to the image tag.
Three ways to resize images to fit a DIV : 1 Two different CSS classes (one for width, one for height). 2 Using the STYLE attribute within the IMG tag to manually set the width or height for each image (essentially the same as #1). 3 Warning, exiting browser-side territory!
CSS makes it possible to resize an image to fit an HTML container. To auto-resize an image or a video you can use the object-fit property. It is used to specify how an image or video fits in the entire container.
Using inline-block property: Use display: inline-block property to set a div size according to its content. making web pages presentable. CSS allows you to apply styles to web pages. More each web page. Using fit-content property in width and height: In this method, we set the width and height property to fit-content value.
You can overflow:hidden
to your #content
. Write like this:
#content
{
min-width:700px;
margin-left:10px;
overflow:hidden;
background-color:AppWorkspace;
}
Check this http://jsfiddle.net/Zvt2j/1/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With