File size: 810 Bytes
b1f1407 | 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 |
class CustomNavbar extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
nav {
background: #333;
color: white;
padding: 1rem;
}
ul {
display: flex;
list-style: none;
margin: 0;
padding: 0;
}
li {
margin-right: 1rem;
}
a {
color: white;
text-decoration: none;
}
</style>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
`;
}
}
customElements.define('custom-navbar', CustomNavbar); |