【发布时间】:2022-01-31 08:30:54
【问题描述】:
即使我已经放置了 text-align 和 align-items,我的网站图像中的文本也不会居中。请帮助我,这是我的任务。我为此使用了 html 和 css。
.projname img {
width: 100%;
height: 40vh;
}
.proj-title {
position: absolute;
top: 20%;
text-align: center;
color: white;
}
.proj-title h1 {
font-size: 500%;
text-transform: uppercase;
text-shadow: 1px 1px 10px #000;
color: white;
text-align: center;
}
.proj-title h3 {
font-size: 200%;
font-weight: 500;
text-shadow: 1px 1px 10px #000;
padding-bottom: 1rem;
color: white;
text-align: center;
}
<div id="home">
<div class="projname">
<img src="background.jpg">
<div class="proj-title">
<h1 class="display-2">Boostrap</h1>
<h3>Lorem ipsum, lorem ipsum dolor sit amet</h3>
</div>
</div>
</div>
【问题讨论】:
-
用
class="display-2"更正你的代码元素应该是<h1>而不是<hr>,不是吗? -
"text inside the image"你不能用 CSS 控制图片的内容
标签: html css image responsive