ul {
float: left;
width: 100%;
padding: 0;
margin: 0;
list-style-type: none;
}
a {
float: left;
width: 6em;
text-decoration: none;
color: white;
background-color: purple;
padding: 0.2em 0.6em;
margin: 0em 2em;
border-right: 1px solid white;
}
a:hover {
background-color: fuchsia;
}
li {
display: inline;
}
<ul>
<li><a href="#">Link one</a></li>
<li><a href="#">Link two</a></li>
<li><a href="#">Link three</a></li>
<li><a href="#">Link four</a></li>
</ul>
I am wondering if there is a way to accomplish what I have in that picture, with code. Not the borders or text but the lines in between the menu items. I have tried a few ways including making a div but I can't seem to get the styling right. If anybody has a solution they've used before I would love to hear it. Thank you in advance for any help.
You could use :after
:pseudo-element to add the line. To filter out the last div
you could use #container .box:not(:last-child)
selector, which will select all .box
es but the last one.
.box {
position: relative;
width: 50px;
text-align: center;
display: inline-block;
border: 2px solid black;
padding: 2px 5px 2px 5px;
}
#container .box:not(:last-child) {
margin-right: 25px;
}
#container .box:not(:last-child):after {
position: absolute;
content: '';
right: -50%;
top: 0%;
width: 50%;
height: 50%;
border-bottom: 2px solid black;
}
<div id="container">
<div class="box">Link 1</div>
<div class="box">Link 2</div>
<div class="box">Link 3</div>
</div>