Css 如何覆盖元素

Css 如何覆盖元素,css,Css,在尝试了所有可能的位置变化后:相对/绝对/等和负边距,我想知道是否有人能告诉我如何让两个绿色条覆盖顶部和底部的标题图像 *注意,由于WordPress的自定义图像头处理响应的方式,主头必须保持为img,而不是成为背景属性 非常感谢 将两个条绝对定位在公共祖先元素中。例如: ​ ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ 并使用以下CSS: ​header { position: relative } nav:nt

在尝试了所有可能的位置变化后:相对/绝对/等和负边距,我想知道是否有人能告诉我如何让两个绿色条覆盖顶部和底部的标题图像

*注意,由于WordPress的自定义图像头处理响应的方式,主头必须保持为img,而不是成为背景属性


非常感谢

将两个条绝对定位在公共祖先元素中。例如:

​ ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ 并使用以下CSS:

​header { 
    position: relative
}
nav:nth-of-type(1) { 
    top: 0
}
nav:nth-of-type(2) { 
    bottom: 0
}
nav {
    background-color: rgba(0,255,0,.25);
    box-sizing: border-box;
    position: absolute;
    width: 100%;
}

这将为您提供以下信息:

将两个条绝对定位在公共祖先元素中。例如:

​ ​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ 并使用以下CSS:

​header { 
    position: relative
}
nav:nth-of-type(1) { 
    top: 0
}
nav:nth-of-type(2) { 
    bottom: 0
}
nav {
    background-color: rgba(0,255,0,.25);
    box-sizing: border-box;
    position: absolute;
    width: 100%;
}
这将为您提供以下信息:

尝试此css

 and make the inline css to external css its for your reference (inline css).

bootstrap.css line 5416

#masthead.container {
    padding: 0;
    position: relative;
    width: 1198px;
}


app.css line 13

#banner {
    position: absolute;
}

bootstrap.css line  3779

.navbar {
    color: #777777;
    overflow: visible;
    position: absolute;
    width: 100%;
}


<div class="container" style="width:100%">
<header style="margin-top: -40px;" class="navbar" role="banner">
如图所示:

试试这个css

 and make the inline css to external css its for your reference (inline css).

bootstrap.css line 5416

#masthead.container {
    padding: 0;
    position: relative;
    width: 1198px;
}


app.css line 13

#banner {
    position: absolute;
}

bootstrap.css line  3779

.navbar {
    color: #777777;
    overflow: visible;
    position: absolute;
    width: 100%;
}


<div class="container" style="width:100%">
<header style="margin-top: -40px;" class="navbar" role="banner">
如图所示:


您可以使用cssz-index属性

例如—


您可以使用cssz-index属性

例如—


+1用于cat图像。我总是用我的例子做同样的事情:猫的形象+1。我总是用我的例子做同样的事情: