html - DIV间距的困难

标签 html css twitter-bootstrap

我正在开发一个类似于此的网站:

http://rogerdudler.github.io/git-guide/

我似乎无法弄清楚这个人是如何让每个部分 DIV 相互接触的。我查看了他的 CSS 的每一行,但无济于事。他的边距设置为0,我的也是,但还是有间距。

我的似乎是间隔的。我可以通过为自己的 DIV 着色和调整边框大小来解决此问题,但我认为这不是最佳做法。

使用 Bootstrap 和我自己的自定义 css:

html {
overflow-y: scroll;
}

body {
font-size: 30px;
text-align: center;
margin: 0;
padding: 0;
    }

#blocks {
position: relative;
margin: 0;
width: 100%;
color: white;
padding-top: 80px;
padding-bottom: 80px;
font-family: 'Quicksand', sans-serif;
  }

div {
display:block;


}

.coherence-principle {
background-color:#348fd4;

}


.signalling-principle {
background-color:#9DDFFF;

}

.redundancy-principle {
background-color:#5B51CC;
color:white;
}

最佳答案

我想我回答了我自己的问题。 我这样做了:

div {
display:block;
float:left;
width:100%;
}

float:left 消除了 DIV 之间的间距(边距)。 我必须在 float 之后将 100% 宽度添加到 DIV,否则存在空白。一定是 CSS 技巧?

关于html - DIV间距的困难,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25298508/

相关文章:

html - 内联和维护 textarea 和 div 之间的响应能力

css - 更正 Bootstrap 4 中导航栏链接的垂直对齐

javascript - 检测固定元素何时返回其原始位置

html - 下拉列表中的表格

html - 如何修复不同浏览器中的垂直间距变化?

CSS 居中文本列

css - 导航选项卡的高度相同

javascript - 用新颜色叠加图像

php - 如何用 PHP 将每个单词包装在 span 中?

jquery - Bootstrap 日历不显示,尽管一切都很好