I want to change all my elements in this specific div’s vertical position, so that they are aligned in the middle, top to bottom.
“vertical-align: top” worked for my button, but not for my other two text elements
“margin: 0px” doesnt seem to work
.FirstRetailer {
clear: both;
background-color: #07213F;
padding: 10px;
height: 62px;
line-height: 62px;
color: #FFFFFF;
vertical-align: top;
}
.RetailerRight1 {
float: right;
float: top;
height: 42px;
vertical-align: text-bottom;
}
.RetailerPrice1 {
padding: 0px 10px;
height: 22px;
}
.btnGoToProduct {
background-color: #A60000;
border: none;
color: white;
padding: 0px 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
height: 42px;
line-height: 42px;
vertical-align: top;
}
<h3>
<div class="FirstRetailer">
<span class="RetailerLeft1">
Product name
</span>
<span class="RetailerRight1">
<span class="RetailerPrice1">
$100.00
</span>
<a href="link" class="btnGoToProduct">Go to product</a>
</span>
</div>
</h3>
Example of my problem (Link to image)
https://cdn.shopify.com/s/files/1/0052/2246/5585/products/123_grande.PNG?v=1567946072
I would like the “Product name” and the “$100.00” to be centered inline with the button.
Many thanks in advance
2
Answers
You can do this by converting your layout to use flex-box.
I’ve made some changes to the html (such as removing the RetailerRight1 class) and removed the css float and vertical-align rules in the code.
Code:
The
vertical-inline: baseline
is by default and it is used to keep the divs inline. No need to add any othervertical-inline
properties. Although just removing thevertical-align: top
from classbtnGoToProduct
will fix the issue but I suggest you remove all thevertical-align
properties.