html - 如何将图像定位在 HTML/CSS 中的文本背景
问题描述
我正在研究 CSS 中的视口元素,并希望背景是来自 unsplash.com 网站的图像
我尝试了来自在线网站的图像,这些图像不适用于背景图像,但本地计算机运行良好
header {
background: #333 ('https://unsplash.com/photos/0J3_p-xc9s8');
color: white;
line-height: 1.7em;
height: 100vh;
padding: 2rem;
}
<header>
<h1>Welcome to my Website</h1>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Maxime officiis eveniet possimus saepe, deleniti neque?</p>
<a href="#" class="btn">see more</a>
</header>
我希望出现背景图像,但没有任何反应。
解决方案
url
不见了!
此外,您必须使用图片网址。不是 unslplash 的那个...
改用这个:
background: #333 url('https://images.unsplash.com/photo-1569255726521-d2e663a80283?ixlib=rb-1.2.1&auto=format&fit=crop&w=1051&q=80');
推荐阅读
- c# - 在wpf上绘制地理坐标
- flutter - 飞镖 - 类型'列表
' 不是类型 'List 的子类型 - >' of '函数结果'
- python - 按日期合并推文,返回情绪得分计数
- arrays - 在swift中按前两个字符对字符串数组进行排序
- php - 编码语言失败
- actionscript-3 - 收集东西时如何添加分数(Actionscript 3 Adobe Animate)?
- perl - 在 apache httpd 2.4 上正确使用 suexec
- quickblox - 如何在 Swift 中使用 QuickBlox 上传和下载视频
- android - 使用 FragmentManager 替换片段时如何处理视图破坏?
- c - MSP430 中带有 TimerA 的软件串行