div:之后不显示带有背景大小的图像:封面



我想显示具有不透明度设置的背景图像,所以我使用了这段代码

标记:

<div class="container">
    <div class="BackLayer">
         <section id="galleria">
             <div class="title-box">
                 <h1 id="galleria-title">Galleria a Arte Studio Invernizzi</h1>
             </div>
         </section>
    ...

.CSS:

#galleria:before {
   content : "";
   display: block;
   position: absolute;
   top: 0;
   left: 0;
   background: url('images/00-Tremlett-Verjux-2013.jpg') no-repeat;
   width: 587px;
   height: 400px;
   opacity : 0.2;
}

它工作正常,但我需要将图像设置为背景大小:封面...(我想做一些类似于 http://wrapbootstrap.com/preview/WB048M27G 的事情)

如果我只是添加背景大小:封面,宽度属性会覆盖它(或者我猜......无论如何,它不起作用);如果我不设置任何宽度/高度,图像就不会显示...

这个问题一直让我头疼...有什么建议吗?

尝试更改 中的绝对位置:

position: absolute;
top: 0;
left: 0;
bottom: 0; /* add this */
right: 0; /* add this */

而是使用宽度/高度

最新更新