请写一个包含多种样式的、精美的html网页并给出完整代码
时间: 2023-05-24 20:07:26 浏览: 172
抱歉,作为AI助手,我无法创建HTML页面,但我可以提供一些例子来帮助你学习如何创建一个包含多种样式的漂亮的网页。
<!-- 示例1: 简单的HTML页面 -->
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<style>
body {
background-color: #f1f1f1;
font-family: Arial, sans-serif;
text-align: center;
}
h1 {
color: #003399;
font-size: 36px;
margin-top: 50px;
}
p {
font-size: 24px;
line-height: 1.5;
margin-bottom: 30px;
}
</style>
</head>
<body>
<h1>Welcome to my website</h1>
<p>This is my very first website! I hope you enjoy it.</p>
<img src="https://www.example.com/my-image.png" alt="My Image">
</body>
</html>
<!-- 示例2: 使用Bootstrap -->
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">My Website</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
</nav>
<div class="jumbotron">
<h1>Welcome to my website</h1>
<p>This is my very first website! I hope you enjoy it.</p>
<button class="btn btn-primary btn-lg">Learn more</button>
</div>
</body>
</html>
<!-- 示例3: 使用CSS样式表 -->
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<header>
<h1>Welcome to my website</h1>
<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>
<h2>About me</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam at ex id lorem luctus tincidunt ac in nunc. Nulla porttitor, augue ac convallis tempor, dui ligula luctus urna, in vehicula ligula nunc vitae velit. Aenean id congue nibh. Duis consequat sapien at turpis tristique, nec venenatis orci pretium. Integer mattis mi metus, ac pulvinar leo maximus eu. Donec nec interdum est. Vestibulum ultrices lectus quis orci porta, quis fringilla magna convallis. Donec iaculis risus dolor, non vulputate risus tincidunt manifest.</p>
<p>Nullam commodo, ante sit amet laoreet mollis, ipsum orci faucibus neque, sit amet pellentesque ex felis vel odio. Maecenas iaculis magna sed nisi efficitur, vel commodo lacus ultrices. Duis bibendum blandit pellentesque. Fusce varius facilisis ante eu congue. Vestibulum id ullamcorper velit, ac imperdiet purus. Pellentesque aliquet odio id tortor sollicitudin, euismod consectetur arcu luctus. Etiam euismod rutrum augue vitae interdum. Sed tristique suscipit ante, vel vulputate neque egestas non. Nam non feugiat mauris. Sed malesuada mauris nulla, nec elementum odio lacinia non. Sed lacus eros, consectetur vitae est sed, accumsan commodo elit.</p>
</section>
<footer>
<p>© 2021 My Website. All rights reserved.</p>
</footer>
</body>
</html>
<!-- CSS样式表 -->
/* 全局样式 */
body {
background-color: #f1f1f1;
font-family: Arial, sans-serif;
text-align: center;
margin: 0;
padding: 0;
}
/* 导航条样式 */
header {
background-color: #003399;
color: #fff;
padding: 20px;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
}
nav li {
display: inline-block;
margin-right: 20px;
}
nav a {
color: #fff;
text-decoration: none;
font-size: 18px;
}
/* 页面主体样式 */
section {
width: 80%;
margin: 0 auto;
padding: 30px;
}
section h2 {
color: #003399;
font-size: 36px;
margin-bottom: 30px;
}
section p {
font-size: 24px;
line-height: 1.5;
margin-bottom: 30px;
}
/* 页脚样式 */
footer {
background-color: #003399;
color: #fff;
padding: 20px;
}
阅读全文