html - CSS删除行之间的间距

标签 html css

是否可以去除两个居中对齐文本之间的间距?

HTML:

  <div id="content2">
       <p class="t1">Discover</p>
       <p class="t1">Discover</p>
    </div>

CSS:

    #content2 {
        clear: both;
        overflow: auto;
    }

    .t1 {
      font-weight: bold;    
      font-size:60px;   
      color: black;
        text-align: center;
    }

p {
    font-size : 30px;
    padding : 0;
    margin : 30px;
    line-height : 20px;
}

代码笔:https://codepen.io/jayvicious/pen/owNJRr

我也在改编自这个线程: Remove spacing between <p>

当我增加行高时,content2 之间的间距和 p也增加。

我正在寻找与此类似的输出:

enter image description here

每次我增加行高,它也会影响第一个段落的间距<p>content2

最佳答案

您能做的最好的事情就是从 p 标签中删除边距/填充并调整行高。

作为示例,请查看 https://codepen.io/anon/pen/bRGzNW

HTML:

<div id="content2">
   <p class="t1">testGg</p>
   <p class="t1">testgG</p>
   <p class="t1">testGg</p>
</div>

CSS:

#content2 {
    clear: both;
    overflow: auto;
}

.t1 {
    font-weight: bold;  
    font-size:60px; 
    line-height:60px;
    color: black;
    text-align: center;
}

p {
    padding : 0;
    margin : 0;
}

关于html - CSS删除行之间的间距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44352583/

相关文章:

javascript - Jquery 克隆只重复一次。需要重复多次

html - 如何获取背景大小 :cover zoomed on hover

html - 调整一个 child 的div宽度,但不调整其他 child 的div宽度

javascript - CLICK 事件的反义词是什么?

html - 如何将箭头添加到div?

html - z-index 似乎无法正常工作

javascript - 当元素是 p5.js Canvas 的一部分时停止调整视口(viewport)大小

CSS BETWEEN 选择器?

css - 不同浏览器之间表格单元格上的背景图像问题

apache - 通过基于域名的 URL 访问 Java Spring 服务时,jQuery .ajax 调用返回错误