There is a page with a list of product entries which have different statuses. I want to be able to use little ribbons per each product, which would indicate what is the current status of the product.
An example of such a list with the ribbon is located here: http://jsfiddle.net/19ren646/
HTML:
<div class="list-group-item">
<h4>Short item</h4>
<p>I don't have that much content really</p>
<div class="ribbon">
<span>Ribbon</span>
</div>
</div>
<div class="list-group-item">
<h4>A much longer item</h4>
<p>I have a lot of content, because I have a Lorem ipsum in me</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos amet, minus maiores adipisci. Neque possimus, iusto odio explicabo. Libero, fugiat.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam, aliquid.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dignissimos amet, minus maiores adipisci. Neque possimus, iusto odio explicabo. Libero, fugiat.</p>
<div class="ribbon">
<span>Ribbon</span>
</div>
</div>
CSS:
.list-group-item {
position:relative;
padding:20px;
padding-left:60px;
border:1px solid #ccc;
}
.ribbon {
position:absolute;
top:0;
left:0;
width:40px;
height:100%;
background:blue;
color:white;
}
.ribbon span {
display:block;
transform:rotate(90deg);
}
To save horizontal space, the ribbon is rotated 90 deg. But my question is, can I get the text of the ribbon vertically in the middle?
I know I can push the text down by user position:relative
or margins
for example, but that would only work well if the heights of all entry items were constant, which they aren't. So can I push the text to the middle, in a way that would work for any height of the .list-group-item
element?