css - 如何调整放置在 CSS div 背景上的图像 gif 的大小
问题描述
#box-2
{
width:50%;
height:80%;
background-color: rgba(177, 177, 177, 0.116);
border:transparent;
background-image:url(human.gif);
}
b
#box-2
{
width:50%;
height:80%;
background-color: rgba(177, 177, 177, 0.116);
border:transparent;
background-image:url(human.gif);
}
<div
id="box-2">
<p class="display-6">Information</p>
<h6 style="text-align: center;">How to nagivate through the Map</h6>
<div class="foo blue"></div><ul>Lecture halls</ul>
<div class="foo orange"></div><ul>Eating Places</ul>
<div class="foo purple"></div><ul>Residences</ul>
<div class="foo black"></div><ul>School Services</ul>
<div class="foo green"></div><ul>Schools</ul>
</div>
我想知道如何调整我放在我的 div 上的 gif 的大小,我只在 CSS 背景上添加了 gif,而不是在 HTML 代码上
解决方案
您可以使用 css 属性background-size
。例如,如果您希望图像覆盖盒子,您可以选择cover
. 您也可以输入固定值。有关更多信息,请参见此处:https ://developer.mozilla.org/de/docs/Web/CSS/background-size
#box-2 {
width: 50%;
height: 80%;
background-color: rgba(177, 177, 177, 0.116);
border: transparent;
background-image: url(human.gif);
background-size: cover;
}
<div id="box-2">
<p class="display-6">Information</p>
<h6 style="text-align: center;">How to nagivate through the Map</h6>
<div class="foo blue"></div>
<ul>Lecture halls</ul>
<div class="foo orange"></div>
<ul>Eating Places</ul>
<div class="foo purple"></div>
<ul>Residences</ul>
<div class="foo black"></div>
<ul>School Services</ul>
<div class="foo green"></div>
<ul>Schools</ul>
</div>
推荐阅读
- pexpect - 将 if/else 语句与 pexpect 一起使用
- neo4j - Neo4j - 匹配具有多个连接的节点
- actionscript-3 - 在 flex AIR 中访问通过 htmlLoader 加载的 nativeWindow 的内容
- docker - 如何在 Docker 容器中提供自定义名称解析
- javascript - 使用 jQuery 检索单击的下拉项
- javascript - 无法让 Firebase 云消息传递在我的网络应用程序中工作
- office365 - 通过 Office 365 的 SMTP 中继发送时跟踪电子邮件状态
- vb.net - VB.NET 编辑数据时出错?
- macos - 在 Mac 上的 chrome 中运行 Selenium 测试时的视觉效果
- ios - WKWebView 不加载本地 html 文件