Reputation: 181
I have a div with a min and max width.
CSS
#box{
position: absolute;
top: 50px;
left: 100px;
min-width: 180px;
max-width: 320px;
height: 180px;
border: 1px solid black;
overflow: hidden;
}
When I type something long into the box it expands to the right. Is it possible to make the box expand to both the left and right evenly?
Upvotes: 1
Views: 4947
Reputation: 85545
You have set left value to 100 pixels which could not let you expand left and right evenly.
Edit
If you don't need absolute position then you could do this by setting margin: 0 auto;
and display: table;
to your div.
Upvotes: 2
Reputation: 54619
You could use a container with text-align:center;
like so:
HTML
<div class="container">
<div id="photo"></div>
</div>
CSS
.container{
text-align: center;
}
#photo{
min-width: 180px;
max-width: 320px;
height: 180px;
border: 1px solid black;
display: inline-block;
text-align: left;
margin-top: 50px;
}
Upvotes: 4