【问题标题】:margin-right not respecting my $gutter value in Susymargin-right 不尊重我在 Susy 中的 $gutter 值
【发布时间】:2013-06-26 20:25:21
【问题描述】:

由于某种原因,我的带有 .tile 样式的 div 不尊重我的 $gutter-width$column-width 值(我不确定是哪一个),并且这些 div 没有正确排列到 +susy-grid-background 参考网格。

在下面的屏幕截图中,您可以看到方形青色 div 不遵循 $columns-width$gutter-width 值。最重要的是,一排应该有 4 个这样的青色 div,但第 4 个被击倒到第二排。

为什么会这样?这是亚像素舍入问题吗?

_base.sass代码

/* Susy Settings */

$total-columns  : 5             
$column-width   : 4em            
$gutter-width   : 1em            
$grid-padding   : $gutter-width  

$desktop : 14

// Susy-grid-background override to draw out horizontal lines
=susy-grid-background       
  +grid-background($total-columns, $column-width, $gutter-width, $base-line-height, $gutter-width, $force-fluid: true)  

style.sass代码

@import compass
@import susy
@import normalize
@import base


$base-font-size: 18px
$base-line-height: 30px
+establish-baseline

ul
  background-color: rgb(111, 50%, 250)

li
  background: rgba(200,50,0,.2)
  text-align: right

a
  background: rgba(0,220,0,.2)
  display: block

h1
  +adjust-font-size-to(90px)
  +adjust-leading-to(4, 90px)
  +leader(2, 90px)
  background: rgba(0,20,200,.3)

h1#logo
  +adjust-font-size-to(30px)
  +adjust-leading-to(2, 30px)
  +leader(0, 30px)

h2
  +adjust-font-size-to(25px)
  +adjust-leading-to(1, 25px)
  background: rgba(250,250,0,.2)

p
  +leader(1)
  +trailer(1)
  background: rgba(0,220,0,.2)

.page, header, .pagenav, .main, .pagefoot
  +transition(all .3s ease)

.page                                
  +container($total-columns, $tablet, $desktop)
  +susy-grid-background


/* BREAKPOINTS */

+at-breakpoint($desktop)
  .page
    +susy-grid-background

  header
    +container
    +susy-grid-background
    background: rgba(250,0,0,.2)
    position: fixed
    left: 0
    right: 0

    h1#logo a
      +hide-text
      float: right
      +span-columns(2)
      background: rgba(200,10,250,.1)

    .pagenav
      clear: both
      float: right
      +span-columns(2)
      background: rgba(0,140,250,.3)

  .main
    +span-columns(12 omega)
    +leader(2)
    background: rgba(1,240,200,.3)

    .tile
      +span-columns(3, 12)
      +adjust-leading-to(9)
      +trailer(1)
      background: #0f6   

  .pagefoot
    background: rgba(45,0,120,.3)
    +span-columns(12,12)     

【问题讨论】:

标签: compass-sass susy-compass


【解决方案1】:

感谢 Eric,我被提到了一个他之前回答过的类似问题:

Weird misalignment in my Susy layout

Susy 网格(默认情况下)内部是流动的。所有流体网格 在浏览器端遭受一定数量的sub-pixel rounding。那 说,你主要看到的是亚像素四舍五入 背景网格,通常比实际更差 元素舍入。那是noted in the docs - 网格背景是 粗略的指南,而不是像素精确的标尺。

Susy还有isolation选项,可以用来停止亚像素 来自compounding 的错误。

所以对于这个特殊问题,我只是用+isolate-grid(3, 12) 替换了+span-columns(3,12),所以我最终的.tile sass 看起来像这样

.tile
  +isolate-grid(3, 12)
  +adjust-leading-to(9)
  +trailer(1)
  background: #0f6   

这就是结果

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-08
    • 1970-01-01
    相关资源
    最近更新 更多