user517406
user517406

Reputation: 13773

setting minimum width of div

I have a page with many different objects of different widths. I am not setting the width of the div that the objects are within as I want it to be able to expand to include whatever items are within it. But I do want the div to have a minimum width. Is it possible to do this?

Upvotes: 18

Views: 51462

Answers (4)

Marwelln
Marwelln

Reputation: 29413

It is very possible. Just use CSS min-width. The MDN page has details.

Upvotes: 17

Valentin Despa
Valentin Despa

Reputation: 42562

Checkout some real documentation regarding this, Mozilla Developer Network.

Upvotes: 1

Kerem Baydoğan
Kerem Baydoğan

Reputation: 10722

Use CSS:

min-width

Definition and Usage

The min-width property sets the minimum width of an element. Note: The min-width property does not include padding, borders, or margins!

like

#example {
  width: 150px;
  min-width: 100px;
  max-width: 200px;
}

Upvotes: 11

Xavier
Xavier

Reputation: 8362

this is achievable via css;

element
{
    min-width:100px;
}

Upvotes: 0

Related Questions