Skip to content

Instantly share code, notes, and snippets.

@DayleySenior
Last active May 14, 2021 17:36
Show Gist options
  • Save DayleySenior/4b5cfa3ff18ec82bd7c5b8cb4166f6a4 to your computer and use it in GitHub Desktop.
Save DayleySenior/4b5cfa3ff18ec82bd7c5b8cb4166f6a4 to your computer and use it in GitHub Desktop.
CSS Inverted Border Tab Menu that flows into the main background

This is a CSS Inverted Border Tab Menu that flows into the main background.

This type of menu pops up a lot on website such as Dribbble.com where designers are creating some of the cleanest website designs, but after a deep search I wasnt able to find where anyone had actually developed this type of menu, only designed it.

This code creates exactly that.

:)

<body>
<div class="nav">
<li class="myLi-1"><a><span class="mySpan">Option 1</span></a></li>
<li class="myLi-2"><a><span class="mySpan">Option 2</span></a></li>
<li class="myLi-3"><a><span class="mySpan">Option 3</span></a></li>
<li class="myLi-4"><a><span class="mySpan">Option 4</span></a></li>
<li class="myLi-5"><a><span class="mySpan">Option 5</span></a></li>
</div>
</body>
/* Body Background */
body {
background-color: #f2f2f2;
}
/* Navigation menu */
.nav {
width: 20%;
background: #f03c9f;
padding: 10px 0px 10px 10px;
}
/* List items */
li {
list-style-type: none;
font-family: helvetica;
color: white;
padding: 15px 25px 15px 25px;
}
/* Link padding */
li a {
padding: 15px 25px 15px 25px;
}
/* list item hover effects */
li:hover {
border-radius: 10px 0px 0px 10px;
background-color: #f2f2f2;
color: black;
}
/* List Item 1 */
.myLi-1:hover:after {
top: 66px;
left: 284px;
position: absolute;
border-top-right-radius: 10px;
box-shadow: 0 -10px 0 0 #f2f2f2;
}
.myLi-1:hover:before {
top: -2px;
left: 284px;
position: absolute;
border-bottom-right-radius: 10px;
box-shadow: 0 10px 0 0 #f2f2f2;
}
/* List Item 2 */
.myLi-2:hover:after {
top: 114px;
left: 284px;
position: absolute;
border-top-right-radius: 10px;
box-shadow: 0 -10px 0 0 #f2f2f2;
}
.myLi-2:hover:before {
top: 46px;
left: 284px;
position: absolute;
border-bottom-right-radius: 10px;
box-shadow: 0 10px 0 0 #f2f2f2;
}
/* List Item 3 */
.myLi-3:hover:after {
top: 162px;
left: 284px;
position: absolute;
border-top-right-radius: 10px;
box-shadow: 0 -10px 0 0 #f2f2f2;
}
.myLi-3:hover:before {
top: 94px;
left: 284px;
position: absolute;
border-bottom-right-radius: 10px;
box-shadow: 0 10px 0 0 #f2f2f2;
}
/* List Item 4 */
.myLi-4:hover:after {
top: 210px;
left: 284px;
position: absolute;
border-top-right-radius: 10px;
box-shadow: 0 -10px 0 0 #f2f2f2;
}
.myLi-4:hover:before {
top: 142px;
left: 284px;
position: absolute;
border-bottom-right-radius: 10px;
box-shadow: 0 10px 0 0 #f2f2f2;
}
/* List Item 5 */
.myLi-5:hover:after {
top: 258px;
left: 284px;
position: absolute;
border-top-right-radius: 10px;
box-shadow: 0 -10px 0 0 #f2f2f2;
}
.myLi-5:hover:before {
top: 190px;
left: 284px;
position: absolute;
border-bottom-right-radius: 10px;
box-shadow: 0 10px 0 0 #f2f2f2;
}
/* all pseudo before & after's */
.nav li:before,
.nav li:after {
content: "";
position: relative;
height: 20px;
width: 20px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment