我怎样才能用Sass获取动态列表中的项目数量? [英] How could I get the number of items in a dynamic list with Sass?

查看:78
本文介绍了我怎样才能用Sass获取动态列表中的项目数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<ul>
  <li></li>
  <li></li>
  <li></li>
  ...
  <li></li>
</ul>

是否有可能通过Sass获得动态列表的最后一项的'n'值?
喜欢使用@each或@for语句计算'ul'中的项目数量?

Is it possible to get the 'n' value o the last item of a dinamic list with Sass? Like counting the number of items within the 'ul' using the @each or @for statements ?

推荐答案

否。仅Sass 编译为CSS。它永远不会发送到浏览器。它不知道DOM。

No. Sass only compiles to CSS. It is never sent to the browser. It has no knowledge of the DOM.

这篇关于我怎样才能用Sass获取动态列表中的项目数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆