English 中文(简体)
如何简化SCSS边境半径米宁? 纽约总部 Sass Beginner
原标题:How to simplify this SCSS border radius Mixin? -- Sass Beginner
  • 时间:2011-11-14 00:33:56
  •  标签:
  • css
  • sass

我有以下的SCSS混合体,我大概会写出太多的多余:

@mixin radius($topleft, $topright: $topleft, $bottomright: $topleft, $bottomleft: $topleft) {

    -moz-border-radius-topleft:     $topleft;
    -moz-border-radius-topright:    $topright;
    -moz-border-radius-bottomright: $bottomright;
    -moz-border-radius-bottomleft:  $bottomleft;
    -webkit-border-radius:          $topleft $topright $bottomright $bottomleft;
    border-radius:                  $topleft $topright $bottomright $bottomleft;

}

指出这些论点可以具有单一价值,适用于所有方面,或所有4个用于定制。

最佳回答

您可将前四行合并为:

-moz-border-radius: $topleft $topright $bottomright $bottomleft;

除此之外,如果你想要保留能够确定不同优势的单独价值观并保持你的法典相互兼容的选项,那么,你再也无法减少法典。

<代码>moz-borer-radius

-moz-border-radius: { { length | percentage }  1 to 4 values | inherit } ;
问题回答

我同意你使用

@import "compass/css3";
@include border-radius(3px);

你可以明确地通过这样的价值观:

@mixin radius($radius) {

-webkit-border-radius: $radius;
border-radius: $radius;
}

类似的论点

.selector {
    @include radius(0 0 5px 5px);
}

Cheers!

如果你利用一名任务执行人(如贪 gr)把你的as子档案转换成 c子,你可以使用汽车设计师添加所有供应商的具体标签。

https://github.com/nDmitry/grunt-autoprefixer”rel=“nofollow”>https://github.com/nDmitry/grunt-autoprefixer

这样,你就能够摆脱混合,只写你想要的边境线。

border-radius: 3px 6px 6px 3px

而这种微薄的东西会把它改换给你,而你最终将产出与你的组合相同。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

Drop down background url in Safari Issue

selectBox.selectCSS { background: url(/Images/replacementSelectBackground.png) top left no-repeat height:auto; } I have an issue in Safari only where the image is not rendering on top ...

CSS specific for Safari

How do you target specifically safari in css with styles?

Aligning textarea in a form

Ive used the following css code to align my form elements: form { position:relative; } form input { position:absolute; left:11em; } However, the textarea element is not aligned correctly with the ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

CSS problem with page footer

I have defined my page footer in the css file as: #footer { position: absolute; height: 50px; text-align: center; background: #66CCCC; bottom: 0px; left: 0px; width: 100%; height: ...

热门标签