Issue
im trying to create something like this google tabs menu with this bar with some radius.
ul {
border-bottom: 1px solid #eee;
}
ul li {
display: inline-block;
text-decoration: none;
}
li {
padding: 10px 0px;
margin: 0 20px;
cursor: pointer;
}
li a.active {
position: relative;
content: "";
display: block;
height: 4px;
width: 100%;
background: #1a73e8;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
<ul>
<li><a href="index.html" class="active">Dashboard</a></li>
<li><a href="mytasks.htm">My tasks</a></li>
</ul>
I tried various types of combinations but failed...
Solution
- Use the
::after
pseudo on the.active
anchor - don't style
li
elements. Treat them as semantic wrappers - use display: flex on the
.tabs
(yes, use a class for that UL parent)
/*QuickReset*/ * { margin: 0; box-sizing: border-box; }
.tabs {
padding: 0;
display: flex;
gap: 1rem;
border-bottom: 1px solid #eee;
list-style: none;
}
.tabs a {
position: relative;
display: block;
text-decoration: none;
padding: 1rem 0;
color: #888;
}
.tabs a.active {
color: #1a73e8;
}
.tabs a.active::after {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 4px;
background-color: currentColor;
border-radius: 4px 4px 0 0;
}
<ul class="tabs">
<li><a href="index.html">Dashboard</a></li>
<li><a href="mytasks.html" class="active">My tasks</a></li>
<li><a href="settings.html">Settings</a></li>
<li><a href="prifile.html">Profile</a></li>
</ul>
Answered By - Roko C. Buljan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.