Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS Z索引问题_Css - Fatal编程技术网

CSS Z索引问题

CSS Z索引问题,css,Css,我试图调整z索引顺序,使第一类比第二类更接近 但我一辈子都不能看到一个盒子的影子 .title { background-image: linear-gradient(bottom, rgb(249,252,249) 33%, rgb(255,255,255) 37%); background-image: -o-linear-gradient(bottom, rgb(249,252,249) 33%, rgb(255,255,255) 37%);

我试图调整z索引顺序,使第一类比第二类更接近

但我一辈子都不能看到一个盒子的影子

    .title {
        background-image: linear-gradient(bottom, rgb(249,252,249) 33%, rgb(255,255,255) 37%);
        background-image: -o-linear-gradient(bottom, rgb(249,252,249) 33%, rgb(255,255,255) 37%);
        background-image: -moz-linear-gradient(bottom, rgb(249,252,249) 33%, rgb(255,255,255) 37%);
        background-image: -webkit-linear-gradient(bottom, rgb(249,252,249) 33%, rgb(255,255,255) 37%);
        background-image: -ms-linear-gradient(bottom, rgb(249,252,249) 33%, rgb(255,255,255) 37%);

        background-image: -webkit-gradient(
            linear,
            left bottom,
            left top,
            color-stop(0.33, rgb(249,252,249)),
            color-stop(0.37, rgb(255,255,255))
        );
        box-shadow: 0px 1px 5px rgba(0,0,0,1);
        height: 50px;
        z-index: 1;
    }

.banner {
    background-image:url('images/grad.jpg');
    background-color:#cccccc;
    height: 500px;
    z-index: -1;
}
但这对我不起作用

标记>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Design Test | PolyDevs</title>
<link rel="stylesheet" type="text/css" href="style.css">
<div class="header">
    <div class="title">
        <div class="logo">
            <img src="images/banner.png"/>
        </div>
    </div>
</div>
</head>
<body>
<div class="banner">

</div>
</body>
</html>

设计测试| PolyDevs

位置:相对位置;修正了我的问题,为什么

绝对定位图元由一个相对定位的父图元定位

如果没有相对定位的元素,则默认相对定位的
元素将成为指定“from”位置(左、右、下、上)的父元素

示例:

<body>
 <div class="posrelative">
  <div class="posabsolute">hello world</div>
 </div>
 </body>

你好,世界
Hello world无法根据父包装器
的位置进行绝对定位,这可能是侧边栏或页脚等

<body>
 <div>
  <div class="posabsolute">hello world</div>
 </div>
</body>

你好,世界

Hello world现在可以定位为绝对位置,但不再基于父对象的位置,而是基于
的位置,默认情况下,该位置会占据浏览器窗口的整个宽度

请发布您的HTML。您也可以共享您的标记(HTML)吗
z-index
就是这样,您的标记很重要……banner的父元素是否设置为
位置:relative
?我知道这把我绊倒在过去的位置:亲戚;修正了我的问题,为什么?谢谢一群家伙不要在
标题中添加
div