File size: 2,107 Bytes
6943658 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
class CustomNavbar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
nav {
background: white;
padding: 1.5rem;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
position: sticky;
top: 0;
z-index: 100;
}
.logo {
font-weight: bold;
font-size: 1.25rem;
color: #4f46e5;
display: flex;
align-items: center;
}
.logo i {
margin-right: 0.5rem;
}
ul {
display: flex;
gap: 1.5rem;
list-style: none;
margin: 0;
padding: 0;
}
a {
color: #4b5563;
text-decoration: none;
font-weight: 500;
padding: 0.5rem 0;
position: relative;
transition: color 0.2s;
}
a:hover {
color: #4f46e5;
}
a::after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 0;
height: 2px;
background-color: #4f46e5;
transition: width 0.3s;
}
a:hover::after {
width: 100%;
}
.mobile-menu {
display: none;
}
@media (max-width: 768px) {
ul {
display: none;
}
.mobile-menu {
display: block;
}
}
</style>
<nav>
<a href="#" class="logo">
<i data-feather="user"></i>
<span>Nikhilesh</span>
</a>
<ul>
<li><a href="#about">About</a></li>
<li><a href="#experience">Experience</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
<button class="mobile-menu" aria-label="Menu">
<i data-feather="menu"></i>
</button>
</nav>
`;
}
}
customElements.define('custom-navbar', CustomNavbar); |