【问题标题】:Create square divs using susy-grid使用 susy-grid 创建方形 div
【发布时间】:2014-06-08 04:32:59
【问题描述】:

是否可以让@include span(3 of 12) 以像素而不是 % 为单位返回?

我正在尝试创建方形元素,我希望这个元素的高度等于它的宽度。

.myElement {
  width: span(3 of 12)
  height: span(3 of 12)
}

当然这会导致高度是一个%,它实际上是它的父容器的一个%,所以它不等于宽度!有什么想法吗?

【问题讨论】:

标签: sass susy-compass susy-sass


【解决方案1】:

并非不可能——只是很棘手(如果你想要一个流畅的正方形)。

// Static width/height is simple
.square-a {
  @include span(2 static);
  height: span(2 static);
}

// Fluid takes a bit more work
.square-b {
  @include span(2);
  height: 0;
  // %-Padding is always relative to parent width
  padding-top: span(2);
  position: relative;

  // Inner element positioned to fit space
  span {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }
}

这是demo of both

【讨论】:

    猜你喜欢
    • 2016-10-14
    • 1970-01-01
    • 2017-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-17
    • 1970-01-01
    相关资源
    最近更新 更多