1.感觉很莫名其妙 代码看了半天感觉代码就是对的 但是元素就是显示不出来 设置了背景色的 scrollWay这个元素就是显示不出来
2.<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ffg</title>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
.box {
width: 500px;
height: 150px;
margin: 50px auto;
background-color: #ccc;
position: relative;
}
.leftBtn {
float: left;
padding-top: 20px;
}
.leftBtn a {
display: block;
width: 20px;
height: 65px;
background: url(images/bg05.png) no-repeat 0 0;
}
.rightBtn {
float: left;
padding-top: 20px;
}
.rightBtn a {
display: block;
width: 20px;
height: 65px;
background: url(images/bg05.png) no-repeat -40px 0;
}
.imgList {
float: left;
height: 130px;
width: 460px;
overflow: hidden;
}
.m_unit {
width: 100%;
height: 130px;
}
.scrollWay {
width: 100%;
height: 20px;
z-index: 999;
background-color: rgb(66, 66, 66);
}
</style>
</head>
<body>
<div class="box">
<div class="leftBtn">
<a href="javascript:;"></a>
</div>
<div class="imgList">
<div class="m_unit"></div>
<div class="scrollWay">ererertwer
<div class="scrollBlock"></div>
</div>
</div>
<div class="rightBtn">
<a href="javascript:;"></a>
</div>
</div>
</body>
</html>
看图片就是出不来 背景色
你不应该给.imgList设置高度,你设置的130px,他的第一个子元素也是130px,scrollWay这个元素正好在外面,而你又设置了overflow:hidden溢出隐藏!
修改父元素的高度,或者overflow就行啦