首页 > 解决方案 > 如何从标题中删除css中的空格

问题描述

我试图在一些单词上方放置一个标题,但我的标题下面有一个空格,我的 css 是

.title{
  grid-template-areas:"image" "title"
}

.title_word{
   grid-area: title;
}

.title_img{
  grid-area: img;
}
<div class="title">
<p class="title_word">hello</p>
<img src="https://live.staticflickr.com/5549/10549969363_76ccf43946_b.jpg" alt="not working" class="title_img">
</div>

如您所见,这可行,但是在 Firefox 和 chrome 中,它给了我很多空白

标签: css

解决方案


如果要删除下面的空格,请添加:

margin-bottom: 0;

给你的

.title

最后它应该看起来像这样。

.title {
    grid-template-areas:"image" "title"
    margin-bottom: 0;
}

推荐阅读