作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Dart 的新手,需要创建动态dom结构。
目前,我使用dart_web_toolkit,但我缺少元素的位置函数。
您可以设置元素的宽度和高度,但不能设置位置(上,左)。
我在那儿想什么吗,或者有人可以给我解决方案?
编辑:
我有一个带有2个按钮的标签,我可以使用“setPixelSize”编辑按钮的大小
但是我需要类似“b1.setPosition”的东西,而且我找不到此方法来定位我的元素(在此示例按钮中)。
目前,它们只是相对于Label而言而已。
final el = querySelector('#body');
ui.Label rootLabel = new ui.Label();
rootLabel.addStyleName("root-style");
ui.RootPanel.get().addWidget(rootLabel, el);
final el1 = querySelector('.root-style');
ui.Button b1 = new ui.Button();
b1.text = "Button 1";
b1.addStyleName("b1");
b1.setPixelSize(30, 50);
ui.RootPanel.get().addWidget(b1, el1);
ui.Button b2 = new ui.Button();
b2.text = "Button 2";
b2.addStyleName("b2");
b1.setPixelSize(60,60);
ui.RootPanel.get().addWidget(b2, el1);
最佳答案
我只是觉得有点https://github.com/akserg/dart_web_toolkit/blob/afac7aac09e3bcd9d3e1f926815eb85040e46e07/lib/src/ui/button_base.dart的代码
似乎您应该通过调用Element
获得b1.getElement()
实例,该实例应允许访问所有元素属性,例如
b1.getElement().style
..position = 'absolute'
..top = '10px'
..left = '25px';
关于dart - 如何使用dart_web_toolkit设置元素位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27101139/
我是一名优秀的程序员,十分优秀!