我的部分下面有一个带有全屏背景图像的固定标题。我想要做的是,如果我有一个警报,它将回显整个页面推下标题和英雄。但它要么不会出现,要么当我确实显示它不会保持固定并滚动页面。
.sitrep {
top 0;
height: 50px;
width: 100%;
position: fixed;
z-index: 10000;
}
.siteHeader {
min-height: 76px;
height: 76px;
overflow: visible;
background-color: #000;
color: #f4f4f4;
position: fixed;
top: 0;
z-index: 10000;
}
#hero {
height: 100vh;
}
.hero {
background: url(images/hero-bg.jpg) no-repeat top center;
background-color: #000;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
#hero-content {
position: absolute;
width: 100%;
bottom: 0%;
}
#hero-content a {
background-color: #131313;
padding-top: 10px;
height: 40px;
display: block;
font-size: 12px;
text-align: center;
text-transform: uppercase;
text-decoration: none;
}
#hero-content img {
display: block;
margin-top: 2px;
max-height: 145px;
margin-right: auto;
margin-left: auto;
margin-bottom: 53px;
padding: 5px;
}
<div class="sitrep">
<div class="alert-status">
<div class="info">
<span class="closebtn" onclick="this.parentElement.style.display='none';">×</span>
<strong>Announcement!</strong> anouncment goes here.
</div>
</div>
</div>
<div id="siteHeader">my header</div>
<!-- Hero Unit -->
<div id="hero" class="hero">
<div id="hero-content">
<img src="content/images/logo-dt.png" class="img-responsive">
<a class="button" role="button" href="#base">Learn more</a>
</div>
</div>
答案 0 :(得分:0)
您正在混淆class
es和ID
。
在HTML中,您为元素提供sitrep
的ID,而您使用siterep
的类为元素提供样式。
尝试以下任一选项,您将被设置:
更改元素属性 <div id="sitrep">
至<div class="sitrep">
更改CSS以适合正确的元素: .sitrep {
到#sitrep {
快乐的编码!