为什么固定元素覆盖浮动元素? [英] Why a fixed element covers a floated element?
本文介绍了为什么固定元素覆盖浮动元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Html是:
<!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>
且CSS为
.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;
}
我的目标是使.imageLine覆盖一些.wrapper ,并且包装器垂直居中,并且始终在视口中。
但是那些代码证明.wrapper覆盖了.imageLine。任何想法来解决这个问题?
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?
推荐答案
您可以使用 z-index
更高的z指数将面临较低的z指数。
Higher z-indices will come infront of lower z-indices.
这篇关于为什么固定元素覆盖浮动元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文