Notification texts go here Contact Us Buy Now!

How to make a div have a fixed size?

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.

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.