What's Going On
I use the i
element to create icons. Normally with an image, or more recently an icon font, but we can adapt for your needs. (Originally the i
element wasn't used for icon, and it is debatable whether it's semantically correct. However, it's used in many icon fonts, and in some major websites.) Since you need to be able to dynamically place the content in the HTML, we can use the i
as a wrap, and a div
inside to make the second color.
Code
HTML:
<i>Top<div>Bottom</div></i>
CSS:
i {
height:32px;
width:32px;
display:inline-block;
position:relative;
color:white;
font-size:10px;
background:lightgreen;
text-align:center;
font-style:normal;
}
i div {
background:orange;
position:absolute;
bottom:0;
height:50%;
width:100%;
}