css - 如何删除 CSS 中 <image> 周围的间距?

标签 css image spacing

<分区>

我在图像的底部和右侧有这个奇怪的间距,我想将其删除。我已将填充和边距设置为 0px,但它仍然显示。这很烦人,因为我希望图像能够以零间距整齐地放入外框,以获得像素完美的外观。

img.news_title_icon {
  width: 80px;
  height: 80px;
  padding: 0px; margin: 0px; border: 0px;
}
body {
  width: 800px;
  margin: auto;
  margin-top: 50px; /* for testing */
  padding: 0px;
  font-family: arial, helvetica, sans-serif;
  font-size: 11pt;
  background-color: #001133;
  color: white;
}
div.news_title_container {				
  margin-bottom: 5px;	
}
.light_container, .dark_container {
  -webkit-box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.57);
  -moz-box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.57);
  box-shadow: 0px 0px 4px 2px rgba(0,0,0,0.57);
  border: 1px solid #005eff;		
}
.light_container {
  background-color: rgba(0, 34, 102, 0.8);	
}
<div class="news_title_container light_container">
  <img class="news_title_icon" alt="an image">
  <img class="news_title_icon" alt="an image">
  <img class="news_title_icon" alt="an image">
</div>

有人可以帮忙吗?谢谢!

最佳答案

内联 block 有这个问题。更多详情 read this 有几种方法

  1. 使用 float 。
  2. 使用 flexbox。
  3. 删除 html 中标签之间的空格。
  4. 负边距
  5. .....

例如,这不是您的问题。

<div class="news_title_container light_container">
  <img class="news_title_icon" alt="an image"><img class="news_title_icon" alt="an image"><img class="news_title_icon" alt="an image">
</div>

关于css - 如何删除 CSS 中 <image> 周围的间距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34964851/

上一篇:html - 2个div填充水平空间

下一篇:javascript - Materialise:模态移动背景并导致页面向右跳转

相关文章:

python - OpenCV BGR 和 PyPlot RGB

qt - 强制删除 Qt 中的所有水平间距

html - 折叠导航旁边的奇数空白

css - 如何在不移动元素的情况下在边框和元素之间留出空间?

css - 使用CSS调整浏览器窗口大小时如何使图像自动调整大小?

css - Sass 不编译

image - 在 MATLAB 中翻转和旋转彩色图像

Xamarin - CollectionView VerticalItemSpacing 不起作用

html - 在我的网页左右两侧放置装饰图片

html - 奇怪的 Bootstrap 网格失败?