categories
product
category
categories
<div>category-1</div>
80px
.pr.product {
width: 380px;
height: 380px;
background-image: url("http://unsplash.it/380/380?random&blur");
margin: 30px;
position: relative;
color: #fff;
text-shadow: 1px 1px 0px rgba(0,0,0,.5);
}
.product .headline {
position: absolute;
left: 20px;
bottom: 60px;
width: 75%;
}
.product .category_wrapper {
position: absolute;
right: 20px;
width: 20%;
bottom: 140px;
background-color: rgba(0, 255, 0, .3);
height: 60px;
top: 255px;
}
.product footer {
text-align: right;
color: red;
font-size: 18px;
text-transform: uppercase;
position: absolute;
bottom: 20px;
right: 20px;
}
<body>
<h3>
Looks good, but only if 3 categories are available.
</h3>
<div class="product">
<div class="headline">
<h1>Test headline</h1>
</div>
<div class="category_wrapper">
<div class="category">category-1</div>
<div class="category">category-2</div>
<div class="category">category-3</div>
</div>
<footer>
FOOTER
</footer>
</div>
<hr/>
<h3>
Only 2 categories (they stick to the top)
</h3>
<div class="product">
<div class="headline">
<h1>Test headline</h1>
</div>
<div class="category_wrapper">
<div class="category">category-1</div>
<div class="category">category-2</div>
</div>
<footer>
FOOTER
</footer>
</div>
<hr/>
<h3>
Desired output if only 2 tags
</h3>
<div class="product">
<div class="headline">
<h1>Test headline</h1>
</div>
<div class="category_wrapper">
<br/>
<div class="category">category-1</div>
<div class="category">category-2</div>
</div>
<footer>
FOOTER
</footer>
</div>
</body>
This will do exactly what you want. But I'm not sure it will go with the CSS you are using without watching it. Try this or provide your CSS for the list and footer if it does not work this way.
#footer {
margin-top: 20px;
width: 100%;
height: auto;
color: red;
}
ul{
margin: 0;
padding: 0;
}
ul li {
list-style-type: none;
}
<ul>
<li>Category 1</li>
<li>Category 2</li>
</ul>
<div id="footer">Footer</div>
UPDATE
Check this fiddle using your updated code and let me know.
Just need to update your .product .category_wrapper
as below
.product .category_wrapper {
position: absolute;
right: 20px;
width: 20%;
bottom: 60px;
background-color: rgba(0, 255, 0, 0.3);
height: auto;
}