html - 如何在图像上显示文本并在我的页面中正确定位该图像?
问题描述
我正在尝试将图像添加到图像底部带有文本的页面。但是,我遇到了 3 个问题:
图像未正确加载;它要么由同一图像的网格组成,要么是原始图像的裁剪。
图像定位不正确,我可以将其从上到下移动,但无法将其从左侧移开。
文本未正确加载到图像顶部。
这是我的代码:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Himalayas</title>
<link rel=stylesheet href="stylesheet.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<div class="title-image">
<div class="title-text">
Text Here
</div>
</div>
</body>
</html>
SCSS:
$title-left:150px;
.title-image{
color: red;
position:relative;
top:$title-top;
left:$title-left;
height:100px;
width:200px;
background-size:100%;
background-image: url(TitleMountain.png);
}
.title-text{
position:relative;
top:$title-top+70;
left:$title-left;
}
任何帮助是极大的赞赏
解决方案
推荐阅读
- android - 如何在 viewpager 中添加意图
- bash - 将 bash 函数自动添加到 $PATH 或 bash shell
- javascript - 使用上一个/下一个按钮时更改活动选项卡颜色
- laravel - Laravel.log 文件不更新日志
- mysql - 如何将一个 Mysql 行显示为多行?
- json - 将特定 API 数据写入 JSON 文件
- javascript - 对象作为 React 子对象无效(发现:[object Promise])Google Maps
- javascript - 视频播放完毕后如何添加自定义按钮
- ios - Xcode:ipatool 因异常而失败
- c++ - 如何使用“现代 CMake”设置编译器标志?