Css Wordpress与背景图像
没有固定高度,我的背景图像无法显示 我的代码如下Css Wordpress与背景图像,css,wordpress,background-image,Css,Wordpress,Background Image,没有固定高度,我的背景图像无法显示 我的代码如下 <div class="site-branding"> <div class="main-image"> </div> </div> 有没有解决方案可以在没有固定高度的情况下工作?空的高度将为0px,因此必须指定一个高度 尝试在其中添加一些文本,您将看到您的图像显示出来,而不指定高度。不,您在任何情况下都无法做到这一点,您只需检查div中的内容是否足以显示图像。我不知道你必须使用固定的高
<div class="site-branding">
<div class="main-image">
</div>
</div>
有没有解决方案可以在没有固定高度的情况下工作?空
的高度将为0px,因此必须指定一个高度
尝试在其中添加一些文本,您将看到您的图像显示出来,而不指定高度。不,您在任何情况下都无法做到这一点,您只需检查div中的内容是否足以显示图像。我不知道你必须使用固定的高度或最小高度使用
最小高度:600px
对于
现在此div中没有内容,因此高度为零背景图像
正在被背景
覆盖。正如下面的答案所说,它是一个空的
,所以你需要给它一个高度。(至少一个最小高度
)
.main-image{
background-image:url('/nonprofit/wpcontent/uploads/2015/04/image1.jpg');
background: url('image1.jpg');
background-position: center;
background-size: cover;
background-repeat: no-repeat;
height:600px;
}