Ok, I've got the following HTML structure
<div class="category">
<div class="container bottom">
<h2>Name1</h2>
</div>
<div class="container top">
<h2>Name2</h2>
</div>
<div class="container ">
<h2>Name3</h2>
</div>
<div class="container">
<h2>Name4</h2>
</div>
<div class="container">
<h2>Name5</h2>
</div>
<div class="container">
<h2>Name6</h2>
</div>
<div class="container">
<h2>Name7</h2>
</div>
</div>
The CSS is this:
* {
margin: 0;
padding: 0;
}
.category {
text-align: center;
width: 95%;
margin: 0 auto;
}
.container {
display: inline-block;
width: 33%;
height: 4em;
}
h2 {
display: inline-block;
width: 100%;
}
.left > * {
text-align: left;
}
.right > *{
text-align: right;
}
.top > * {
vertical-align: top;
}
.bottom > * {
vertical-align: bottom;
}
The main goal is to do something like this: Example
For the sake of it, pretend the picture is accurate and the .container
(gray boxes) have the same size (as you can see in the CSS)
My problem is the vertical-align
is not working.. I've looked into this CodePen Code that works without display: table-cell
and other table-display-related solutions I've found out in StackOverflow. Why doesn't it work with my HTML and CSS code? I get all the <h2>
align in the middle :\