我想要使背景标题图像响应。我需要它是视口高度或图像高度的100%,以较小者为准。背景img没有显示
一个例子是类似https://brittanychiang.com/v1/
页眉横幅DIV大小看起来是正确的,但图像不似乎显示出来?
创建一个的jsfiddle这里:https://jsfiddle.net/pnnxm1yf/2/
header {
height: 100vh;
max-height: 850px;
}
#header-banner {
color: #fff;
background: linear-gradient(rgba(0,0,0,0.5), rgba(0,0,0,0.5)),url(https://unsplash.com/?photo=gzH1qxPLXtA) center center no-repeat;
background-size: cover;
position: relative;
}
<p>Why is my image not showing up?</p>
<header>
<section id="header-banner">
</section>
</header>
<p>content after image</p>
图片网址错误,并缺少高度:)请参阅https://jsfiddle.net/pnnxm1yf/3/ – keja
您的图片网址重定向到:'https:// unsplash.com/photos/gzH1qxPLXtA' –
您网址并不是指图像 – Roysh