用html做一个网页代码,头部背景为红色,两侧插入两张悬浮照片,下面设置窄一点的导航菜单,设置12个可点击变色的超链接标签在此菜单最左侧设置两个搜索和用户登录按钮。主体部位背景为一个照片,居中插入两张照片,最上部照片上设置八个并列的标签输入汉字,。底部设置较多的可点击链接。
时间: 2024-04-22 10:21:51 浏览: 152
以下是这个网页的代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>我的网页</title>
<style type="text/css">
body {
margin: 0;
padding: 0;
}
header {
background-color: red;
height: 200px;
position: relative;
}
#left-image, #right-image {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 100px;
height: 100px;
background-image: url(left-image.jpg);
background-size: cover;
background-position: center;
z-index: 1;
}
#left-image {
left: 0;
}
#right-image {
right: 0;
background-image: url(right-image.jpg);
}
nav {
background-color: #eee;
height: 50px;
display: flex;
align-items: center;
padding: 0 20px;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
nav a {
display: block;
padding: 10px;
color: black;
text-decoration: none;
border-right: 1px solid #ccc;
transition: background-color 0.3s;
}
nav a:hover {
background-color: #ccc;
}
nav a.active {
background-color: #ccc;
font-weight: bold;
}
#search, #login {
margin-left: auto;
background-color: #ccc;
padding: 5px 10px;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
}
main {
background-image: url(main-image.jpg);
background-size: cover;
background-position: center;
height: 600px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#center-image {
width: 200px;
height: 200px;
background-image: url(center-image.jpg);
background-size: cover;
background-position: center;
margin: 20px;
}
#labels {
display: flex;
justify-content: center;
align-items: center;
}
#labels span {
display: block;
margin: 10px;
font-size: 20px;
font-weight: bold;
color: white;
background-color: rgba(0, 0, 0, 0.5);
padding: 10px;
border-radius: 5px;
}
footer {
background-color: #ddd;
padding: 20px;
text-align: center;
}
footer a {
color: black;
text-decoration: none;
margin: 10px;
font-weight: bold;
}
</style>
</head>
<body>
<header>
<div id="left-image"></div>
<div id="right-image"></div>
</header>
<nav>
<ul>
<li><a href="#" class="active">首页</a></li>
<li><a href="#">新闻</a></li>
<li><a href="#">体育</a></li>
<li><a href="#">科技</a></li>
<li><a href="#">财经</a></li>
<li><a href="#">娱乐</a></li>
<li><a href="#">军事</a></li>
<li><a href="#">汽车</a></li>
<li><a href="#">房产</a></li>
<li><a href="#">游戏</a></li>
<li><a href="#">旅游</a></li>
<li><a href="#">教育</a></li>
<li><button id="search">搜索</button></li>
<li><button id="login">登录</button></li>
</ul>
</nav>
<main>
<div id="center-image"></div>
<div id="labels">
<span>标签1</span>
<span>标签2</span>
<span>标签3</span>
<span>标签4</span>
<span>标签5</span>
<span>标签6</span>
<span>标签7</span>
<span>标签8</span>
</div>
</main>
<footer>
<a href="#">链接1</a>
<a href="#">链接2</a>
<a href="#">链接3</a>
<a href="#">链接4</a>
<a href="#">链接5</a>
<a href="#">链接6</a>
<a href="#">链接7</a>
<a href="#">链接8</a>
<a href="#">链接9</a>
<a href="#">链接10</a>
</footer>
</body>
</html>
```
注意:为了方便,我使用了一些占位图片和占位文字,需要根据实际情况进行替换。另外,这个网页只是一个示例,实际情况中可能会根据需求进行调整。
阅读全文