老师我右边的距离是怎么回事,不对称
来源:2-3 html5页面布局(表现层_banner)
无根鸟飞呀飞
2019-06-25 13:23:46
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>慕课网</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <header> <div class="logo"> <img src="images/logo.png" alt="logo"> </div> <nav> <a href="#" class="active">Home</a> <a href="#">Course</a> <a href="#">Actual</a> <a href="#">Plan</a> <a href="#">FAQ</a> <a href="#">Notes</a> </nav> </header> <section class="banner"> <div> <img src="images/banner/banner1.jpg" alt="" class="centerbnr"> <img src="images/banner/banner3.jpg" alt="" class="leftbnr"> <img src="images/banner/banner2.jpg" alt="" class="rightbnr"> </div> </section> <section class="main"> <aside> <h1>Recent <span>Course</span></h1> <dl> <dt>Hyper Text Markup Language</dt> <dd><img src="images/Course/05_05.png"></dd> <dd>HTML is the standard markup language used to create web pages and its elements form the building blocks of all websites.</dd> </dl> <dl> <dt>Cascading Style Sheets</dt> <dd><img src="images/Course/06_04.png"></dd> <dd>Cascading Style Sheets (CSS) is a simple mechanism for adding style (e.g., fonts, colors, spacing) to Web documents.</dd> </dl> <dl> <dt>JavaScript</dt> <dd><img src="images/Course/09_07.png"></dd> <dd>JavaScript is a high-level, dynamic, untyped, and interpreted programming language.</dd> </dl> <dl> <dt>AngularJS</dt> <dd><img src="images/Course/02_09.png"></dd> <dd>AngularJS is an open-source web application framework mainly maintained by Google and by a community of individuals and...</dd> </dl> </aside> <article> <h1>Welcome to Massive Open Online <span>Course</span>!</h1> <p>We provide the latest knowledge to help you cope with the changing world! </p> <img src="images/article.jpg"> <p>We hope that all the students who love the Internet can be more convenient access to learning resources, using the Internet thinking to change our learning. </p> <p>Focus on IT skills education MOOC, consistent with the development trend of the Internet down to earth's MOOC. We are free, we only teach useful, we concentrate on education.</p> </article> </section> <footer> <p>Copyright © 2016 imooc.com All Rights Reserved.</p> <ul> <li><img src="images/icon/weichat.png"/></li> <li><img src="images/icon/sina.png"/></li> <li><img src="images/icon/qq.png"/></li> </ul> </footer> </body> </html>
*{
margin: 0px;
padding:0px;
}
a{text-decoration: none;}
ul,li{list-style-type: none;}
/*header*/
header{
width: 100%;
background: #000;
height: 73px;
line-height: 73px;
position: relative;
}
header:after{
position: absolute;
top: 73px;
left: 0px;
background: #d6d6d6;
width: 100%;
height: 7px;
content: '';
}
.logo{
float: left;
margin-left: 50px;
position: relative;
z-index: 1;
}
.logo > img{
vertical-align: middle;
}
nav{
height: 73px;
float: right;
margin-right: 30px;
position: relative;
z-index: 1;
}
nav a{
color: #fff;
font-size: 20px;
display: block;
float: left;
width: 110px;
text-align: center;
}
nav a:nth-child(1){background: #433b90;}
nav a:nth-child(2){background: #017fcb;}
nav a:nth-child(3){background: #78b917;}
nav a:nth-child(4){background: #feb800;}
nav a:nth-child(5){background: #f27c01;}
nav a:nth-child(6){background: #d40112;}
nav>a:hover,a.active{padding-bottom: 7px;}
/*banner*/
.banner{background: #eaeaea;font-size: 0;width: 1349px;margin-top: 7px;}
.banner div{
width: 1200px;
margin: 0 auto;
height: 510px;
background: red;
position: relative;
overflow: hidden;
background: #eaeaea;
}
.banner img{display: block;}
.centerbnr{
width: 800px;
height: 500px;
margin: 0 auto;
z-index: 2;
position: absolute;
left: 0;
right: 0;
margin: auto;
}
img.leftbnr{position: absolute;
left: -10%;
}
img.rightbnr{position: absolute;
right: -20%;
}
.leftbnr{
width: 700px;
height: 300px;
z-index: 1;
position: absolute;
left: 0px;
top: 100px;
}
.rightbnr{
width: 700px;
height: 300px;
z-index: 1;
position: absolute;
right: 0px;
top: 100px;
}
/*main*/
aside{
width: 40%;
float: left;
/*margin-left: 20px;*/
}
article{
width: 60%;
float: right;
}
/*footer*/
footer{
width: 100%;
height: 60px;
overflow: hidden;
zoom:1;
background: #000;
line-height: 60px;
color: #fff;
}
footer p{
float: left;
margin-left: 50px;
}
footer ul{
float: right;
margin-right: 30px;
height: 60px;
line-height: 60px;
}
footer li{
float: left;
}
footer img{
vertical-align: middle;
}
1回答
同学你好,同学说的距离是这里吗?

老师这边测试的是对称的。

出现的原因可能是分辨率不同导致的,建议同学把类名为banner的元素的宽度设置为100%再测试一下
如果帮助到了你,欢迎采纳~祝学习愉快~~
相似问题