Why a fixed element covers a floated element?

丶灬走出姿态 提交于 2020-01-06 20:23:16

问题


the Html is :

<!DOCTYPE HTML>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="wp-1-main.css">
    <title></title>
</head>
<body>
    <div class="wrapper">
        <div class="textArea"></div>
    </div>
    <div class="imageLine">
    </div>
</body>
</html>

and the CSS is

.wrapper{
    width: 100%;
    height: 400px;
    position: fixed;
    top: 50%;
    margin-top: -200px;
    border-top: solid 1px black;
    border-bottom: solid 1px black;
    background-color: pink;
}

.imageLine{
    width: 500px;
    height: 1500px;
    float: right;
    margin-right: 60px;
    background-color: grey;

}

my goal is to make the .imageLine cover some .wrapper , and the wrapper is centered vertically , and always be in the viewport. but those code turn out that the .wrapper covers the .imageLine . any idea to fix that?


回答1:


You could use z-index

Higher z-indices will come infront of lower z-indices.



来源:https://stackoverflow.com/questions/11281271/why-a-fixed-element-covers-a-floated-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!