about区域中间部分布局问题
index.html代码如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>2-9页面布局作业</title> <link rel="stylesheet" type="text/css" href="cssFile/headerCss.css"> <link rel="stylesheet" type="text/css" href="cssFile/bannerCss.css"> <link rel="stylesheet" type="text/css" href="cssFile/aboutCss.css"> <link rel="stylesheet" type="text/css" href="cssFile/galleryCss.css"> <link rel="stylesheet" type="text/css" href="cssFile/footerCss.css"> </head> <body> <!--顶部部分--> <div class="header"> <div class="logo"> <img src="images/logo.png"> </div> <div class="nav"> <ul> <li>HOME</li> <li>ABOUT</li> <li>GALLERY</li> <li>FACULTY</li> <li>EVENTS</li> <li>CONTACT</li> </ul> </div> </div> <!--banner部分--> <div class="banner"> <div class="bannerImg"> <img src="images/banner3.jpg"> </div> <div class="ImgLayer"></div> <div class="sendMassage"> <input type="text" name="userName" placeholder=" your Name"> <input type="text" name="userPhone" placeholder=" your Phone"> <input type="text" name="userEmail" placeholder=" your Email"> <input type="text" name="userComment" style=""> <button>SEND MASSAGE</button> </div> </div> <!--ABOUT部分--> <div class="about"> <!--ABOUT顶部--> <div class="about_top"> <label class="title">ABOUT</label> <label class="line"></label> <label class="description">Lorem Ipsum is simply dummy text of the printing and ypesetting industry.Lorem Ipsum has been the industry's standard dummy text ever since the 1500s.</label> </div> <!--ABOUT中间部分--> <div class="about_middle"> <!--左侧部分--> <div class="left"> <div class="word1"> <label>A WORD<br>ABOUT US</label> </div> <div class="word2"> <label>Praesent dignissim viverra est,sed bibendum ligula congue non.Sed ac nislet felis gravida commodo?Suspendisse eget ullamcorper ipsum.Suspendisse diam amet. </label> <div> <button>EXPLORE</button> </div> </div> </div> <!--中间部分--> <div class="center"> <img src="images/bb3.jpg"> </div> <!--右侧部分--> <div class="right"> </div> </div> <div style="clear: both;"></div> <!--ABOUT底部--> <div class="about_bottom"></div> </div> </body> </html>
headerCss.css代码如下:
*{
margin: 0px;
padding: 0px;
}
.header{
width: 100%;
height: 100px;
background-color: #07cbc9;
}
.header .logo{
float: left;
padding-left: 100px;
padding-top: 25px;
}
.header .nav{
float: right;
padding-right: 100px;
}
.header .logo img{
height: 50px;
}
.header .nav ul li{
float: left;
list-style: none;
width: 80px;
color: #ffffff;
font-weight: bold;
line-height: 100px;
}bannerCss.css代码如下:
.banner{
width: 100%;
position: absolute;
top: 100px;
}
.bannerImg{
width: 100%;
position: absolute;
top: 0px;
}
.bannerImg img{
width: 100%;
height: 600px;
}
.banner .ImgLayer{
width: 100%;
height: 600px;
top: 100px;
left: 0px;
background-color: #000;
opacity: 0.4;
}
.banner .sendMassage{
width: 500px;
height: 400px;
/*background-color: cyan;*/
position: absolute;
top: 70px;
right: 50%;
margin-right: -250px;
}
.banner .sendMassage input[type="text"]{
width: 496px;
height: 50px;
margin-top: 30px;
font-size: 20px;
color: #FFFFFF;
line-height: 50px;
border: 2px solid #7D7C7F;
background-color: transparent;
}
.banner .sendMassage input[type="text"]:hover{
border: 2px solid #07cbc9;
background-color: transparent;
}
.banner .sendMassage button{
width: 200px;
height: 50px;
color: #FFFFFF;
line-height: 50;
margin-top: 30px;
margin-left: 150px;
font-size: 20px;
color: #7D7C7F;
line-height: 50px;
border: 2px solid #7D7C7F;
background-color: transparent;
}
.banner .sendMassage button:hover{
border: 2px solid #07cbc9;
background-color: transparent;
}aboutCss.css代码如下:
.about{
position: absolute;
top:705px;
width: 100%;
/*height: 800px;*/
/*background-color: cyan;*/
}
.about .about_top{
padding-top: 20px;
margin: 0 auto;
width: 500px;
height: 100px;
background-color: #FFFFFF;
text-align: center;
}
.about .about_top .title{
font-family: "微软雅黑"
font-size: 25px;
font-weight: bold;
}
.about .about_top .line{
background-color: #07CBC9;
display: block;
width: 15px;
height: 2px;
margin: 3px auto;
}
.about .about_top .description{
font-family: "微软雅黑";
font-size: 15px;
color: #7D7F7C;
}
.about .about_middle{
margin: 0 auto;
padding-top: 20px;
width: 1000px;
/*height: 250px;*/
background-color: cyan;
}
.about .about_middle .left{
/*position: absolute;*/
/*position: relative;*/
top: 0px;
left: 0px;
width: 250px;
z-index: 20;
}
.about .about_middle .left .word1{
font-family: "微软雅黑";
font-size: 30px;
}
.about .about_middle .left .word2{
padding: 20px;
background-color: rgba(255,255,255,0.2);
font-family: "微软雅黑"
font-size: 15px;
border: 1px solid #7D7F7C;
}
.about .about_middle .left .word2 button{
margin-top: 10px;
padding: 15px;
background-color: #000;
font-size: 20px;
color: #FFF;
border: 0px;
}
.about .about_middle .center{
/*position: absolute;*/
/*position: relative;*/
top: 0px;
left: 190px;
z-index: 10;
}
.about .about_middle .center img{
width: 600px;
height: 400px;
}
.about .about_middle .right{
/*position: absolute;*/
/*position: relative;*/
top: 0px;
right: 0px;
width: 120px;
height: 100px;
background-color: #000
}当我对 about区域中间部分的 左、中、右三部分都设置绝对定位后三部分是相对与整个about部分的DIV进行分布的。
当不设置定位方式时,三部分就就会在about区域中间部分的DIV进行文档流布局。
是什么原因造成的?
3
收起
正在回答 回答被采纳积分+1
2回答
懒人13
2019-05-27 14:53:01
其它代码均未修改,仅aboutCss.css代码修改如下:
.about{
position: absolute;
top:705px;
width: 100%;
/*height: 800px;*/
/*background-color: cyan;*/
}
.about .about_top{
padding-top: 20px;
margin: 0 auto;
width: 500px;
height: 100px;
background-color: #FFFFFF;
text-align: center;
}
.about .about_top .title{
font-family: "微软雅黑"
font-size: 25px;
font-weight: bold;
}
.about .about_top .line{
background-color: #07CBC9;
display: block;
width: 15px;
height: 2px;
margin: 3px auto;
}
.about .about_top .description{
font-family: "微软雅黑";
font-size: 15px;
color: #7D7F7C;
}
.about .about_middle{
position: relative;
margin: 0 auto;
padding-top: 20px;
width: 1000px;
/*height: 250px;*/
background-color: cyan;
}
.about .about_middle .left{
position: absolute;
/* position: relative;*/
top: 0px;
left: 0px;
width: 250px;
z-index: 20;
}
.about .about_middle .left .word1{
font-family: "微软雅黑";
font-size: 30px;
}
.about .about_middle .left .word2{
padding: 20px;
background-color: rgba(255,255,255,0.2);
font-family: "微软雅黑"
font-size: 15px;
border: 1px solid #7D7F7C;
}
.about .about_middle .left .word2 button{
margin-top: 10px;
padding: 15px;
background-color: #000;
font-size: 20px;
color: #FFF;
border: 0px;
}
.about .about_middle .center{
position: absolute;
/*position: relative;*/
top: 0px;
left: 190px;
z-index: 10;
}
.about .about_middle .center img{
width: 600px;
height: 400px;
}
.about .about_middle .right{
position: absolute;
/*position: relative;*/
top: 0px;
right: 0px;
width: 120px;
height: 100px;
background-color: #000
}
从网页搭建入门Java Web2018版
- 参与学习 人
- 提交作业 1088 份
- 解答问题 10204 个
如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星