html - 特定 div 中前面的文本和后面的背景图像
问题描述
我正在尝试创建一个具有前端文本和背景图像的 div。
到目前为止,这是我的基本 html
<div>
<img src="@userImage" width="90px" height="90px" />
<div class="footer-field">Hello World</div>
</div>
这是我得到的结果。
但我想从 Microsoft word 中得到类似的东西。
我希望有人帮助我。先感谢您
解决方案
这是一种使用background-image
单个html元素的方法。
.footer-field {
width: 190px;
height: 190px;
display: grid;
align-items: center;
text-align: center;
color: red;
background-size: cover;
background-image: url(https://images.unsplash.com/photo-1559157693-c34156e0f8c3?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1350&q=80);
}
<div class="footer-field">Centered Text</div>
推荐阅读
- shopify - 如何在没有会话的情况下在 Shopify 应用上生成访问令牌
- r - 在R中基于时间间隔合并两个数据集
- python - 获取正值的总和和负值的总和
- windows - Windows 批处理文件 - CLS 命令不起作用
- c++ - 我可以在不涉及 AES C++ 的情况下使用 openssl 3.0 信封 RSA 加密吗?
- laravel - 在路径中找不到文件:my_path/storage/file_39.pdf
- jboss5.x - Netbeans 12 和 JBoss
- r - 根据选定的 tabItem 创建反应数据框
- html - 如何并排对齐两个元素并将它们居中
- android - Android kotlin 调试协程