我正在尝试在具有图像背景的按钮底部制作一个透明的 div。这个 div 将包含应该对齐的文本。文本的长度各不相同,因此 div 应该增大以容纳文本。
我的方法不起作用——它产生了这个结果:
这些按钮具有相同的类;唯一的区别是没有图像的那个是动态创建的:
<button class="tiles" style="padding: 0px; background: url(../static/bilder/Multifunktionstür.jpg); background-size: cover; background-repeat: no-repeat" v-if="selectedCategory==''" >
<div class="button-label flex-container">
<h3>MULTIFUNKTIONSTÜREN</h3>
</div>
</button>
<button v-for="category in categories" class="tiles" v-if="selectedCategory==''" @click="selectCategory(category)">
<div class="button-label flex-container">
<h3>{{ category.name.toUpperCase() }}</h3>
</div>
</button>
.flex-container {
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center;
justify-content: center;
}
.button-label {
text-align: center;
background-color: rgba(255, 255, 255, 0.8);
position: absolute;
width: 100%;
height: 20%;
bottom: 0px;
}
关于我可能做错了什么的任何想法?谢谢。
似乎您正在为带有图像的 div 赋予内联样式:style="padding: 0px;"。这是删除图像块中的空间。如果您也将填充 0 应用于另一个框,您应该能够在两个框中获得相同的结果。
您可以使用:
.button.tiles {
padding: 0;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句