margin-right不尊重我在Susy的$ gutter值

时间:2013-05-28 15:53:12

标签: compass-sass susy-compass

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

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

为什么会这样?这是一个子像素舍入问题吗?

enter image description here

_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)     

1 个答案:

答案 0 :(得分:0)

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

Weird misalignment in my Susy layout

  

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

     

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

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

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

这是结果

enter image description here