怎样设置页眉区能在设置固定定位且width100%的情况下
document.html
<!DOCTYPE html>
<meta charset="gbk"/>
<html>
<head>
<title>Career Builder</title>
<link rel="stylesheet" type="text/css" href="document.css">
<script type="text/javascript" src="document.js"></script>
</head>
<body>
<div class="header">
<a href="#"><img src="image/logo.png" class="img-header"></a>
<ul>
<li>
<a href="#"><p>CONTACT</p></a>
</li>
<li>
<a href="#"><p>EVENTS</p></a>
</li>
<li>
<a href="#"><p>FACULTY</p></a>
</li>
<li>
<a href="#"><p>GALLERY</p></a>
</li>
<li>
<a href="#"><p>ABOUT</p></a>
</li>
<li>
<a href="#"><p>HOME</p></a>
</li>
</ul>
</div>
<div class="banner">
<form action="" method="post">
<img src="image/banner3.jpg">
<div class="input1-form">
<input type="text" name="" value="your Name" style="width: 450px; height: 35px;">
</div>
<div class="input2-form">
<input type="text" name="" value="your Phone" style="width: 450px; height: 35px;">
</div>
<div class="input3-form">
<input type="text" name="" value="your Email" style="width: 450px; height: 35px;">
</div>
<div class="input4-form">
<textarea rows="" cols="" value="" style="width: 448px;height: 130px">Write Your Comment Here</textarea>
</div>
<div class="input5-form">
<input type="submit" name="" value="SEND MESSAGE" style="width: 125px; height: 40px;">
</div>
</form>
</div>
<div class="about">
<div>
<title></title>
<p></p>
</div>
<div></div>
<div></div>
</div>
<div class="gallery"></div>
<div class="footer"></div>
</body>
</html>
document.css
body{
width: 1700px;
margin:0 0;
font-family: Microsoft YaHei UI;
}
/*设置顶部*/
.header{
width: 100%;
height: 100px;
background-color: #07cbc9;
position: fixed;
top: -16px;
right: 0;
z-index: 800;
}
.header .img-header{
margin-top:20px;
margin-left: 80px;
float: left;
}
.header ul{
width: 1400px;
margin-right: 120px;
}
.header ul li{
list-style: none;
float: right;
height: 100px;
margin-top: -16px;
}
.header ul li a p{
/*设置段落格式*/
width: 78px;
height: 100px;
line-height: 100px;
color: white;
margin-top: 0px;
text-align: center;
}
.header ul li a{
/*去下划线*/
text-decoration: none;
}
.header ul li a p:hover{
background-color: black;
}
/*设置banner区*/
.banner{
width: 100%;
background-color: black;
position: absolute;
z-index: 200;
}
/*设置背景图片和透明度*/
.banner form{
// background: url(image/banner3.jpg) no-repeat;
// background-size: cover;
width: 100%;
height: 800px;
// opacity: 0.4;
}
.banner form img{
position: absolute;
z-index: 300;
}
.banner form .input1-form{
position: absolute;
z-index: 400;
top: 212.5px;
left: 624px;
}
.banner form .input2-form{
position: absolute;
z-index: 400;
top: 272.5px;
left: 624px;
}
.banner form .input3-form{
position: absolute;
top: 332.5px;
left: 624px;
z-index: 400;
}
.banner form .input4-form{
position: absolute;
top: 392.5px;
left: 624px;
z-index: 400;
}
.banner form .input5-form{
position: absolute;
top: 547.5px;
left: 624px;
z-index: 400;
}
input[value]{
color: rgba(255, 255, 255, 0.5);
border: 1px solid rgba(255, 255, 255, 0.5);
background-color: rgba(255, 255, 255, 0)
}
textarea{
color: rgba(255, 255, 255, 0.5);
border: 1px solid rgba(255, 255, 255, 0.5);
background-color: rgba(255, 255, 255, 0)
}
/*设置悬停在表单时的样式*/
textarea:hover{
border-color: #07cbc9;
}
.banner form .div5-form input[value]:hover{
background-color: #07cbc9;
border: none;
}
input[value]:hover{
border-color: #07cbc9;
}
怎样设置页眉区能在设置固定定位且width100%的情况下显示与banner区的img同宽1700px?怎么推导得到解决方法的?
正在回答
同学你好,请问是想实现鼠标经过相应导航时,背景颜色变为黑色。如果是,那么已经实现了但对代码进行修改,代码如下:
/*设置段落格式*/
.header ul li a p{
float: right;
font-size: 15px;
line-height: 100px;
font-weight: bold;
text-align: center;
}
.header ul li a{
color: #FFFEFE;
display: block;
padding: 0 10px;
}如果是想将顶部固定到上边栏,那么已经实现,可尝试将分辨率调高测试或完成其他模块测试。祝学习愉快!
同学你好,请问同学是想将banner区设置为宽度为1700px;吗?如果是修改css,代码如下:
/*修改body与header中的样式*/
body{
margin: 0px;
padding: 0px;
font-family: Microsoft YaHei UI;
}
/*设置顶部*/
.header{
width: 100%;
height: 100px;
background-color: #07cbc9;
position: fixed;
top: 0px;
z-index: 800;
}
.header .img-header{
margin-top:20px;
margin-left: 80px;
float: left;
}
.header ul{
width: 1400px;
margin-right: 120px;
}
.header ul li{
list-style: none;
float: right;
height: 100px;
margin-top: -16px;
}
.header ul li a p{
/*设置段落格式*/
width: 78px;
height: 100px;
line-height: 100px;
color: white;
margin-top: 0px;
text-align: center;
}
.header ul li a{
/*去下划线*/
text-decoration: none;
}
.header ul li a p:hover{
background-color: black;
}
/*设置banner区 修改宽度*/
.banner{
width: 1700px;
margin: 0 auto;
background-color: black;
}
/* 修改top距离 */
.img-banner{
width: 100%;
height: 800px;
position: relative;
top: 80px;
}
/* 修改遮罩层的宽度 */
.topLayer{
background-color: #000;
opacity: 0.4;
z-index: 1;
position: absolute;
top: 80px;
width: 1700px;
height: 800px;
}
.banner form .input1-form{
position: absolute;
z-index: 400;
top: 212.5px;
left: 624px;
}
.banner form .input2-form{
position: absolute;
z-index: 400;
top: 272.5px;
left: 624px;
}
.banner form .input3-form{
position: absolute;
top: 332.5px;
left: 624px;
z-index: 400;
}
.banner form .input4-form{
position: absolute;
top: 392.5px;
left: 624px;
z-index: 400;
}
.banner form .input5-form{
position: absolute;
top: 547.5px;
left: 624px;
z-index: 400;
}
input[value]{
color: rgba(255, 255, 255, 0.5);
border: 1px solid rgba(255, 255, 255, 0.5);
background-color: rgba(255, 255, 255, 0)
}
textarea{
color: rgba(255, 255, 255, 0.5);
border: 1px solid rgba(255, 255, 255, 0.5);
background-color: rgba(255, 255, 255, 0)
}
/*设置悬停在表单时的样式*/
textarea:hover{
border-color: #07cbc9;
}
.banner form .div5-form input[value]:hover{
background-color: #07cbc9;
border: none;
}
input[value]:hover{
border-color: #07cbc9;
}祝学习愉快!
<!DOCTYPE html>
<meta charset="gbk"/>
<html>
<head>
<title>Career Builder</title>
<link rel="stylesheet" type="text/css" href="document.css">
<script type="text/javascript" src="document.js"></script>
</head>
<body>
<div class="header">
<a href="#"><img src="image/logo.png" class="img-header"></a>
<ul>
<li>
<a href="#"><p>CONTACT</p></a>
</li>
<li>
<a href="#"><p>EVENTS</p></a>
</li>
<li>
<a href="#"><p>FACULTY</p></a>
</li>
<li>
<a href="#"><p>GALLERY</p></a>
</li>
<li>
<a href="#"><p>ABOUT</p></a>
</li>
<li>
<a href="#"><p>HOME</p></a>
</li>
</ul>
</div>
<div class="banner">
<form action="#" method="post">
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
</html>
<!--图片-->
<div class="pic">
<img class="img-banner" src="image/banner3.jpg">
</div>
<!--遮罩层-->
<div class="topLayer">
<div class="input1-form">
<input type="text" name="" value="your Name" style="width: 450px; height: 35px;">
</div>
<div class="input2-form">
<input type="text" name="" value="your Phone" style="width: 450px; height: 35px;">
</div>
<div class="input3-form">
<input type="text" name="" value="your Email" style="width: 450px; height: 35px;">
</div>
<div class="input4-form">
<textarea rows="" cols="" value="" style="width: 448px;height: 130px">Write Your Comment Here</textarea>
</div>
<div class="input5-form">
<input type="submit" name="" value="SEND MESSAGE" style="width: 125px; height: 40px;">
</div>
</form>
</div>
<div class="about">
<div>
<title></title>
<p></p>
</div>
<div></div>
<div></div>
</div>
<div class="gallery"></div>
<div class="footer"></div>
</body>
</html>
/*修改body与header中的样式*/
body{
/*width: 1700px;
margin:0 0;*/
margin: 0px;
padding: 0px;
font-family: Microsoft YaHei UI;
}
/*设置顶部*/
.header{
width: 100%;
height: 100px;
background-color: #07cbc9;
position: fixed;
top: 0px;
// right: 0;
z-index: 800;
}
.header .img-header{
margin-top:20px;
margin-left: 80px;
float: left;
}
.header ul{
width: 1400px;
margin-right: 120px;
}
.header ul li{
list-style: none;
float: right;
height: 100px;
margin-top: -16px;
}
.header ul li a p{
/*设置段落格式*/
width: 78px;
height: 100px;
line-height: 100px;
color: white;
margin-top: 0px;
text-align: center;
}
.header ul li a{
/*去下划线*/
text-decoration: none;
}
.header ul li a p:hover{
background-color: black;
}
/*设置banner区*/
.banner{
width: 100%;
background-color: black;
position: absolute;
z-index: 200;
}
/*设置背景图片和透明度*/
// .banner form{
// // background: url(image/banner3.jpg) no-repeat;
// // background-size: cover;
// width: 100%;
// height: 800px;
// // opacity: 0.4;
// }
.img-banner{
width: 100%;
height: 800px;
position: relative;
// z-index: 300;
top: 0px;
}
.topLayer{
background-color: #000;
opacity: 0.4;
z-index: 1;
position: absolute;
top: 80px;
width: 100%;
height: 800px;
}
.banner form .input1-form{
position: absolute;
z-index: 400;
top: 212.5px;
left: 624px;
}
.banner form .input2-form{
position: absolute;
z-index: 400;
top: 272.5px;
left: 624px;
}
.banner form .input3-form{
position: absolute;
top: 332.5px;
left: 624px;
z-index: 400;
}
.banner form .input4-form{
position: absolute;
top: 392.5px;
left: 624px;
z-index: 400;
}
.banner form .input5-form{
position: absolute;
top: 547.5px;
left: 624px;
z-index: 400;
}
input[value]{
color: rgba(255, 255, 255, 0.5);
border: 1px solid rgba(255, 255, 255, 0.5);
background-color: rgba(255, 255, 255, 0)
}
textarea{
color: rgba(255, 255, 255, 0.5);
border: 1px solid rgba(255, 255, 255, 0.5);
background-color: rgba(255, 255, 255, 0)
}
/*设置悬停在表单时的样式*/
textarea:hover{
border-color: #07cbc9;
}
.banner form .div5-form input[value]:hover{
background-color: #07cbc9;
border: none;
}
input[value]:hover{
border-color: #07cbc9;
}
同学你好,在现基础的布局中,进行调试。代码如下:
<!-- 在<div class="banner">下 <form action=""> 上添加代码--> <!-- 图片 --> <div class="pic"> <img class="img-banner" style="" src="image/banner3.jpg"> </div> <!-- 遮罩层 --> <div class="topLayer"> </div>
/* 修改 boby 与 header中的样式*/
body{
/*width: 1700px;
margin:0 0;*/
margin: 0px;
padding: 0px;
font-family: Microsoft YaHei UI;
}
.header{
width: 100%;
height: 100px;
background-color: #07cbc9;
position: fixed;
top: 0px;
/*right: 0;*/
z-index: 800;
}
/* 添加下面的代码,删除.banner form img 与.banner form */
.img-banner{
width: 100%;
height: 800px;
position: relative;
top:0px;
}
.topLayer{
background-color: #000;
opacity: 0.4;
z-index: 1;
position: absolute;
top: 80px;
width: 100%;
height: 800px;
}祝学习愉快!
- 参与学习 人
- 提交作业 626 份
- 解答问题 4928 个
想要学好Web后端开发的中流砥柱语言,本阶段为你轻松铺就扎实的基础,从前端网页布局的搭建到后台PHP开发,助你从零基础到掌握主流开发语言。
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星