响应式官网 HTML+CSS+JS 示例 - 简单易懂
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Responsive Website</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Services</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<section class="hero">
<div class="hero-content">
<h1>Welcome to our website</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<a href="#" class="cta-btn">Get Started</a>
</div>
</section>
<section class="features">
<div class="feature">
<h2>Feature 1</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div class="feature">
<h2>Feature 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
<div class="feature">
<h2>Feature 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</section>
<footer>
<p>© 2021 Your Company. All rights reserved.</p>
</footer>
<script src="script.js"></script>
</body>
</html>
/* Reset some default styles */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
<p>/* Global styles */
body {
font-family: Arial, sans-serif;
}</p>
<p>/* Header styles */
header {
background-color: #333;
color: #fff;
padding: 10px;
}</p>
<p>nav ul {
list-style: none;
display: flex;
justify-content: space-between;
}</p>
<p>nav ul li {
margin-right: 20px;
}</p>
<p>nav ul li a {
color: #fff;
text-decoration: none;
}</p>
<p>/* Hero section styles */
.hero {
background-image: url("hero-image.jpg");
background-size: cover;
background-position: center;
height: 400px;
display: flex;
align-items: center;
justify-content: center;
}</p>
<p>.hero-content {
text-align: center;
color: #fff;
}</p>
<p>.hero-content h1 {
font-size: 32px;
margin-bottom: 20px;
}</p>
<p>.hero-content p {
font-size: 18px;
margin-bottom: 30px;
}</p>
<p>.cta-btn {
padding: 10px 20px;
background-color: #333;
color: #fff;
text-decoration: none;
}</p>
<p>/* Features section styles */
.features {
display: flex;
justify-content: center;
padding: 50px 0;
}</p>
<p>.feature {
text-align: center;
margin: 0 20px;
}</p>
<p>.feature h2 {
font-size: 24px;
margin-bottom: 10px;
}</p>
<p>.feature p {
font-size: 16px;
}</p>
<p>/* Footer styles */
footer {
background-color: #333;
color: #fff;
padding: 10px;
text-align: center;
}</p>
原文地址: https://www.cveoy.top/t/topic/p931 著作权归作者所有。请勿转载和采集!