在SASS中,有没有办法定义#{$site_name}-product-list? (使用变量的 ID 名称)

发布于 2024-11-09 06:35:15 字数 476 浏览 0 评论 0原文

例如,如果

$site_namecarsboats,那么类似的东西

#{$site_name}-product-list
  background: #ffc

在SASS中可能会变成

#cars-product-list
  background: #ffc        // this is still SASS, but the CSS will be like this

这样吗? (我们没有使用 SCSS,因此正在寻找 SASS 的解决方案,但如果 SCSS 可以做到这一点,您可以将其放在评论中吗?谢谢。)(HAML 可以通过使用 %div{:id => 来做到这一点; "#{site_name}-product-list"},但也需要 SASS 才能使用)

For example, if

$site_name is cars, or boats, then something like

#{$site_name}-product-list
  background: #ffc

which will become

#cars-product-list
  background: #ffc        // this is still SASS, but the CSS will be like this

is it possible in SASS? (we are not using SCSS, so looking for a solution for SASS, but if SCSS can do it, can you put that in a comment. thanks.) (HAML can do this by using %div{:id => "#{site_name}-product-list"}, but need the SASS to work with it as well)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜心 2024-11-16 06:35:15

好的,我找到了答案:

http://sass-lang.com/ docs/yardoc/file.SASS_REFERENCE.html#interpolation_

所以它可能

$site_name: cars

  ...

##{$site_name}-product-list
  background: #ffc

会变成

#cars-product-list
  background: #ffc

虽然,有一些用户声称使用这样的 ID 或类名来帮助提高搜索引擎排名是没有用的...他们声称仅使用 #product-list 效果是 100% - 但我的问题仍然是 - 我们如何确定 Google、Yahoo、Bing 的所有信息?那?今天适用的内容可能不适用于两个月后? (他们可以随时更改算法)

此外,还需要对 HAML 和 SASS 文件执行此操作(对于很多元素,而不仅仅是 1 或 2 个 - HAML 可能大约 20 个,SASS 可能大约 20 个) (单数或复数)),所以我想知道这是否值得付出努力。

Ok, I found the answer:

http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#interpolation_

so it can be

$site_name: cars

  ...

##{$site_name}-product-list
  background: #ffc

which will become

#cars-product-list
  background: #ffc

although, there are some users who claim that it is useless to use an ID or class names like that to help boost the search engine rankings... such they claim that it is 100% as good to just use #product-list -- but my question remain -- how can we be sure about all of Google, Yahoo, Bing, do that? And what applies today may not apply 2 months later? (they can change the algorithm any time)

Also, this needs to be done for both the HAML as well as for the SASS files (for a lot of elements, not just 1 or 2 -- probably around 20 for HAML and 20 for SASS (either singular or plural)), so I wonder if it is worth the effort.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文