老师,我按视频中的代码显示的效果和视频中不一样,右边会凸出来一部分且有水平滚动条?

老师,我按视频中的代码显示的效果和视频中不一样,右边会凸出来一部分且有水平滚动条?

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>imooc</title>

<link rel="stylesheet" type="text/css" href="css/style.css" />

</head>

<body>

<header>

<div class="container">

<a href="index.html"><img src="images/logo.png"/></a>

<nav>

<a href="index.html" class="Home active">Home</a>

<a href="#" class="Course">Course</a>

<a href="#" class="Actual">Actual</a>

<a href="#" class="Plan">Plan</a>

<a href="#" class="FAQ">FAQ</a>

<a href="#" class="Notes">Notes</a>

</nav>

</div>

</header>

<section class="banner">

<ul>

<li class="active"><img src="images/banner/banner1.jpg"/></li>

<li class="left"><img src="images/banner/banner3.jpg"/></li>

<li class="right"><img src="images/banner/banner2.jpg"/></li>

</ul>

</section>

<section class="main">

<aside>

<h1>Recent <samp>Course</samp></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 <samp>Massive Open Online Course!</samp></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>

<div class="container">

<p>

Copyright&nbsp;&copy;&nbsp;imooc.com&nbsp;All&nbsp;Rights&nbsp;Reserved.

</p>

<span>

<img src="images/icon/weichat.png"/>

<img src="images/icon/sina.png"/>

<img src="images/icon/qq.png"/>

</span>

</div>

</footer>

</body>

</html>

*{

padding:0;

margin:0;

border:none;

font-family:Arial;

font-size:14px;

}

a{

text-decoration:none;

}

ul{

list-style:none;

}

header{

height:80px;

background:#000;

}

/*> 直接后台选择器、子选择器*/

header > .container{

width:1200px;

margin:0 auto;

}

header > .container > a{

display:block;

float:left;

margin: 5px 25px;

}

header > .container > nav{

float:right;

}

header > .container > nav > a{

font-size:24px;

display:block;

width:110px;

height:73px;

line-height:73px;

text-align:center;

float:left;

color:#fff;

}

header > .container > nav > a.Home{background:#433b90;}

header > .container > nav > a.Course{background:#017fcb;}

header > .container > nav > a.Actual{background:#78b917;}

header > .container > nav > a.Plan{background:#feb800;}

header > .container > nav > a.FAQ{background:#f27c01;}

header > .container > nav > a.Notes{background:#d40112;}

header > .container > nav > a:hover,

header > .container > nav > a.active{

padding-bottom:7px;

}

.banner {

background:#eaeaea;

}

.banner > ul{

position:relative;

width:1490px;

height:538px;

margin:0 auto;

padding-top:10px;

}

.banner > ul > li{

position:absolute;

width:610px;

height:300px;

overflow:hidden;

}

.banner > ul > li.active{

z-index:2;

top:37px;

right:0;

left:0;

width:960px;

height:460px;

margin:auto;

border:1px solid #fff;

}

.banner > ul > li.left{

z-index:1;

top:0;

bottom:0;

left:0;

margin:auto;

}

.banner > ul > li.right{

z-index:1;

top:0;

right:0;

bottom:0;

margin:auto;

}

.banner > ul > li > img{

position:absolute;

left:-30%;

height:100%;

}



正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

4回答
好帮手慕言 2020-03-23 20:14:03

同学你好,在同学的代码中,没有看到给body元素设置宽度,可能是分辨率的原因,在同学的电脑上显示的是1046px。现在没有滚动条了即可,继续往下学习吧,祝学习愉快~

好帮手慕言 2020-03-22 19:15:45

同学你好,有可能是分辨率的问题,同学可以给.banner>ul设置的宽度调整的小一些。祝学习愉快~

  • 提问者 慕斯卡7039390 #1
    老师,我最后看了,.banner的宽度为1046px,而.banner>ul的宽度为1490px,要大于.banner的宽度(.banner的宽度不是要被子元素撑开么,怎么是1046px啊?按原来的代码),最后我把.banner>ul的宽度设置为1460px,其他li的宽度依次减小,才没有了水平滚动条,不知是否可以
    2020-03-23 18:32:28
  • 提问者 慕斯卡7039390 #2
    老师,body的宽度也是1046px?
    2020-03-23 18:38:02
提问者 慕斯卡7039390 2020-03-22 18:07:16
老师,以下是我的代码效果图,却是有水平滚动条,且右边的图片凸出

http://img1.sycdn.imooc.com//climg/5e77381309d1787c10240626.jpg



好帮手慕夭夭 2020-03-21 19:14:29

同学你好,老师使用你的代码测试,没有横向滚动条,如下:

http://img1.sycdn.imooc.com//climg/5e75f70309246a5119180903.jpg

另外,右边凸起具体指的哪里。请同学先自己再重新测试一下,如果还有问题,可以把具体位置描述一下,以便老师定位问题。

祝学习愉快 !

问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师