你好,亲爱的stackoverflowers,
我正在一个网站上,figcaptions的背景色需要与其上的图像背景相对应。因此,基本上,多个figcaptions具有多种不同的背景色。是否可以添加ID或类?
我一直在网上搜索并没有找到答案,所以我在这里,为您提供出色的人才!这就是我目前所拥有的,这是非常基本的。
figcaption{
position: absolute;
color: white;
background: rgba(10,10,10,1);
width:245px;
height:30%;
padding: 10px 20px;
opacity: 100;
bottom: 0;
left: -30%;
-webkit-transition: all 0.6s ease;
-moz-transition: all 0.6s ease;
-o-transition: all 0.6s ease;
}
最佳答案
您可以将一个类添加到figcaption并将其应用背景色。
如果您对图像和figcaption使用相同的类,则它们将具有相同的背景色-例如:
的HTML
<img class="redbg">
<figcaption class="redbg">Caption</figcaption>
的CSS
.redbg{ background:red; }