- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
不确定这个问题是否属于这个讨论区,但我想知道在 Bourbon 中使用一些 mixins 的好处(如果有的话)。 Sass 的全部意义在于编写 DRY 代码,所以为什么要使用:
.div{
@import margin(10 10 10 10);
}
当你可以只使用普通的 css 时
.div{
margin: 10px;
}
最佳答案
Bourbon 的 margin mixin 进行四次测量并将它们映射到相应的单向属性。我从来都不喜欢单向 margin 属性,但根据 CSSWizardry它们具有以下优势:
The benefits are, as I see them:
- Easier to define vertical rhythm in one fell swoop.
- More confidence in (re)moving components if you know their margins all push in the same direction.
- Components and elements don’t have to necessarily live in a certain order if their margins aren’t dependent on adjoining sides.
- Not being concerned with collapsing margins means one less thing to worry about.
您给出的示例实际上将编译为以下 CSS:
SCSS
.div {
@import margin(10px 10px 10px 10px);
}
CSS
.div {
margin-top: 10px;
margin-right: 10px;
margin-bottom: 10px;
margin-left: 10px;
}
参见 Bourbon Docs有关方向属性混合的更多信息。
关于css - 干代码 : Sass Bourbon why use some mixins?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31619393/
我的主函数中有这两个函数。正如您将看到的,它们两者之间的唯一区别在于它们附加/编辑 html 的方式。我认为最好提出两个新函数,一个执行前半部分,另一个执行后半部分。我不确定这是否可以用 jQuery
我是编码新手,但一直在阅读有关 DRY - 不要重复自己的内容。 我有一个不适合 DRY 方法的 JavaScript if/else 语句,但我无法练习如何编写 JavaScript if/else
我的情况很简单: $("#check-in").dateDropper({ years_multiple: "10", format: "d-m-Y", minYear: "2
我想要一个方法在很多地方创建以下 json 字符串: {"daily_calendar":{"search":{"print_date":"2014-06-30"}}} 我有以下四行代码来制作散列:
我有这个正则表达式来检查字符串的格式是否为date, two or three dots ,date /\A(\d{1,2}-\d{1,2}-\d{4})...?(\d{1,2}-\d{1,2}-\d
我正在试验一些代码来创建我自己的 DOM 方法,但没有扩展实际的 DOM,类似于 jQuery 的工作方式。到目前为止,这是我的原型(prototype): function Lib( selecto
我是 Java 编程的新手。这里有人可以帮我让我的代码保持干燥吗? Button level01 = (Button) findViewById(R.id.level01); level01.setO
我正在通过一个数组来根据外部设置的状态应用不同的类。这就是我现在的做法,但我觉得我在重复自己很多次。有干燥机的方法吗?如果有帮助,类名可以是其他名称。 var children2 = Array.fr
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 4 年前。 Improve t
我正在尝试构建一个搜索页面,使用户能够找到满足特定阈值标准的模型的任何实例,并且在避免严重冗余代码方面遇到困难。我希望有更好的方法来做到这一点。这是一个稍微做作的示例,应该说明我正在尝试做什么,并在最
我是一名优秀的程序员,十分优秀!