Reputation: 187
I have a simple textbox within a .well
and want to style the width of the .well
class to be not much bigger than the text I put in.
Is there an easy way to achieve this with CSS?
Upvotes: 1
Views: 2734
Reputation: 80
How about this?
.well{display: inline-block;}
Example.
.well{
display: inline-block;
background: gold;
}
.textbox{
background: skyblue;
}
<div class="well">
well
<div class="textbox">textbox</div>
</div>
Upvotes: 1
Reputation: 1894
I think better use Textarea
, then text automatically wrap the textarea field's width.
<textarea rows="5"></textarea>
Upvotes: 1
Reputation: 1912
Use max-width property in the style for the box and
.well-class{width:auto; max-width:200px;}
for the class, This will work.
Upvotes: 1