Spaces:
Running
Running
| class CustomNavbar extends HTMLElement { | |
| connectedCallback() { | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| nav { | |
| background: linear-gradient(135deg, #000000 0%, #1a1a1a 100%); | |
| padding: 1rem 2rem; | |
| display: flex; | |
| justify-content: space-between; | |
| align-items: center; | |
| border-bottom: 2px solid #dc2626; | |
| box-shadow: 0 4px 6px -1px rgba(220, 38, 38, 0.1); | |
| } | |
| .logo { | |
| color: white; | |
| font-weight: bold; | |
| font-size: 1.5rem; | |
| background: linear-gradient(45deg, #ffffff, #dc2626); | |
| background-clip: text; | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| } | |
| ul { | |
| display: flex; | |
| gap: 2rem; | |
| list-style: none; | |
| margin: 0; | |
| padding: 0; | |
| } | |
| a { | |
| color: #e5e5e5; | |
| text-decoration: none; | |
| transition: all 0.3s ease; | |
| font-weight: 500; | |
| } | |
| a:hover { | |
| color: #dc2626; | |
| transform: translateY(-1px); | |
| } | |
| .nav-link { | |
| position: relative; | |
| } | |
| .nav-link::after { | |
| content: ''; | |
| position: absolute; | |
| width: 0; | |
| height: 2px; | |
| bottom: -4px; | |
| left: 0; | |
| background: #dc2626; | |
| transition: width 0.3s ease; | |
| } | |
| .nav-link:hover::after { | |
| width: 100%; | |
| } | |
| @media (max-width: 768px) { | |
| nav { | |
| flex-direction: column; | |
| gap: 1rem; | |
| padding: 1rem; | |
| } | |
| ul { | |
| gap: 1rem; | |
| } | |
| } | |
| </style> | |
| <nav> | |
| <div class="logo">汉字猎人</div> | |
| <ul> | |
| <li><a href="/" class="nav-link">Home</a></li> | |
| <li><a href="/about.html" class="nav-link">About</a></li> | |
| <li><a href="/contact.html" class="nav-link">Contact</a></li> | |
| </ul> | |
| </nav> | |
| `; | |
| } | |
| } | |
| customElements.define('custom-navbar', CustomNavbar); |