三階段漸進式修改示範 - 展示如何用自然語言與AI溝通
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>媒體網站</title>
</head>
<body>
<style>
body {
text-align: center;
padding-top: 100px;
padding-bottom: 50px;
color: white;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
nav {
background-color: rgba(0, 0, 0, 0.8);
padding: 15px 20px;
position: fixed;
top: 0;
left: 0;
right: 0;
}
h1 {
font-size: 42px;
margin-bottom: 20px;
text-shadow: 2px 2px 4px black;
}
video {
width: 100%;
margin: 30px 0;
}
</style>
<nav>
<div class="logo">我的網站</div>
<ul>
<li><a href="index.html">首頁</a></li>
<li><a href="media.html">多媒體</a></li>
</ul>
</nav>
<h1>感受生活的美好</h1>
<video controls>
<source src="video3.mp4" type="video/mp4" />
</video>
</body>
</html>
將影片從內容區移到背景層
「我現在想要影片作為背景,然後在導覽列底下,文字在影片上面」
我理解了!我會幫你做以下調整:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>媒體網站</title>
</head>
<body>
<style>
body {
margin: 0;
padding: 0;
overflow-x: hidden;
}
/* 背景影片容器 */
.video-background {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.video-background video {
width: 100%;
height: 100%;
object-fit: cover;
}
/* 內容區域 */
.content {
position: relative;
z-index: 1;
text-align: center;
padding-top: 150px;
min-height: 100vh;
color: white;
}
nav {
background-color: rgba(0, 0, 0, 0.8);
padding: 15px 20px;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
}
.logo {
color: white;
font-size: 24px;
font-weight: bold;
display: inline;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: inline;
}
nav ul li {
display: inline;
margin-left: 20px;
}
nav ul li a {
color: white;
text-decoration: none;
font-size: 18px;
}
nav ul li a:hover {
color: yellow;
}
h1 {
font-size: 42px;
margin-bottom: 20px;
text-shadow: 2px 2px 4px black;
}
h2 {
font-size: 28px;
margin-bottom: 15px;
text-shadow: 2px 2px 4px black;
}
h3 {
font-size: 22px;
text-shadow: 2px 2px 4px black;
}
</style>
<!-- 背景影片 -->
<div class="video-background">
<video autoplay muted loop>
<source src="video3.mp4" type="video/mp4" />
</video>
</div>
<!-- 導覽列 -->
<nav>
<div class="logo">我的網站</div>
<ul>
<li><a href="index.html">首頁</a></li>
<li><a href="media.html">多媒體</a></li>
</ul>
</nav>
<!-- 內容區 -->
<div class="content">
<h1>感受生活的美好</h1>
<h2>用心聆聽世界的聲音</h2>
<h3>讓音樂與影像說故事</h3>
</div>
</body>
</html>
.video-background 容器,使用 position: fixedautoplay muted loop 自動播放z-index 控制圖層順序基於版本1進行優化
「影片可以變亮一點嗎?」
當然可以!我會使用 CSS 的 filter 屬性來調整影片亮度:
filter: brightness(1.3) 讓影片變亮30%<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>媒體網站</title>
</head>
<body>
<style>
body {
margin: 0;
padding: 0;
overflow-x: hidden;
}
/* 背景影片容器 */
.video-background {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.video-background video {
width: 100%;
height: 100%;
object-fit: cover;
filter: brightness(1.3); /* 增加亮度 */
}
/* 內容區域 */
.content {
position: relative;
z-index: 1;
text-align: center;
padding-top: 150px;
min-height: 100vh;
color: white;
}
nav {
background-color: rgba(0, 0, 0, 0.8);
padding: 15px 20px;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
}
.logo {
color: white;
font-size: 24px;
font-weight: bold;
display: inline;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: inline;
}
nav ul li {
display: inline;
margin-left: 20px;
}
nav ul li a {
color: white;
text-decoration: none;
font-size: 18px;
}
nav ul li a:hover {
color: yellow;
}
h1 {
font-size: 42px;
margin-bottom: 20px;
text-shadow: 2px 2px 4px black;
}
h2 {
font-size: 28px;
margin-bottom: 15px;
text-shadow: 2px 2px 4px black;
}
h3 {
font-size: 22px;
text-shadow: 2px 2px 4px black;
}
</style>
<!-- 背景影片 -->
<div class="video-background">
<video autoplay muted loop>
<source src="video3.mp4" type="video/mp4" />
</video>
</div>
<!-- 導覽列 -->
<nav>
<div class="logo">我的網站</div>
<ul>
<li><a href="index.html">首頁</a></li>
<li><a href="media.html">多媒體</a></li>
</ul>
</nav>
<!-- 內容區 -->
<div class="content">
<h1>感受生活的美好</h1>
<h2>用心聆聽世界的聲音</h2>
<h3>讓音樂與影像說故事</h3>
</div>
</body>
</html>
filter: brightness(1.3);基於版本2進行最終優化
「導覽列我要加上一個圓形的我的照片,照片叫樹哥1-1.jpg」
沒問題!我會在導覽列加入圓形頭像:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>媒體網站</title>
</head>
<body>
<style>
body {
margin: 0;
padding: 0;
overflow-x: hidden;
}
/* 背景影片容器 */
.video-background {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
}
.video-background video {
width: 100%;
height: 100%;
object-fit: cover;
filter: brightness(1.3);
}
/* 內容區域 */
.content {
position: relative;
z-index: 1;
text-align: center;
padding-top: 150px;
min-height: 100vh;
color: white;
}
nav {
background-color: rgba(0, 0, 0, 0.8);
padding: 15px 20px;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
display: flex;
align-items: center;
}
/* 圓形頭像 */
.profile-pic {
width: 40px;
height: 40px;
border-radius: 50%;
object-fit: cover;
margin-right: 15px;
border: 2px solid white;
}
.logo {
color: white;
font-size: 24px;
font-weight: bold;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: inline;
margin-left: auto;
}
nav ul li {
display: inline;
margin-left: 20px;
}
nav ul li a {
color: white;
text-decoration: none;
font-size: 18px;
}
nav ul li a:hover {
color: yellow;
}
h1 {
font-size: 42px;
margin-bottom: 20px;
text-shadow: 2px 2px 4px black;
}
h2 {
font-size: 28px;
margin-bottom: 15px;
text-shadow: 2px 2px 4px black;
}
h3 {
font-size: 22px;
text-shadow: 2px 2px 4px black;
}
</style>
<!-- 背景影片 -->
<div class="video-background">
<video autoplay muted loop>
<source src="video3.mp4" type="video/mp4" />
</video>
</div>
<!-- 導覽列 -->
<nav>
<img src="樹哥1-1.jpg" alt="個人照片" class="profile-pic">
<div class="logo">我的網站</div>
<ul>
<li><a href="index.html">首頁</a></li>
<li><a href="media.html">多媒體</a></li>
</ul>
</nav>
<!-- 內容區 -->
<div class="content">
<h1>感受生活的美好</h1>
<h2>用心聆聽世界的聲音</h2>
<h3>讓音樂與影像說故事</h3>
</div>
</body>
</html>
<img> 標籤:src="樹哥1-1.jpg"border-radius: 50%display: flex 以正確對齊元素透過這三階段示範,學生學到:
🎯 關鍵心法:把AI當作你的編程助手,用對話方式說出你想要的效果!