css - 如何使用 foundation 4 完成 Bootstrap 网格系统对其 ".col-xs-"或 "smallgrid"的操作?

标签 css twitter-bootstrap twitter-bootstrap-3 zurb-foundation

我希望在没有框架的情况下使用自定义 CSS 构建一个网站,只是为了提高我对 CSS 的控制力。我希望我的整个站点保留其布局,并且无论使用什么设备都可以看到。 Foundation 用它的“smallgrid”来做,用“.col-xs-” Bootstrap 。如果没有框架,我该怎么做?

最佳答案

Foundation 和 Bootstrap 都使用相同的方式为您提供灵活的网格:它们以百分比固定每个可能的列宽,并使用媒体查询在移动/平板电脑/桌面网格之间切换(Foundation 为 smallmediumlargexssmmdlg 用于 Bootstrap。

查看这些链接以了解更多相关信息:

Bootstrap 3:

// Mobile first : Bootstrap display the content with -xs columns
.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6,
.col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11 {
    float: left;
}
.col-xs-12 { width: 100%; }
.col-xs-11 { width: 91.66666666666666%; }
.col-xs-10 { width: 83.33333333333334%; }
.col-xs-9  { width: 75%; }
.col-xs-8  { width: 66.66666666666666%; }
.col-xs-7  { width: 58.333333333333336%; }
.col-xs-6  { width: 50%; }
.col-xs-5  { width: 41.66666666666667%; }
.col-xs-4  { width: 33.33333333333333%; }
.col-xs-3  { width: 25%; }
.col-xs-2  { width: 16.666666666666664%; }
.col-xs-1  { width: 8.333333333333332%; }

// if we reach 768px, let's use -sm columns
@media (min-width: 768px) {
  .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6,
  .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11 {
      float: left;
  }
  .col-sm-12 { width: 100%; }
  .col-sm-11 { width: 91.66666666666666%; }
  ...
}
// ... etc with -md and -lg columns

基础 5:

// Mobile first : Foundation display the content with -small columns
@media only screen {
    .column,
    .columns {
      position: relative;
      padding-left: 0.9375rem;
      padding-right: 0.9375rem;
      float: left; }
    .small-1 { width: 8.33333%; }
    .small-2 {width: 16.66667%; }
    .small-3 { width: 25%; }
    .small-4 { width: 33.33333%; }
    .small-5 { width: 41.66667%; }
    .small-6 { width: 50%; }
    .small-7 { width: 58.33333%; }
    .small-8 { width: 66.66667%; }
    .small-9 { width: 75%; }
    .small-10 { width: 83.33333%; }
    .small-11 { width: 91.66667%; }
    .small-12 { width: 100%; }
}

// If we reach 40.063em, let's use -medium columns
@media only screen and (min-width: 40.063em) {
    .column,
    .columns {
      position: relative;
      padding-left: 0.9375rem;
      padding-right: 0.9375rem;
      float: left; }
    .medium-1 { width: 8.33333%; }
    .medium-2 {width: 16.66667%; }
    ...
}

// ...etc with -large columns

关于css - 如何使用 foundation 4 完成 Bootstrap 网格系统对其 ".col-xs-"或 "smallgrid"的操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20333666/

相关文章:

html - Bootstrap 4 卡图像不对齐

html - Bootstrap 部分不会出现在移动浏览器中,但会出现在桌面版本中

html - 属性溢出不起作用(仅在 div 中设置滚动)

twitter-bootstrap - CSS 使圆 Angular 成为具有百分比半径的圆

css - 引导按钮

css - Masonry 和 Bootstrap 3 - 3 个不同大小的列

python - 使用 Flask 在另一个页面中显示选定的表单项

html - 删除 WordPress 主题上的边距

html - 我想用 css 更改 div 右侧或左侧的外观

c# - 在 Bootstrap 中对齐列。第一个瓷砖需要大