gpt4 book ai didi

html - 内容阻止文本前后的 Css

转载 作者:太空宇宙 更新时间:2023-11-04 01:49:54 24 4
gpt4 key购买 nike

我正在尝试设计一个八边形,里面塞满了文字。但不知何故,文字没有显示。请帮忙!

HTML

<div class = "octagon">This is some text</div>

CSS

.octagon 
{
width: 134px;
height: 100px;
background: #40174F;
position: relative;
color:white;
}
.octagon::before
{
content: "";
position: absolute;
top: 0;
left: 0;
border-bottom: 25px solid #40174F;
border-left: 25px solid #fff;
border-right: 25px solid #fff;
width: 84px;
height: 0;
color:white;

}
.octagon::after
{
content: "";
position: absolute;
bottom: 0;
left: 0; border-top: 25px solid #40174F; border-left: 25px solid #fff; border-right: 25px solid #fff; width: 84px; height: 0;
color:white;
}

div 中的文本未显示。

最佳答案

在 .octagon 类中添加 line-height 和 text-align

.octagon {
width: 134px;
height: 100px;
background: #40174F;
position: relative;
color: white;
line-height: 6;
text-align: center;
}

关于html - 内容阻止文本前后的 Css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43704982/

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