Forum Moderators: not2easy
The problem is: I have a web application which provides user feedback when events are completed, such as updating a page. I want to display the message highlighted with a tasteful border and background so it stands out. However, some of the messages can be quite short, so I'd like to have the highlighted area with a minimum width, say 140px - and if the message is longer, the area expands accordingly without wrapping the text (unless the text is very long of course).
Can I do this with plain, reasonably standard CSS?
This is the CSS definition:
<style type="text/css">
.message {
border:1px solid red;
background-color:orange;
padding:4px;
min-width:140px;
text-align:center;
}
</style> <div class="message">
Page updated
</div>
<br>
<div class="message">
Thankyou for your feedback. We have printed it out and fed it to our goat.
<div>
Might I suggest setting you widths in em's (or %) with a minimum left and right padding in the box.
<style type="text/css">
.message {
border:1px solid red;
background-color:orange;
padding:.25em 1em .25em 1em ;
min-width:10em;
text-align:center;
}
</style>
This should provide a flexability you are looking for.
Marshall
CSS isn't my forte, I have no idea if it's even possible. And trying various combinations involving e.g. min-width doesn't seem to work. Putting the text in a <span> with a border solves the expansion problem, but a <span> can't have a defined width, it seems.