用html和css仿作苹果网站
时间: 2023-06-26 11:10:08 浏览: 112
很好,下面是一个简单的示例:
HTML代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Apple Website Clone</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<nav>
<ul>
<li><a href="#">Mac</a></li>
<li><a href="#">iPad</a></li>
<li><a href="#">iPhone</a></li>
<li><a href="#">Watch</a></li>
<li><a href="#">TV</a></li>
<li><a href="#">Music</a></li>
<li><a href="#">Support</a></li>
<li><a href="#">Search</a></li>
<li><a href="#">Bag</a></li>
</ul>
</nav>
</header>
<div class="hero">
<h1>Welcome to Apple</h1>
<p>Discover the innovative world of Apple and shop everything iPhone, iPad, Apple Watch, Mac, and Apple TV, plus explore accessories, entertainment, and expert device support.</p>
<button>Learn More</button>
</div>
<div class="products">
<h2>Popular Products</h2>
<ul>
<li>
<img src="https://www.apple.com/v/home/ep/images/heroes/iphone-12-pro/hero__dvsbeydztgqy_small_2x.jpg" alt="iPhone 12 Pro">
<h3>iPhone 12 Pro</h3>
<p>From $999</p>
</li>
<li>
<img src="https://www.apple.com/v/home/ep/images/heroes/ipad-pro/hero__dvsbeydztgqy_small_2x.jpg" alt="iPad Pro">
<h3>iPad Pro</h3>
<p>From $799</p>
</li>
<li>
<img src="https://www.apple.com/v/home/ep/images/heroes/macbook-air/hero__dvsbeydztgqy_small_2x.jpg" alt="MacBook Air">
<h3>MacBook Air</h3>
<p>From $999</p>
</li>
</ul>
</div>
<div class="footer">
<p>© 2021 Apple Inc. All rights reserved.</p>
</div>
</body>
</html>
```
CSS代码:
```css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
header {
background-color: #000;
color: #fff;
padding: 10px;
display: flex;
justify-content: space-between;
align-items: center;
position: fixed;
top: 0;
left: 0;
right: 0;
}
nav ul {
display: flex;
list-style: none;
}
nav ul li a {
color: #fff;
text-decoration: none;
padding: 10px;
}
.hero {
background-image: url(https://www.apple.com/v/home/ep/images/heroes/iphone-12-pro/hero__dvsbeydztgqy_small_2x.jpg);
height: 500px;
background-size: cover;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.hero h1 {
font-size: 60px;
text-shadow: 2px 2px #000;
}
.hero p {
font-size: 20px;
margin-bottom: 20px;
}
.hero button {
padding: 10px 20px;
background-color: #fff;
color: #000;
border: none;
font-size: 18px;
border-radius: 30px;
}
.products {
margin-top: 100px;
text-align: center;
}
.products h2 {
font-size: 40px;
margin-bottom: 50px;
}
.products ul {
display: flex;
justify-content: center;
list-style: none;
}
.products li {
margin: 0 50px;
}
.products img {
width: 300px;
height: 200px;
margin-bottom: 20px;
}
.products h3 {
font-size: 30px;
margin-bottom: 10px;
}
.products p {
font-size: 20px;
}
.footer {
background-color: #000;
color: #fff;
padding: 10px;
text-align: center;
position: fixed;
bottom: 0;
left: 0;
right: 0;
}
```
你可以在浏览器中打开HTML文件查看效果。这只是一个简单的示例,你可以根据需要进行修改和添加更多内容。
阅读全文