user4853991
user4853991

Reputation: 95

set minimum width of a div having position as relative

How to style this div both with a min-width and width

css

#diva {
   position: relative;
   margin: 0 auto;
   min-width: 75px;
   width: auto;
   height: 50px;
   padding: 4px;
   color: white;
   background-color: red;
}

html

<div id="diva">
    hello
</div>

When i set width to auto, this div occupies the full page width.

Upvotes: 0

Views: 578

Answers (1)

JohnDevelops
JohnDevelops

Reputation: 567

display:inline-block;

Just add display:inline-block; to the styles for the div. That should work :)

http://jsfiddle.net/432kxywu/

Upvotes: 1

Related Questions