css - 列文本位置不匹配;延长列线?

标签 css

学习 CSS 的第 2 天。
第一列不像其他两列那样垂直对齐,我用第一列更改了其他两列中的一列,似乎任何第一列都没有在顶部对齐。 Image of Columns .我没有发布的其余 CSS 似乎没有干扰列,那么为什么以及如何解决这个问题?
由于我添加了一些填充,列之间的线没有到达顶部。我如何扩展它们?

/*CSS*/
.types h3 {
    text-decoration: underline;
    margin-bottom: -5px;
}

.types{
    column-count: 3;
    column-rule: 2px solid black;
    text-align: center;
    background-color: #eee;
    border-top: 1px solid black;
    border-bottom: 1px solid black;
    border-left: 1px solid black;
    box-shadow: 2px 2px 2px black;
    padding-top: 5px;
}

编辑#

<!DOCTYPE html>
<html>  
    <head>  
        <link rel="stylesheet" type="text/css" href="interview.css">  
        <title>Interviews</title>  
    </head>  
<body>  
    <div class="container">
    /*Content that is above the Columns*/
        <div class="types">
            <h3>Standardised Interview</h3>
            <p>
                /*First Long Paragraph from image*/
            </p>
            <h3>Exploratory Interviews</h3>
            <p>
                /*Second Long Paragraph from image*/
            </p>
            <h3>Unstructured Interviews</h3>
            <p>
                /*Third Long Paragraph from image*/
            </p>
        </div>
        /*More content below the Columns*/
    </div>
</body>
</html>

最佳答案

标题有需要清零的默认边距。

A CSS reset应该是有序的,但一个快速简单的方法是:

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
::before,
::after {
  box-sizing: inherit;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

::before,
::after {
  box-sizing: inherit;
}

.types h3 {
  text-decoration: underline;
  margin-bottom: 5px;
}

.types {
  column-count: 3;
  column-rule: 2px solid black;
  text-align: center;
  background-color: #eee;
  border-top: 1px solid black;
  border-bottom: 1px solid black;
  border-left: 1px solid black;
  box-shadow: 2px 2px 2px black;
  padding-top: 5px;
}
<div class="container">
  <div class="types">
    <h3>Standardised Interview</h3>
    <p>
      /*First Long Paragraph from image*/
    </p>
    <h3>Exploratory Interviews</h3>
    <p>
      /*Second Long Paragraph from image*/
    </p>
    <h3>Unstructured Interviews</h3>
    <p>
      /*Third Long Paragraph from image*/
    </p>
  </div>

关于css - 列文本位置不匹配;延长列线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48723957/

相关文章:

html - 如何在 Angular 组件中使用嵌套的 flexbox?

php - 调整浏览器大小时或在移动设备上运行时如何不破坏表格布局

css - 将 div 放入固定位置 woocommerce

html - Flexbox 内容没有通过链接和图像均匀分布

html - CSS 列 : How can I properly align my two columns?

javascript - 获取位于隐藏父级的元素的尺寸

javascript - 如何知道网站或 html 页面的某些特定部分使用了什么 JavaScript 或 jquery?

javascript - 应用 z-index 时悬停状态不起作用

css - 如何将文本对齐到未知大小图像的左下角?

css - 向 Highcharts 树形图上的标签文本添加彩色边框(不是阴影)