Susy 2:具有流动主要内容区域的固定宽度侧边栏

2023-08-01前端开发问题
3

本文介绍了Susy 2:具有流动主要内容区域的固定宽度侧边栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

使用 Susy 2(候选发布版),我试图弄清楚如何使用固定宽度的侧边栏创建简单的流体布局 - 无论是左侧还是右侧 - 我很高兴使用第一个和最后一个关键字.谁能给我任何关于如何在 Susy 2 中执行此操作的指示?

Using Susy 2 (release candidate), I'm trying to figure out how to create a simple fluid layout with a fixed width sidebar - either left position or right - I'm happy using the first and last keywords. Can anyone give me any pointers on how to do this within Susy 2?

谢谢!

推荐答案

有几种方法可以混合固定/流体布局,具体取决于您自己的具体情况.

There are a few ways to mix fixed/fluid layouts, depending on your own specific case.

  1. 隔离侧边栏.

  1. Isolate the sidebar.

浮动隔离是保持浮动相互独立的一种很酷的方法.

Float isolation is a cool a way of keeping floats independent from each other.

.side {
  @include span(3 static isolate);
}

.main {
  @include full;
  padding-left: span(3 static wide);
}

// or...

.main {
  margin-left: span(3 static wide);
}

span(3 static) 将跨越 3 列,使用您的 column-width 设置/单位.添加 isolate 将设置负右边距,以防止占用水平空间.添加 wide 将在该宽度中包含一个额外的装订线.你也可以使用像 200px 这样的任意宽度.这取决于你.

span(3 static) will span 3-columns, using your column-width setting/units. Adding isolate will set negative right margins, to keep it from taking horizontal space. Adding wide, will include an extra gutter in that width. You could also use arbitrary widths like 200px instead. It's up to you.

从流程中完全移除侧边栏.

Remove the sidebar from the flow entirely.

如果从流程中删除侧边栏是安全的,有时最简单的方法是绝对定位它,并为主要内容添加相等的填充.使用 Susy 2,可能看起来像这样:

If it's safe to remove the sidebar from the flow, it is sometimes simplest to position it absolutely, and add equal padding to the main content. Using Susy 2, that could look something like this:

.side {
  position: absolute;
  left: 0;
  top: 0;
  width: span(3 static);
}

.main {
  padding-left: span(3 static wide);
}

  • 使用布局上下文技巧.

  • Use a layout-context hack.

    还有一些方法可以创建一个新的布局上下文来填充浮动后的剩余空间.其中最简单的是 overflow: hidden;

    There are also ways to create a new layout context that will fill the remaining space after a float. The simplest of those is overflow: hidden;

    .side {
      @include span(3 static);
    }
    
    .main {
      overflow: hidden;
    }
    

    这样做的缺点是如果您出于任何原因需要溢出.还有其他技术,也有其他的缺点,比如这个:

    The downside of that is if you need to overflow for any reason. There are other techniques, that have other hackey downsides, like this one:

    .main {
      display: table-cell;
      vertical-align: top;
      width: 10000px;
    }
    

  • 这篇关于Susy 2:具有流动主要内容区域的固定宽度侧边栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

    The End

    相关推荐

    layui 单选框、复选框、下拉菜单不显示问题如何解决?
    1. 如果是ajax嵌套了 页面, 请确保 只有最外层的页面引入了layui.css 和 layui.js ,内层页面 切记不要再次引入 2. 具体代码如下 layui.use(['form', 'upload'], function(){ var form = layui.form; form.render(); // 加入这一句});...
    2024-11-09 前端开发问题
    313

    layui要如何改变时间日历布局大小?
    问题描述 我想改变layui时间日历布局大小,这个要怎么操作呢? 解决办法 可以用css样式对时间日历进行重新布局,具体代码如下: !DOCTYPE htmlhtmlheadmeta charset="UTF-8"title/titlelink rel="stylesheet" href="../../layui/css/layui.css" /style#test-...
    2024-10-24 前端开发问题
    271

    缩放背景图像以适合 ie8 窗口
    Scale background image to fit ie8 window(缩放背景图像以适合 ie8 窗口)...
    2024-04-19 前端开发问题
    11

    IE7 (IETEster) 中的@fontface 无法正常工作
    @fontface in IE7 (IETEster) not working properly(IE7 (IETEster) 中的@fontface 无法正常工作)...
    2024-04-19 前端开发问题
    9

    Safari 5.1 打破 CSS 表格单元格间距
    Safari 5.1 breaks CSS table cell spacing(Safari 5.1 打破 CSS 表格单元格间距)...
    2024-04-19 前端开发问题
    3

    如何使用 `on()` 委托 `hover()` 函数
    How to delegate `hover()` function by using `on()`(如何使用 `on()` 委托 `hover()` 函数)...
    2024-04-19 前端开发问题
    17