How to Make a Div Have a Fixed Size
There are a few ways to make a div have a fixed size. One way is to give it a max-height
and max-width
in your .css
:
.fontpixel{ max-width:200px; max-height:200px; }
This will set the maximum height and width of the div to 200 pixels. You can also use the width
and height
properties to set the exact height and width of the div.
Another way to make a div have a fixed size is to use the display: inline-block
property. This will make the div take up as little space as possible, and its width will be defined by the CSS.
#innerbox { width:250px; /* or whatever width you want. */ max-width:250px; /* or whatever width you want. */ display: inline-block; }
You can also use the overflow: hidden
property to hide any content that overflows the div.
<div class="form-control" style="height:100px; width:55%; overflow:hidden; cursor:pointer"> </div>
Finally, you can use the max-height
and max-width
properties to set the maximum height and width of an image within a div.
<div> <img src="whatever it is" class="image-crop"> </div> /*mobile code*/ .image-crop{ width:100%; max-height: auto; } /*desktop code*/ @media screen and (min-width: 640px) { .image-crop{ width:100%; max-height: 140px; }
This will ensure that the image does not overflow the div.