\n
\n\n\n\n

Key HTML Elements
\nBadge: Labels each item with statuses like \"New\" or \"Popular.\"
\nProduct Image: Displays the item with a glowing effect and 3D depth.
\nStats: Uses progress bars to display item attributes like defense or attack.
\nIcons: Interactive icons at the bottom of each card provide quick access to favorite actions.
\nStep 2: Designing with CSS
\nBasic Styles and Background
\nThe background uses a radial gradient to create a dramatic look, while each product card is styled with gradients, shadows, and smooth transitions.
\n<\/p>\n\n

body {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  min-height: 100vh;\n  margin: 0;\n  background: radial-gradient(circle at center, #1b1b2f, #090909);\n  font-family: Arial, sans-serif;\n  overflow: hidden;\n  color: #fff;\n}\n\n.product-showcase {\n  display: flex;\n  gap: 40px;\n  perspective: 1200px;\n}\n<\/pre>\n\n\n\n

產(chǎn)品卡片樣式
\n每張卡片均采用 3D 外觀設(shè)計(jì),并包含用于交互的懸停效果。 :hover 效果提供微妙的旋轉(zhuǎn)和發(fā)光,增強(qiáng)高級感。
\n<\/p>\n\n

.product-card {\n  position: relative;\n  width: 270px;\n  height: 420px;\n  padding: 25px;\n  background: linear-gradient(145deg, #2a2a2a, #3c3c3c);\n  border-radius: 20px;\n  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.5);\n  display: flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  transform-style: preserve-3d;\n  transition: transform 0.5s, box-shadow 0.5s, background 0.5s;\n  cursor: pointer;\n  overflow: hidden;\n}\n\n.product-card:hover {\n  transform: scale(1.1) rotateY(10deg);\n  box-shadow: 0 30px 60px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 255, 0, 0.7);\n}\n<\/pre>\n\n\n\n

統(tǒng)計(jì)數(shù)據(jù)和進(jìn)度條
\n我們使用進(jìn)度條來展示防御力、耐久度等屬性,為展示增添了獨(dú)特的視覺元素。
\n<\/p>\n\n

.stats {\n  width: 100%;\n  margin-top: 15px;\n}\n\n.stat-bar {\n  display: flex;\n  align-items: center;\n  justify-content: space-between;\n  margin-bottom: 10px;\n  color: #ffd700;\n  font-size: 14px;\n  font-weight: bold;\n}\n\n.progress {\n  width: 60%;\n  height: 8px;\n  background: rgba(255, 255, 255, 0.2);\n  border-radius: 5px;\n}\n\n.progress-bar {\n  height: 100%;\n  background: linear-gradient(90deg, #ffcc00, #f9844a);\n}\n<\/pre>\n\n\n\n

添加粒子效果
\n添加移動(dòng)和改變顏色的粒子可以增強(qiáng)身臨其境的感覺。這些粒子可以脈動(dòng)產(chǎn)生發(fā)光效果。
\n<\/p>\n\n

.particle {\n  position: absolute;\n  width: 4px;\n  height: 4px;\n  border-radius: 50%;\n  background: rgba(255, 215, 0, 0.9);\n  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 0 20px rgba(255, 255, 0, 0.3);\n  animation: particleAnimation 3s ease-in-out infinite, particleMove 4s linear infinite;\n}\n<\/pre>\n\n\n\n

第 3 步:添加 JavaScript 交互性
\nJavaScript 管理懸停動(dòng)畫、點(diǎn)擊事件和發(fā)光粒子效果。<\/p>\n\n

添加懸停和點(diǎn)擊動(dòng)畫
\n我們通過鼠標(biāo)移動(dòng)來制作卡片旋轉(zhuǎn)和縮放的動(dòng)畫,并通過單擊切換縮放。
\n<\/p>\n\n

const cards = document.querySelectorAll('.product-card');\n\ncards.forEach((card) => {\n  let isClicked = false;\n\n  card.addEventListener('mousemove', (e) => {\n    if (!isClicked) {\n      const { width, height } = card.getBoundingClientRect();\n      const offsetX = e.clientX - card.offsetLeft - width \/ 2;\n      const offsetY = e.clientY - card.offsetTop - height \/ 2;\n      const rotationX = (offsetY \/ height) * -25;\n      const rotationY = (offsetX \/ width) * 25;\n\n      card.style.transform = `rotateY(${rotationY}deg) rotateX(${rotationX}deg) scale(1.05)`;\n    }\n  });\n\n  card.addEventListener('mouseleave', () => {\n    if (!isClicked) {\n      card.style.transform = 'rotateY(0deg) rotateX(0deg) scale(1)';\n    }\n  });\n\n  card.addEventListener('click', () => {\n    isClicked = !isClicked;\n    card.style.transform = isClicked\n      ? 'scale(1.2) rotateY(0deg) rotateX(0deg)'\n      : 'rotateY(0deg) rotateX(0deg) scale(1)';\n  });\n});\n<\/pre>\n\n\n\n

添加發(fā)光粒子
\n為了增強(qiáng)氣氛,我們創(chuàng)建了在每張產(chǎn)品卡周圍隨機(jī)移動(dòng)的粒子。
\n<\/p>\n\n

function addParticleEffect() {\n  const particle = document.createElement('div');\n  particle.classList.add('particle');\n  particle.style.left = `${Math.random() * 100}%`;\n  particle.style.top = `${Math.random() * 100}%`;\n  particle.style.animationDuration = `${2 + Math.random() * 3}s`;\n  document.body.appendChild(particle);\n\n  setTimeout(() => particle.remove(), 5000);\n}\n\nsetInterval(() => {\n  cards.forEach(() => addParticleEffect());\n}, 1000);\n<\/pre>\n\n\n\n

結(jié)論
\n利用動(dòng)態(tài)動(dòng)畫和粒子效果構(gòu)建 3D 角斗士主題產(chǎn)品展示,打造引人入勝的互動(dòng)體驗(yàn),吸引用戶。通過將用于視覺樣式的 CSS 和用于交互性的 JavaScript 相結(jié)合,我們創(chuàng)建了一個(gè)高質(zhì)量的沉浸式組件,非常適合產(chǎn)品展示或游戲相關(guān)網(wǎng)站。受《角斗士之戰(zhàn)》的啟發(fā),該展示凸顯了現(xiàn)代網(wǎng)頁設(shè)計(jì)與歷史主題相結(jié)合的力量。<\/p>\n\n

?發(fā)現(xiàn)更多:<\/p>\n

探索角斗士之戰(zhàn):在 https:\/\/gladiatorsbattle.com 潛入古代武士和戰(zhàn)略游戲的世界。
\nGitHub:查看更多項(xiàng)目:https:\/\/github.com\/HanGPIErr。
\nLinkedIn:連接以獲取項(xiàng)目更新:https:\/\/www.linkedin.com\/in\/pierre-romain-lopez\/。
\nTwitter:關(guān)注 https:\/\/x.com\/GladiatorsBT 了解設(shè)計(jì)和開發(fā)見解。
\n請繼續(xù)關(guān)注有關(guān)創(chuàng)建引人入勝的交互式組件的更多教程!<\/p>\n\n\n \n\n \n "}

亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

首頁 web前端 css教程 角斗士產(chǎn)品角斗士主題產(chǎn)品展示,帶有動(dòng)態(tài)粒子和交互式動(dòng)畫

角斗士產(chǎn)品角斗士主題產(chǎn)品展示,帶有動(dòng)態(tài)粒子和交互式動(dòng)畫

Nov 14, 2024 pm 03:39 PM

Gladiator Product Gladiator-Themed Product Showcase with Dynamic Particles & Interactive Animations

簡介

在本教程中,我們將創(chuàng)建一個(gè)超優(yōu)質(zhì)的 3D 角斗士主題產(chǎn)品展示,其中包括動(dòng)畫產(chǎn)品卡、動(dòng)態(tài)懸停效果、點(diǎn)擊交互以及使每件物品栩栩如生的發(fā)光粒子效果。該展示專為沉浸式用戶體驗(yàn)而設(shè)計(jì),結(jié)合了 3D 變換、發(fā)光動(dòng)畫和脈動(dòng)亮點(diǎn),為每件產(chǎn)品帶來獨(dú)特的互動(dòng)感覺。這個(gè)設(shè)計(jì)的靈感來自于《角斗士之戰(zhàn)》,這是一款互動(dòng)游戲,玩家可以在其中體驗(yàn)古代戰(zhàn)斗和策略的快感。

跟隨創(chuàng)建您自己的交互式產(chǎn)品展示,并學(xué)習(xí)如何使用 HTML、CSS 和 JavaScript 來實(shí)現(xiàn)令人驚嘆的視覺效果和動(dòng)態(tài)動(dòng)畫。

第 1 步:設(shè)置 HTML 結(jié)構(gòu)
每張產(chǎn)品卡都代表一個(gè)角斗士主題的物品,例如盾牌或劍,并帶有徽章、圖標(biāo)和統(tǒng)計(jì)數(shù)據(jù)等互動(dòng)元素。

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



<p>Key HTML Elements<br>
Badge: Labels each item with statuses like "New" or "Popular."<br>
Product Image: Displays the item with a glowing effect and 3D depth.<br>
Stats: Uses progress bars to display item attributes like defense or attack.<br>
Icons: Interactive icons at the bottom of each card provide quick access to favorite actions.<br>
Step 2: Designing with CSS<br>
Basic Styles and Background<br>
The background uses a radial gradient to create a dramatic look, while each product card is styled with gradients, shadows, and smooth transitions.<br>
</p>

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

.product-showcase {
  display: flex;
  gap: 40px;
  perspective: 1200px;
}

產(chǎn)品卡片樣式
每張卡片均采用 3D 外觀設(shè)計(jì),并包含用于交互的懸停效果。 :hover 效果提供微妙的旋轉(zhuǎn)和發(fā)光,增強(qiáng)高級感。

.product-card {
  position: relative;
  width: 270px;
  height: 420px;
  padding: 25px;
  background: linear-gradient(145deg, #2a2a2a, #3c3c3c);
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7), 0 0 20px rgba(255, 215, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform-style: preserve-3d;
  transition: transform 0.5s, box-shadow 0.5s, background 0.5s;
  cursor: pointer;
  overflow: hidden;
}

.product-card:hover {
  transform: scale(1.1) rotateY(10deg);
  box-shadow: 0 30px 60px rgba(255, 215, 0, 0.8), 0 0 30px rgba(255, 255, 0, 0.7);
}

統(tǒng)計(jì)數(shù)據(jù)和進(jìn)度條
我們使用進(jìn)度條來展示防御力、耐久度等屬性,為展示增添了獨(dú)特的視覺元素。

.stats {
  width: 100%;
  margin-top: 15px;
}

.stat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  color: #ffd700;
  font-size: 14px;
  font-weight: bold;
}

.progress {
  width: 60%;
  height: 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 5px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #ffcc00, #f9844a);
}

添加粒子效果
添加移動(dòng)和改變顏色的粒子可以增強(qiáng)身臨其境的感覺。這些粒子可以脈動(dòng)產(chǎn)生發(fā)光效果。

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.9);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5), 0 0 20px rgba(255, 255, 0, 0.3);
  animation: particleAnimation 3s ease-in-out infinite, particleMove 4s linear infinite;
}

第 3 步:添加 JavaScript 交互性
JavaScript 管理懸停動(dòng)畫、點(diǎn)擊事件和發(fā)光粒子效果。

添加懸停和點(diǎn)擊動(dòng)畫
我們通過鼠標(biāo)移動(dòng)來制作卡片旋轉(zhuǎn)和縮放的動(dòng)畫,并通過單擊切換縮放。

const cards = document.querySelectorAll('.product-card');

cards.forEach((card) => {
  let isClicked = false;

  card.addEventListener('mousemove', (e) => {
    if (!isClicked) {
      const { width, height } = card.getBoundingClientRect();
      const offsetX = e.clientX - card.offsetLeft - width / 2;
      const offsetY = e.clientY - card.offsetTop - height / 2;
      const rotationX = (offsetY / height) * -25;
      const rotationY = (offsetX / width) * 25;

      card.style.transform = `rotateY(${rotationY}deg) rotateX(${rotationX}deg) scale(1.05)`;
    }
  });

  card.addEventListener('mouseleave', () => {
    if (!isClicked) {
      card.style.transform = 'rotateY(0deg) rotateX(0deg) scale(1)';
    }
  });

  card.addEventListener('click', () => {
    isClicked = !isClicked;
    card.style.transform = isClicked
      ? 'scale(1.2) rotateY(0deg) rotateX(0deg)'
      : 'rotateY(0deg) rotateX(0deg) scale(1)';
  });
});

添加發(fā)光粒子
為了增強(qiáng)氣氛,我們創(chuàng)建了在每張產(chǎn)品卡周圍隨機(jī)移動(dòng)的粒子。

function addParticleEffect() {
  const particle = document.createElement('div');
  particle.classList.add('particle');
  particle.style.left = `${Math.random() * 100}%`;
  particle.style.top = `${Math.random() * 100}%`;
  particle.style.animationDuration = `${2 + Math.random() * 3}s`;
  document.body.appendChild(particle);

  setTimeout(() => particle.remove(), 5000);
}

setInterval(() => {
  cards.forEach(() => addParticleEffect());
}, 1000);

結(jié)論
利用動(dòng)態(tài)動(dòng)畫和粒子效果構(gòu)建 3D 角斗士主題產(chǎn)品展示,打造引人入勝的互動(dòng)體驗(yàn),吸引用戶。通過將用于視覺樣式的 CSS 和用于交互性的 JavaScript 相結(jié)合,我們創(chuàng)建了一個(gè)高質(zhì)量的沉浸式組件,非常適合產(chǎn)品展示或游戲相關(guān)網(wǎng)站。受《角斗士之戰(zhàn)》的啟發(fā),該展示凸顯了現(xiàn)代網(wǎng)頁設(shè)計(jì)與歷史主題相結(jié)合的力量。

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

探索角斗士之戰(zhàn):在 https://gladiatorsbattle.com 潛入古代武士和戰(zhàn)略游戲的世界。
GitHub:查看更多項(xiàng)目:https://github.com/HanGPIErr。
LinkedIn:連接以獲取項(xiàng)目更新:https://www.linkedin.com/in/pierre-romain-lopez/。
Twitter:關(guān)注 https://x.com/GladiatorsBT 了解設(shè)計(jì)和開發(fā)見解。
請繼續(xù)關(guān)注有關(guān)創(chuàng)建引人入勝的交互式組件的更多教程!

以上是角斗士產(chǎn)品角斗士主題產(chǎn)品展示,帶有動(dòng)態(tài)粒子和交互式動(dòng)畫的詳細(xì)內(nèi)容。更多信息請關(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)容,請聯(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

用于從照片中去除衣服的在線人工智能工具。

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集成開發(fā)環(huán)境

Dreamweaver CS6

Dreamweaver CS6

視覺化網(wǎng)頁開發(fā)工具

SublimeText3 Mac版

SublimeText3 Mac版

神級代碼編輯軟件(SublimeText3)

CSS教程,用于創(chuàng)建加載旋轉(zhuǎn)器和動(dòng)畫 CSS教程,用于創(chuàng)建加載旋轉(zhuǎn)器和動(dòng)畫 Jul 07, 2025 am 12:07 AM

創(chuàng)建CSS加載旋轉(zhuǎn)器的方法有三種:1.使用邊框的基本旋轉(zhuǎn)器,通過HTML和CSS實(shí)現(xiàn)簡單動(dòng)畫;2.使用多個(gè)點(diǎn)的自定義旋轉(zhuǎn)器,通過不同延遲時(shí)間實(shí)現(xiàn)跳動(dòng)效果;3.在按鈕中添加旋轉(zhuǎn)器,通過JavaScript切換類來顯示加載狀態(tài)。每種方法都強(qiáng)調(diào)了設(shè)計(jì)細(xì)節(jié)如顏色、大小、可訪問性和性能優(yōu)化的重要性,以提升用戶體驗(yàn)。

解決CSS瀏覽器兼容性問題和前綴 解決CSS瀏覽器兼容性問題和前綴 Jul 07, 2025 am 01:44 AM

處理CSS瀏覽器兼容性和前綴問題需理解瀏覽器支持差異并合理使用廠商前綴。1.了解常見問題如Flexbox、Grid支持不一,position:sticky失效,動(dòng)畫表現(xiàn)不同;2.查閱CanIuse確認(rèn)特性支持情況;3.正確使用-webkit-、-moz-、-ms-、-o-等廠商前綴;4.推薦使用Autoprefixer自動(dòng)添加前綴;5.安裝PostCSS并配置browserslist指定目標(biāo)瀏覽器;6.構(gòu)建時(shí)自動(dòng)處理兼容性;7.老項(xiàng)目可用Modernizr檢測特性;8.不必追求所有瀏覽器一致,確

使用CSS剪輯路徑創(chuàng)建自定義形狀 使用CSS剪輯路徑創(chuàng)建自定義形狀 Jul 09, 2025 am 01:29 AM

使用CSS的clip-path屬性可以裁剪元素為自定義形狀,如三角形、圓形缺口、多邊形等,無需依賴圖片或SVG。其優(yōu)勢包括:1.支持circle、ellipse、polygon等多種基本形狀;2.可響應(yīng)式調(diào)整,適配移動(dòng)端;3.易于動(dòng)畫化,可結(jié)合hover或JavaScript實(shí)現(xiàn)動(dòng)態(tài)效果;4.不影響布局流,僅裁剪顯示區(qū)域。常見用法如圓形裁剪clip-path:circle(50pxatcenter)和三角形裁剪clip-path:polygon(50%0%,1000%,00%)。注意

顯示:內(nèi)聯(lián),顯示:塊和顯示:內(nèi)聯(lián)塊之間有什么區(qū)別? 顯示:內(nèi)聯(lián),顯示:塊和顯示:內(nèi)聯(lián)塊之間有什么區(qū)別? Jul 11, 2025 am 03:25 AM

Themaindifferencesbetweendisplay:inline,block,andinline-blockinHTML/CSSarelayoutbehavior,spaceusage,andstylingcontrol.1.Inlineelementsflowwithtext,don’tstartonnewlines,ignorewidth/height,andonlyapplyhorizo??ntalpadding/margins—idealforinlinetextstyling

造型與CSS不同訪問的鏈接 造型與CSS不同訪問的鏈接 Jul 11, 2025 am 03:26 AM

設(shè)置訪問過鏈接的樣式能提升用戶體驗(yàn),尤其在內(nèi)容密集型網(wǎng)站中幫助用戶更好導(dǎo)航。1.使用CSS的:visited偽類可定義已訪問鏈接樣式,如顏色變化;2.注意瀏覽器出于隱私限制僅允許修改部分屬性;3.顏色選擇應(yīng)與整體風(fēng)格協(xié)調(diào),避免突兀;4.移動(dòng)端可能不顯示該效果,建議結(jié)合其他視覺提示如icon輔助標(biāo)識。

CSS繪畫API是什么? CSS繪畫API是什么? Jul 04, 2025 am 02:16 AM

thecsspaintingapienablesdemimageGenerationinCsssingJavascript.1.developersCreateApaintWorkletClassWithaPaint()method.2.theyregisteritviaregisterpaint()。3.thecustompAntFunctionSthenusitySthenusedisthenusedisthenusedIncerspropertieslikeBacknockforg-image-image.thisallows.thisallowsforderforderynamecvis

如何使用CSS創(chuàng)建響應(yīng)式圖像? 如何使用CSS創(chuàng)建響應(yīng)式圖像? Jul 15, 2025 am 01:10 AM

要使用CSS創(chuàng)建響應(yīng)式圖片,主要可通過以下方法實(shí)現(xiàn):1.使用max-width:100%和height:auto讓圖片在保持比例的同時(shí)自適應(yīng)容器寬度;2.結(jié)合HTML的srcset和sizes屬性智能加載適配不同屏幕的圖片源;3.利用object-fit和object-position控制圖片裁剪與焦點(diǎn)展示。這些方法共同確保圖片在不同設(shè)備上清晰、美觀地呈現(xiàn)。

什么是常見的CSS瀏覽器不一致? 什么是常見的CSS瀏覽器不一致? Jul 26, 2025 am 07:04 AM

不同瀏覽器對CSS解析存在差異,導(dǎo)致顯示效果不一致,主要包括默認(rèn)樣式差異、盒模型計(jì)算方式、Flexbox和Grid布局支持程度及某些CSS屬性行為不一致。1.默認(rèn)樣式處理不一致,解決方法是使用CSSReset或Normalize.css統(tǒng)一初始樣式;2.舊版IE的盒模型計(jì)算方式不同,建議統(tǒng)一使用box-sizing:border-box;3.Flexbox和Grid在邊緣情況或舊版本中表現(xiàn)有差異,應(yīng)多測試并使用Autoprefixer;4.某些CSS屬性行為不一致,需查閱CanIuse并提供降級

See all articles