猿问

CSS网页布局的作业2-10

麻烦你帮我看一下,banner的照片为什么宽度都谢了100%,却只有一部分宽度

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>CSS2-10作业</title>

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

">

</head>

<body>

<div class="top">

<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>

<div class="banner">

<div class="banner-img"><img src="images\banner3.jpg"></div>

</div>

<div class="about"></div>

<div class="gallery"></div>

<div class="footer"></div>

</body>

</html>

*{

padding: 0;

margin: 0;

}

.top{width: 100%;height: 81px;background-color:#07cbc9;}

.top .logo{float:left;margin-left: 158px;margin-top: 15px}

.top .nav {float:right;margin-right: 111px}

.top .nav ul{padding-right: 20px}

.top .nav ul li{width:80px;font-weight:bolder;list-style-type:none; float: left; line-height: 81px;color:#fff6ea;padding-right: 20px }


.banner{width:100%;height: 601px;position: relative;}

.banner .banner-img{width:100%;height: 601px;position: absolute;}


慕桂英3251318
浏览 1549回答 2
2回答

你说2016

因为你并没有设置img标签的宽度,只是在代码最后一行设置了img标签上面一个div即(.banner-inner)的宽度为100%.banner .banner-img{width:100%;height: 601px;position: absolute;}改成.banner .banner-img img{width:100%;height: 601px;position: absolute;}就可以了

闪开我要发

.banner .banner-img>img{width:100%;height: 100%;}
随时随地看视频慕课网APP
我要回答