I have the following list:
<ul>
<li></li>
<li></li>
<li></li>
<li class="container"></li>
<li class="container"></li>
<li class="container"></li>
<li></li>
</ul>
I am trying to create a top- and bottom-border on the container
class elements, but only the first and last must have this border.
I tried to use CSS for this, but the first-child
and last-child
selectors do not do what I was expecting:
CSS:
.container:first-child {
border-top: 1px solid #000;
padding-top: 10px;
}
.container:last-child {
border-bottom: 1px solid #000;
padding-bottom: 10px;
}
Is there a way to dynamically add top- and bottom-borders with just these classes using CSS?