2013-02-22 40 views
0

我第一次使用SCSS(我已经使用LESS是过去)并使用Foundation框架。我使用语义网格mixins,但我发现它在Chrome检查器中查看它们时创建了大量的选择器。这是正常的吗?语义网格mixin创建大规模选择器

下面是一个例子。

.top_bar .information_for_agencies, .top_bar .registration, header[role="banner"] .branding, header[role="banner"] .branding .logo, header[role="banner"] .branding .tagline, header[role="banner"] div[role="navigation"], footer[role="contentinfo"] section, body.full_width div[role="main"] article[role="article"], body.full_width div[role="main"] article[role="article"] header img.top_masthead, body.full_width div[role="main"] article[role="article"] div.content img.top_left, body.full_width div[role="main"] article[role="article"] div.content img.top_right, body.full_width div[role="main"] article[role="article"] div.content figure.left_align, body.full_width div[role="main"] article[role="article"] div.content figure.right_align, body.full_width div[role="main"] article[role="article"] div.content figure.full_width, body.full_width div[role="main"] article[role="article"] footer img.bottom_masthead, body.two_columns div[role="main"] article[role="article"], body.two_columns div[role="main"] article[role="article"] header img.top_masthead, body.two_columns div[role="main"] article[role="article"] div.content img.top_left, body.two_columns div[role="main"] article[role="article"] div.content img.top_right, body.two_columns div[role="main"] article[role="article"] div.content figure.left_align, body.two_columns div[role="main"] article[role="article"] div.content figure.right_align, body.two_columns div[role="main"] article[role="article"] div.content figure.full_width, body.two_columns div[role="main"] article[role="article"] footer img.bottom_masthead, body.two_columns div[role="main"] aside[role="complementary"], body.three_columns div[role="main"] section.adverts, body.three_columns div[role="main"] article[role="article"], body.three_columns div[role="main"] article[role="article"] header img.top_masthead, body.three_columns div[role="main"] article[role="article"] div.content img.top_left, body.three_columns div[role="main"] article[role="article"] div.content img.top_right, body.three_columns div[role="main"] article[role="article"] div.content figure.left_align, body.three_columns div[role="main"] article[role="article"] div.content figure.right_align, body.three_columns div[role="main"] article[role="article"] div.content figure.full_width, body.three_columns div[role="main"] article[role="article"] footer img.bottom_masthead, body.three_columns div[role="main"] aside[role="complementary"], body.homepage div[role="main"] header h1, body.homepage div[role="main"] .hero_container .video_holder, body.homepage div[role="main"] .hero_container form, body.homepage div[role="main"] .hero_container form .personal_details label, body.homepage div[role="main"] .hero_container form .form_actions label, body.homepage div[role="main"] .hero_container form .form_actions .input_action, body.homepage div[role="main"] .reasons ul li, body.homepage div[role="main"] .testimonials h4, body.homepage div[role="main"] .testimonials ul blockquote, body.homepage div[role="main"] .register form, body.homepage div[role="main"] .register form .personal_details label, body.homepage div[role="main"] .register form .extra_info label { position: relative; min-height: 1px; padding: 0 15px; }

回答

2

我刚开始用最近与青菜的基础,我没有看到这一点。你的app.scss和_settings.scss和config.rb文件是什么样的? 您是否广泛使用@extend? 当你使用@extend时会发生什么,它会组合具有相似属性的选择器。 所以,如果您有:

.TestMe { 
    color: blue; 
    background: white; 
    margin: 10px; 
    width: 200px; } 

.hello { 
    @extend .TestMe 
    width: 100px; } 

将合并到这个CSS:

.TestMe, .hello { 
    color: blue; 
    background: white; 
    margin: 10px; 
    width: 200px; 
} 

.hello { 
    width: 100px; 
} 
+0

是的,你必须使用'@ extend'而非@include。前者不是SASS mixin,后者是。 你说你正在使用一个mixin,但是一个mixin不会创建这样的大规模选择器,但是它会导致在生成的文件中重复CSS的片段。 记住不同之处在于'@ extend'会扩展你的CSS选择器,正如@ keith73所描述的那样,而@ include将包含更多的CSS。 – Tim 2013-03-18 10:01:32

+1

如果您在这些地方没有自己使用'@ extend',那么请检查SCSS源以获取您正在使用的语义网格组合。这一定是使用'@ extend'的地方。所以当你认为你只是在做'@ include'的时候,你会不知不觉地做出大量的扩展。对此可能没有太多可以做的事情。 – Tim 2013-03-19 16:22:39