如何在不设置文本样式的情况下更改 Dojo 按钮的大小?
我是 Dojo 和 CSS 的新手,所以也许我在这里遗漏了一些明显的东西。
我有一个页面,其中有几个以编程方式创建的 Dijit 按钮,我想将其中一个按钮放大 - 保留文本并增加文本和按钮边缘之间的空间。我不想覆盖 .dijiButtonNode
的 CSS 来执行此操作,因为页面上还有其他不应更改的 Dijit 按钮。
我尝试将其添加到小部件声明中:
style: { padding: "1em" }
和 this:
class: "PaddedButton"
.PaddedButton
{
padding: 1em;
}
但由于 Dijit 按钮呈现为嵌套跨度,因此它填充了按钮周围的区域。
I'm new to Dojo and CSS, so maybe I'm missing something obvious here.
I have a page with several Dijit buttons that are created programmatically, and I want to make one of them bigger- leave the text alone and increase the space between the text and the edge of the button. I don't want to override the CSS for .dijiButtonNode
to do so because there are other Dijit buttons the page that shouldn't be altered.
I tried adding this to the widget declaration:
style: { padding: "1em" }
and this:
class: "PaddedButton"
.PaddedButton
{
padding: 1em;
}
but since Dijit buttons are rendered as nested spans it padded the area around the button instead.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 CSS 的最佳方法是使用浏览器调试工具之一(您应该已经在使用),例如 Firebug 或 Chrome 开发人员工具。您可以使用inspect_element轻松找到元素的DOM节点,然后直接编辑其CSS样式,直到它们执行您想要的操作。您还可以查看哪些 CSS 规则处于活动状态以及哪些规则被忽略或覆盖。
我在这里想出了一个工作示例:
http://jsfiddle.net/missingno/FrYdx/2/
重要部分如下CSS 选择器:
选择具有 dijitButtonNode 类的任何节点,该节点源自同时具有 paddedButton 和 dijitButton 类的节点。我不能只执行
.paddedButton .dijitButtonNode
因为这样规则最终会被更具体的选择器级联。The best way to work with CSS is using one of the browser debugging tools (that you should already be using) like Firebug or the Chrome developer tools. You can find an element's DOM node easily with inspect_element and then directly edit its CSS styles until they do what you want. You can also see what CSS rules are active and what are being ignored or overwritten.
I have come up with a working example here:
http://jsfiddle.net/missingno/FrYdx/2/
The important part is the following CSS selector:
This selects any node with class dijitButtonNode that descends from a node that has both of the paddedButton and dijitButton classes. I couldn't do just a
.paddedButton .dijitButtonNode
because then the rule would end up being cascaded by a more specific selector.