开发者

Is there a reason why SASS, a CSS generator, needs to reject lines such as margin:10px ? (no space after colon)

开发者 https://www.devze.com 2023-01-03 05:48 出处:网络
I need to change all the CSS into SASS... and find that margin:10px working in CSS and failing in SASS somewhat disturbing...

I need to change all the CSS into SASS... and find that

margin:10px

working in CSS and failing in SASS somewhat disturbing...

It is easy to miss one and you don't what you are missing (what is not working in the final CSS but you don't know)

Pretty much I am grep for /:\S/开发者_开发知识库 (colon by followed by a non-whitespace) to see if there are such cases, using TextMate (a Mac text editor)... but those a:hover also shows up as well.


In Sass you can define nested selectors, and these can have pseudoclasses such as :hover. It doesn't see your margin as an attribute but as another element with a pseudoclass.

.stylin
  display: block
  margin:10px
  a:hover
    color: red

The above will recognize display: block correctly, but it will see margin:10px and a:hover as the same kind of pattern.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号