国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

首頁(yè) web前端 js教程 如何創(chuàng)建具有動(dòng)態(tài)效果和選擇指示器的超高級(jí)可擴(kuò)展導(dǎo)航欄

如何創(chuàng)建具有動(dòng)態(tài)效果和選擇指示器的超高級(jí)可擴(kuò)展導(dǎo)航欄

Nov 17, 2024 pm 10:55 PM

How to Create an Ultra Premium Expandable Navbar with Dynamic Effects and Selection Indicator

簡(jiǎn)介

在今天的教程中,我們將逐步創(chuàng)建一個(gè)具有時(shí)尚設(shè)計(jì)、動(dòng)態(tài)動(dòng)畫(huà)和現(xiàn)代效果的超優(yōu)質(zhì)可擴(kuò)展導(dǎo)航欄。此高級(jí)導(dǎo)航欄具有以下功能:

高端美感的動(dòng)畫(huà)粒子背景。
具有懸停效果的發(fā)光圖標(biāo)。
突出顯示活動(dòng)部分的動(dòng)態(tài)選擇指示器。
流暢的動(dòng)畫(huà)和過(guò)渡,打造專(zhuān)業(yè)的外觀(guān)。
該導(dǎo)航欄采用 HTML、CSS 和 JavaScript 構(gòu)建,非常適合高質(zhì)量 Web 界面并增強(qiáng)用戶(hù)體驗(yàn),使其成為任何項(xiàng)目的絕佳補(bǔ)充,包括《角斗士之戰(zhàn)》等互動(dòng)游戲。讓我們開(kāi)始吧!

第 1 步:設(shè)置 HTML 結(jié)構(gòu)
我們的可擴(kuò)展導(dǎo)航欄使用 Font Awesome 圖標(biāo)、切換按鈕和自定義數(shù)據(jù)工具提示屬性來(lái)為每個(gè)圖標(biāo)提供描述。這種標(biāo)記為我們提供了一個(gè)靈活的構(gòu)建結(jié)構(gòu)。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Expandable Premium Navbar</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
  <link rel="stylesheet" href="styles.css">
</head>
<body>

  <!-- Particle Background -->
  <div>



<p>Key HTML Elements<br>
Particle Background: Provides a subtle, animated effect behind the navbar for a high-end look.<br>
Toggle Button: Allows users to expand or collapse the navbar.<br>
Nav Items: Each item includes a tooltip, an icon, and some have notification badges.<br>
Selection Indicator: Highlights the active section with a glowing effect.<br>
Step 2: Styling the Navbar with CSS<br>
Our CSS will focus on creating a luxurious, modern design with animated background particles, hover effects, and tooltip displays. Let’s go through each part.</p>

<p>Base Styles and Background Setup<br>
</p>

<pre class="brush:php;toolbar:false">body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  margin: 0;
  background: radial-gradient(circle, #1b1b2f, #121212);
  font-family: Arial, sans-serif;
  overflow: hidden;
  position: relative;
}

/* Particle Background */
#particle-background {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: url('https://www.transparenttextures.com/patterns/dark-matter.png');
  animation: particleAnimation 30s linear infinite;
  opacity: 0.3;
}

@keyframes particleAnimation {
  0% { background-position: 0 0; }
  100% { background-position: 1000px 1000px; }
}
Navbar Styling
The navbar includes a semi-transparent background with a subtle blur effect to achieve a glassy look, which expands and collapses smoothly.

css
Copier le code
.navbar {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  padding: 15px;
  border-radius: 40px;
  backdrop-filter: blur(15px);
  box-shadow: 0px 10px 30px rgba(0, 0, 0, 0.6);
  transition: width 0.4s ease, padding 0.4s ease;
  gap: 15px;
  width: 60px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.navbar.expanded {
  width: 360px;
  padding: 15px 20px;
  justify-content: flex-start;
}

切換按鈕
切換按鈕可展開(kāi)和折疊導(dǎo)航欄,并在懸停時(shí)顯示旋轉(zhuǎn)動(dòng)畫(huà)。

.toggle-button {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.3s ease, color 0.3s ease;
}

.toggle-button:hover {
  color: #ff00cc;
  transform: rotate(90deg);
}

導(dǎo)航項(xiàng)和工具提示效果
每個(gè)導(dǎo)航項(xiàng)都有一個(gè)帶有漸變和發(fā)光背景的懸停效果。工具提示以柔和的陰影效果出現(xiàn)以引導(dǎo)用戶(hù)。

.nav-item {
  position: relative;
  padding: 12px;
  font-size: 24px;
  color: #ffffff;
  cursor: pointer;
  border-radius: 15px;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
}

.nav-item:hover {
  background: linear-gradient(135deg, rgba(255, 0, 204, 0.4), rgba(51, 51, 255, 0.4));
  transform: translateY(-5px) scale(1.05);
}

.nav-item::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: -45px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 12px;
  color: #ffffff;
  background: rgba(30, 30, 30, 0.85);
  padding: 8px 12px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.nav-item:hover::before {
  opacity: 1;
  transform: translateY(-8px);
}

選擇指示器和通知徽章

.selection-indicator {
  position: absolute;
  bottom: 10px;
  height: 4px;
  width: 30px;
  background: linear-gradient(90deg, #ff00cc, #3333ff);
  border-radius: 2px;
  transition: transform 0.3s ease, width 0.3s ease;
  z-index: -1;
}

/* Notification Badge */
.notification-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  background: linear-gradient(45deg, #ff0000, #ff4d4d);
  color: #ffffff;
  border-radius: 50%;
  padding: 4px 7px;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.3);
  animation: pulse 1.8s infinite ease-in-out;
}

第 3 步:添加 JavaScript 以實(shí)現(xiàn)交互
JavaScript 控制導(dǎo)航欄的可展開(kāi)狀態(tài)、活動(dòng)項(xiàng)目和選擇指示器。它還可以在調(diào)整大小時(shí)使指示器與所選項(xiàng)目保持對(duì)齊。

const toggleButton = document.querySelector('.toggle-button');
const navbar = document.querySelector('.navbar');
const navItems = document.querySelectorAll('.nav-item');
const selectionIndicator = document.querySelector('.selection-indicator');

// Toggle the expanded state of the navbar
toggleButton.addEventListener('click', () => {
  navbar.classList.toggle('expanded');
  toggleButton.querySelector('i').classList.toggle('fa-bars');
  toggleButton.querySelector('i').classList.toggle('fa-times');
});

// Update selection indicator position
function updateSelectionIndicator(activeItem) {
  const itemRect = activeItem.getBoundingClientRect();
  const navbarRect = navbar.getBoundingClientRect();
  const offsetX = itemRect.left - navbarRect.left + navbar.scrollLeft;
  selectionIndicator.style.transform = `translateX(${offsetX}px)`;
  selectionIndicator.style.width = `${itemRect.width}px`;
}

// Handle nav item selection
navItems.forEach((item) => {
  item.addEventListener('click', () => {
    navItems.forEach(nav => nav.classList.remove('active'));
    item.classList.add('active');
    updateSelectionIndicator(item);
  });
});

// Initialize the position of the selection indicator on page load
document.addEventListener('DOMContentLoaded', () => {
  const activeItem = document.querySelector('.nav-item.active');
  if (activeItem) {
    updateSelectionIndicator(activeItem);
  }
});

結(jié)論
創(chuàng)建具有動(dòng)態(tài)動(dòng)畫(huà)和直觀(guān)界面的優(yōu)質(zhì)可擴(kuò)展導(dǎo)航欄可以提升任何 Web 項(xiàng)目的水平。通過(guò)用于設(shè)計(jì)的 CSS 和用于交互的 JavaScript,我們構(gòu)建了一個(gè)靈活的組件,非常適合 Gladiators Battle 等高端應(yīng)用程序。該導(dǎo)航欄的平滑過(guò)渡、發(fā)光效果和可擴(kuò)展功能提供了專(zhuān)業(yè)且現(xiàn)代的用戶(hù)體驗(yàn)。

?發(fā)現(xiàn)更多:

探索角斗士之戰(zhàn):潛入古代武士的世界,體驗(yàn)戰(zhàn)略游戲玩法,網(wǎng)址為 https://gladiatorsbattle.com
查看我們的 GitHub:查看代碼示例和文檔:https://github.com/HanGPIErr/Gladiators-Battle-Documentation
在 LinkedIn 上聯(lián)系:在 https://www.linkedin.com/in/pierre-romain-lopez/
上關(guān)注我 關(guān)注 X:在 https://x.com/GladiatorsBT
上了解設(shè)計(jì)和游戲項(xiàng)目的最新動(dòng)態(tài) 請(qǐng)繼續(xù)關(guān)注有關(guān)使用 HTML、CSS 和 JavaScript 創(chuàng)建高級(jí) Web 組件的更多教程!

以上是如何創(chuàng)建具有動(dòng)態(tài)效果和選擇指示器的超高級(jí)可擴(kuò)展導(dǎo)航欄的詳細(xì)內(nèi)容。更多信息請(qǐng)關(guān)注PHP中文網(wǎng)其他相關(guān)文章!

本站聲明
本文內(nèi)容由網(wǎng)友自發(fā)貢獻(xiàn),版權(quán)歸原作者所有,本站不承擔(dān)相應(yīng)法律責(zé)任。如您發(fā)現(xiàn)有涉嫌抄襲侵權(quán)的內(nèi)容,請(qǐng)聯(lián)系admin@php.cn

熱AI工具

Undress AI Tool

Undress AI Tool

免費(fèi)脫衣服圖片

Undresser.AI Undress

Undresser.AI Undress

人工智能驅(qū)動(dòng)的應(yīng)用程序,用于創(chuàng)建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用于從照片中去除衣服的在線(xiàn)人工智能工具。

Clothoff.io

Clothoff.io

AI脫衣機(jī)

Video Face Swap

Video Face Swap

使用我們完全免費(fèi)的人工智能換臉工具輕松在任何視頻中換臉!

熱工具

記事本++7.3.1

記事本++7.3.1

好用且免費(fèi)的代碼編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用

禪工作室 13.0.1

禪工作室 13.0.1

功能強(qiáng)大的PHP集成開(kāi)發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺(jué)化網(wǎng)頁(yè)開(kāi)發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級(jí)代碼編輯軟件(SublimeText3)

熱門(mén)話(huà)題

JavaScript與Java:您應(yīng)該學(xué)到哪種語(yǔ)言? JavaScript與Java:您應(yīng)該學(xué)到哪種語(yǔ)言? Jun 10, 2025 am 12:05 AM

javascriptisidealforwebdevelogment,whilejavasuitslarge-scaleapplicationsandandandroiddevelopment.1)javascriptexceleatingingingingingingingbeatingwebexperienceswebexperienceswebexperiencesandfull-stackdeevermentwithnode.js.2)

在JavaScript中使用哪些評(píng)論符號(hào):一個(gè)明確的解釋 在JavaScript中使用哪些評(píng)論符號(hào):一個(gè)明確的解釋 Jun 12, 2025 am 10:27 AM

在JavaScript中,選擇單行注釋?zhuān)?/)還是多行注釋?zhuān)?/)取決于注釋的目的和項(xiàng)目需求:1.使用單行注釋進(jìn)行快速、內(nèi)聯(lián)的解釋?zhuān)?.使用多行注釋進(jìn)行詳細(xì)的文檔說(shuō)明;3.保持注釋風(fēng)格的一致性;4.避免過(guò)度注釋?zhuān)?.確保注釋與代碼同步更新。選擇合適的注釋風(fēng)格有助于提高代碼的可讀性和可維護(hù)性。

JavaScript評(píng)論的最終指南:增強(qiáng)代碼清晰度 JavaScript評(píng)論的最終指南:增強(qiáng)代碼清晰度 Jun 11, 2025 am 12:04 AM

是的,javascriptcommentsarenectary和shouldshouldshouldseffectional.1)他們通過(guò)codeLogicAndIntentsgudedepleders,2)asevitalincomplexprojects,和3)handhanceClaritywithOutClutteringClutteringThecode。

Java vs. JavaScript:清除混亂 Java vs. JavaScript:清除混亂 Jun 20, 2025 am 12:27 AM

Java和JavaScript是不同的編程語(yǔ)言,各自適用于不同的應(yīng)用場(chǎng)景。Java用于大型企業(yè)和移動(dòng)應(yīng)用開(kāi)發(fā),而JavaScript主要用于網(wǎng)頁(yè)開(kāi)發(fā)。

JavaScript評(píng)論:簡(jiǎn)短說(shuō)明 JavaScript評(píng)論:簡(jiǎn)短說(shuō)明 Jun 19, 2025 am 12:40 AM

JavascriptconcommentsenceenceEncorenceEnterential gransimenting,reading and guidingCodeeXecution.1)單inecommentsareusedforquickexplanations.2)多l(xiāng)inecommentsexplaincomplexlogicorprovideDocumentation.3)

掌握J(rèn)avaScript評(píng)論:綜合指南 掌握J(rèn)avaScript評(píng)論:綜合指南 Jun 14, 2025 am 12:11 AM

評(píng)論arecrucialinjavascriptformaintainingclarityclarityandfosteringCollaboration.1)heelpindebugging,登機(jī),andOnderStandingCodeeVolution.2)使用林格forquickexexplanations andmentmentsmmentsmmentsmments andmmentsfordeffordEffordEffordEffordEffordEffordEffordEffordEddeScriptions.3)bestcractices.3)bestcracticesincracticesinclud

JavaScript數(shù)據(jù)類(lèi)型:深度潛水 JavaScript數(shù)據(jù)類(lèi)型:深度潛水 Jun 13, 2025 am 12:10 AM

JavaScripthasseveralprimitivedatatypes:Number,String,Boolean,Undefined,Null,Symbol,andBigInt,andnon-primitivetypeslikeObjectandArray.Understandingtheseiscrucialforwritingefficient,bug-freecode:1)Numberusesa64-bitformat,leadingtofloating-pointissuesli

JavaScript與Java:開(kāi)發(fā)人員的全面比較 JavaScript與Java:開(kāi)發(fā)人員的全面比較 Jun 20, 2025 am 12:21 AM

JavaScriptIspreferredforredforwebdevelverment,而Javaisbetterforlarge-ScalebackendsystystemsandSandAndRoidApps.1)JavascriptexcelcelsincreatingInteractiveWebexperienceswebexperienceswithitswithitsdynamicnnamicnnamicnnamicnnamicnemicnemicnemicnemicnemicnemicnemicnemicnddommanipulation.2)

See all articles