gpt4 book ai didi

html - CSS - 六边形背景图像

转载 作者:太空宇宙 更新时间:2023-11-04 13:08:45 25 4
gpt4 key购买 nike

我需要使用空心六边形图像作为我网站中某些内容的背景。它应该看起来像这样:

enter image description here

但是我在布置六边形内的内容时遇到了各种麻烦。

到目前为止我有这个:

.hex-bg {
background-image: url('/images/diamond.png');
background-size: cover;
background-repeat: no-repeat;
min-height: 30px;
padding: 10px;
}

你们认为处理这种情况的最佳方法是什么?

最佳答案

JSbin Demo

.hex-bg {
background-image: url('/images/diamond.png');
background-size: cover;
background-repeat: no-repeat;
background-position:center;
min-height: 30px;
box-sizing:border-box;
padding: 20px;
width:250px;
height:290px;
text-align:center;
color:white;
font-size:14px;
}

.hex-bg img{
max-width:50px;
padding:20px;
}

.text-wrapper{
margin-top:10px;
}

只要文本不太长并且不会溢出六边形的底部,它就应该可以工作。如果您需要文本的精确换行,您可能需要考虑另一种方法,例如 CSS Text Wrap

关于html - CSS - 六边形背景图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36525126/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com