html - 从 div 元素内的图像中删除间隙
问题描述
我正在做一个前端项目,在那里我创建了一个带有一些文本和图像的“关于我们”部分。
如您所见,我正在尝试删除图像下方的白色小间隙。我尝试调整div 元素和图像的margin
, padding
,height
但我肯定遗漏了一些东西
我的代码:
#about-container{
width:100%;
height:auto;
background-color: white;
position: relative;
margin:0;
display:flex;
}
#about-container div{
margin:0;
padding:0;
height:auto;
}
#desc{
width:30%;
background-color:green;
}
#desc ul{
list-style-type: none;
margin:0;
padding:0;
}
#desc li{
padding:10px;
}
#about-img{
width:70%;
}
#about-img img{
width:100%;
height:500px;
}
<div id="about-container">
<div id="desc">
<h1> Our values </h1>
<ul>
<li>We care about our customer needs </li>
<li>We focus on the quality of our products & services offered </li>
<li>We invest in innovation and sustainable development </li>
<li>We care about the needs of society and vulnerable social groups</li>
</ul>
</div>
<div id="about-img">
<img src="IMAGES/about-img.jpg">
</div>
</div>
感谢您对这项小任务的帮助。
解决方案
添加vertical-align: top;
到图像。或者只是添加diaplay: block
到图像
#about-container{
width:100%;
height:auto;
background-color: white;
position: relative;
margin:0;
display:flex;
}
#about-container div{
margin:0;
padding:0;
height:auto;
}
#desc{
width:30%;
background-color:green;
}
#desc ul{
list-style-type: none;
margin:0;
padding:0;
}
#desc li{
padding:10px;
}
#about-img{
width:70%;
}
#about-img img{
width:100%;
height:500px;
vertical-align: top;
}
<div id="about-container">
<div id="desc">
<h1> Our values </h1>
<ul>
<li>We care about our customer needs </li>
<li>We focus on the quality of our products & services offered </li>
<li>We invest in innovation and sustainable development </li>
<li>We care about the needs of society and vulnerable social groups</li>
</ul>
</div>
<div id="about-img">
<img src="https://www.w3schools.com/bootstrap/sanfran.jpg">
</div>
</div>
推荐阅读
- text - 如何在 Microsoft 认知服务中训练自定义语音模型 语音转文本
- python - PyQt5中带有editingFinished信号的QSpinBox?
- python - 将 UI 元素插入现有布局
- php - 通过 AJAX 单击链接时使用 $wpdb 插入行
- excel - 使用可变文件名导入
- android - 选择订单日期和交货日期后如何关注 textInputLayout
- windows - 现代系统上跨多个显示器的 Windows GDI BitBlt / MaskBlt:不同设备上是否存在 DC?
- java - 为什么在迭代期间从 ArrayList 中删除元素时我没有收到 ConcurrentModificationException
- glfw - GLFW | 什么是框架?
- python - 列出熊猫数据框 - Python