鍍金池/ 問答/HTML/ 請CSS高手幫我看看為什么元素就是顯示不出來?

請CSS高手幫我看看為什么元素就是顯示不出來?

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溢出隱藏!

clipboard.png
修改父元素的高度,或者overflow就行啦

2018年5月26日 08:24
編輯回答
吢涼

應該是沒有清除浮動,然后又用了overflow為hidden.
圖片描述

2018年7月1日 16:38
編輯回答
下墜

非常感謝兩位的回答 受益了..謝謝

2018年3月19日 12:50