249 lines
6.2 KiB
HTML
249 lines
6.2 KiB
HTML
<!doctype html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>背景图标题组件</title>
|
|
<link
|
|
rel="stylesheet"
|
|
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"
|
|
/>
|
|
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
}
|
|
|
|
body {
|
|
background-color: #f5f7fa;
|
|
color: #333;
|
|
padding: 20px;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
.demo-section {
|
|
background: white;
|
|
border-radius: 12px;
|
|
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
|
|
padding: 30px;
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.demo-section h2 {
|
|
color: #2c3e50;
|
|
margin-bottom: 20px;
|
|
padding-bottom: 10px;
|
|
border-bottom: 2px solid #f0f0f0;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
.demo-section h2 i {
|
|
margin-right: 10px;
|
|
color: #6a11cb;
|
|
}
|
|
|
|
/* 背景图标题组件样式 */
|
|
.hero-section {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 500px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
overflow: hidden;
|
|
border-radius: 12px;
|
|
margin: 30px 0;
|
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.hero-bg {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-image: url('https://images.unsplash.com/photo-1550751827-4bd374c3f58b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1470&q=80');
|
|
background-size: cover;
|
|
background-position: center;
|
|
opacity: 0.5; /* 背景图透明度50% */
|
|
z-index: 1;
|
|
}
|
|
|
|
.hero-content {
|
|
position: relative;
|
|
z-index: 2;
|
|
text-align: center;
|
|
color: #2c3e50;
|
|
max-width: 800px;
|
|
padding: 40px;
|
|
background: rgba(255, 255, 255, 0.85);
|
|
border-radius: 12px;
|
|
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
|
|
backdrop-filter: blur(5px);
|
|
}
|
|
|
|
.hero-title {
|
|
font-size: 2.5rem;
|
|
font-weight: 700;
|
|
margin-bottom: 20px;
|
|
color: #2c3e50;
|
|
position: relative;
|
|
padding-bottom: 15px;
|
|
}
|
|
|
|
.hero-title:after {
|
|
content: '';
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
width: 60px;
|
|
height: 3px;
|
|
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.hero-description {
|
|
font-size: 1.2rem;
|
|
line-height: 1.8;
|
|
margin-bottom: 30px;
|
|
color: #444;
|
|
}
|
|
|
|
.hero-btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 12px 30px;
|
|
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
|
color: white;
|
|
border: none;
|
|
border-radius: 8px;
|
|
font-weight: 600;
|
|
font-size: 1.1rem;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
box-shadow: 0 4px 12px rgba(106, 17, 203, 0.2);
|
|
}
|
|
|
|
.hero-btn:hover {
|
|
transform: translateY(-3px);
|
|
box-shadow: 0 6px 16px rgba(106, 17, 203, 0.3);
|
|
}
|
|
|
|
.hero-btn i {
|
|
margin-right: 10px;
|
|
}
|
|
|
|
/* 响应式设计 */
|
|
@media (max-width: 768px) {
|
|
.hero-section {
|
|
height: 400px;
|
|
}
|
|
|
|
.hero-content {
|
|
padding: 30px 20px;
|
|
margin: 0 15px;
|
|
}
|
|
|
|
.hero-title {
|
|
font-size: 2rem;
|
|
}
|
|
|
|
.hero-description {
|
|
font-size: 1.1rem;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.hero-section {
|
|
height: 350px;
|
|
}
|
|
|
|
.hero-title {
|
|
font-size: 1.8rem;
|
|
}
|
|
|
|
.hero-description {
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.hero-btn {
|
|
padding: 10px 20px;
|
|
font-size: 1rem;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="app">
|
|
<div class="container">
|
|
<div class="demo-section">
|
|
<h2><i class="fas fa-image"></i> 背景图标题组件演示</h2>
|
|
|
|
<hero-section
|
|
title="创新科技,呵护健康"
|
|
description="我们的产品采用先进的电解水技术,能够有效清除口腔细菌,保护牙齿健康。结合微气泡空化效应和次氯酸杀菌技术,提供双重清洁保护,为您带来卓越的口腔护理体验。"
|
|
background-image="https://images.unsplash.com/photo-1550751827-4bd374c3f58b?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1470&q=80"
|
|
button-text="了解更多"
|
|
></hero-section>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const { createApp } = Vue
|
|
|
|
// 背景图标题组件
|
|
const HeroSection = {
|
|
props: {
|
|
title: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
description: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
backgroundImage: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
buttonText: {
|
|
type: String,
|
|
default: '了解更多',
|
|
},
|
|
},
|
|
template: `
|
|
<div class="hero-section">
|
|
<div class="hero-bg" :style="{ backgroundImage: 'url(' + backgroundImage + ')' }"></div>
|
|
<div class="hero-content">
|
|
<h2 class="hero-title">{{ title }}</h2>
|
|
<p class="hero-description">{{ description }}</p>
|
|
<button class="hero-btn">
|
|
<i class="fas fa-info-circle"></i>{{ buttonText }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
`,
|
|
}
|
|
|
|
// 主应用
|
|
const app = createApp({})
|
|
|
|
app.component('HeroSection', HeroSection)
|
|
app.mount('#app')
|
|
</script>
|
|
</body>
|
|
</html>
|