【问题标题】:How can we apply CSS stylings using Dart Language?我们如何使用 Dart 语言应用 CSS 样式?
【发布时间】:2013-08-21 09:17:36
【问题描述】:

我在通过 dart 应用 z-index 时遇到问题。这样做的正确方法是什么

var carousel = query(".carousel");
  var classList = [];
  carousel.children.forEach(
      (childElement) => childElement.classes.forEach(
         (className) => classList.add(className)
          ));
  for (var i = 0; i < classList.length; i++) {
    query(classList[i]).style.zIndex+=1; //Need to increment z-index value for 
                                           the child divs incrementally
  }

【问题讨论】:

    标签: z-index dart dart-webui dart-editor


    【解决方案1】:

    zIndex 是一个字符串,所以你不能直接增加它。

    你可以试试这个:

    var elem = query(".${classList[i]}");
    var newIndex = int.parse(elem.style.zIndex) + 1;
    elem.style.zIndex = "${newIndex}";
    

    【讨论】:

    • 我收到此控制台错误“异常:空对象没有 getter 'style'。”
    • 现在它得到了原生解析的格式异常。可能有什么问题?
    • 如果 zIndex 当前为空,代码将不起作用。首先将其初始化为“0”。
    猜你喜欢
    • 2023-02-24
    • 1970-01-01
    • 1970-01-01
    • 2010-12-19
    • 1970-01-01
    • 2023-02-13
    • 2016-12-14
    • 1970-01-01
    • 2011-02-09
    相关资源
    最近更新 更多