gpt4 book ai didi

html - 文本周围的紧凑(透明)框的 CSS

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

我正在尝试使用 CSS 复制这个经过 Photoshop 处理的标题:

Photoshopped header example

我通过创建一个背景为标题图像的 CSS 类来做到这一点:

.header-text {
background-image: url(/images/group.jpg);
background-repeat: no-repeat;
background-position: center;
text-align: center;
background-size: auto;
width: 900px;
height: 250px;
/*margin: 0px 0 0 0px;*/
padding: 0 0 0 0;
position: relative;
float: left;
}

然后将包含文本的 h1 放入该类的 div 中。这是 h1 的 CSS(抱歉,由于我一直在尝试调试,它过于冗长):

.header-text h1{
background:
linear-gradient(
rgba(33, 33, 33, 0.7),
rgba(33, 33, 33, 0.7)
);
position: absolute;
font-weight: normal;
bottom: 0px;
left: 0px;
font-family: 'Roboto', Calibri, Helvetica, Arial, sans-serif;
font-size: 75px;
color: #f2f2f2;
width: 900px;
height: 82px;
margin: 0 0 0 0;
padding: 0 0 0 0;
}

以及 header 的 HTML:

<div id="header_wrap" class="inner">
<div class="header-text">
<h1>CS Women UMass Amherst</h1>
</div>
...
</div>

但是,无论我多么努力,我似乎​​都无法像在 Photoshop 图像中那样使文本背景充满文字。据我所知,我已经删除了所有填充,所以我不知道这个额外的背景是从哪里来的。我能得到的最接近的是:

enter image description here

提前致歉:我不是前端人员!

最佳答案

line-height 应该有助于获得我认为您正在寻找的效果。这是一个 example .

关于html - 文本周围的紧凑(透明)框的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33616751/

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