gpt4 book ai didi

html - 为什么我的 HERO 不显示上面有文字的图像?

转载 作者:行者123 更新时间:2023-11-28 19:17:37 25 4
gpt4 key购买 nike

我想知道是否可以得到一些帮助。

我正在尝试创建一个 HERO,在这里您可以看到我是如何将它与 和 标签一起编写的 https://www.screencast.com/t/COOZ3dCy9l

在这里你可以看到我是如何做css的 https://www.screencast.com/t/gSt4tvpY2C

在这里你可以看到结果是多么的不好 https://www.screencast.com/t/B5k1NS4J

我注意到我没有冒号“:”,所以我在后面加上了。但是那没有用。我尝试使用图像的 URL 并链接到我的图像文件夹。

我想要页面顶部的英雄标题。我正在尝试让背景图片在上面显示文字。

<!--Start of Hero-->

<!DOCTYPE html>
<html>
<head>
<title>Connie's High Quality CLeaning</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="javascript/javascript.js"></script>
</head>
<body>
<div class="hero-image">
<div class="hero-text">
<h1>
Connie's
</h1>
<p>
High Quality Cleaning Servive
</p>
</div>
</div>

<!--End of Hero-->

<!--start of external file style.css -->

body, html {
height: 100%;
}
.hero-image{
background-image: linear-gradient(rba(0,0,0,0.5)), url('images/kitchen.png');
height: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;

}
.hero-text{
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}

<!-- End of external file style.css -->

最佳答案

嘿,我已经更改了您的 CSS,并且效果很好。这是 CSS:

body,
html {
height: 100%;
}

.hero-image {
width: 100%;
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('images/kitchen.png');
height: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative
}

.hero-text {
text-align: center;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
}

关于html - 为什么我的 HERO 不显示上面有文字的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57947864/

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