Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS/HTML Text over background

I always run into a little trouble with layouts. I need help with part of it. I don't really know how to explain but I'll do my best lol.

HTML

<div id="details">
<div id="stat_bar">
    <div id='details' style="width:100%">Exp</div>
</div>
<br>
<br>
<div id="stat_bar">
    <div id='details' style="width:100%">Energy 12/12</div>
</div>
<br>
<br>
<div id="stat_bar">
    <div id='details' style="width:80%">Stamina 100%</div>
</div>
<br>
<br>
<div id="stat_bar">
    <div id='details' style="width:100%">Adrenaline 12/12</div>
</div>
<br>
<br>
<div id="stat_bar">
    <div id='details' style="width:10%">Health 10%</div>
</div>
<br>
<br>

Here is my fiddle http://jsfiddle.net/nay3rv36

As you can see when the width is low the text gets pushed to the bottom. I want the text to stay in the box but the background to be down.


1 Answers

Id's on elements should be unique.

Check out this : http://jsfiddle.net/js3mptyy/1/

For a full html / css update.

#details #stat_bar div {
    background:#006600;
    height:14px;
    white-space: nowrap;
}

Would sort your problem if you keep the id's as is.

Adding white-space: nowrap will stop text wrapping to a new line in a small div.

like image 109
Ben Temple-Heald Avatar answered Apr 21 '26 15:04

Ben Temple-Heald



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!