DAT GUI - 调整输入字段的大小 [英] DAT GUI - resizing input fields
问题描述
我正在使用 Dat Gui 将菜单系统添加到我的应用程序中.
I am using Dat Gui to add a menu system into my application.
我的 html 代码中有这个:
I have this in my html code:
<script src="js/dat.gui.js"></script>
<link type="text/css" rel="stylesheet" href="js/dat-gui-style.css">
在 dat-gui-style.css 文件中我有这个:
and in the dat-gui-style.css file I have this:
.dg .c input[type=text] { width: 350px; }
这允许我为菜单系统中的输入字段设置自定义宽度.这几乎正是我想要实现的目标.但是,它仅适用于全局.我希望能够从我的 js 代码中动态控制我的输入字段的宽度属性.
This allows me to set a custom width for the input fields in the menu system. Which is almost exactly what I want to achieve. However, it only works globally. I wish to be able to control the width property for my input fields dynamically from within my js code.
我试过了:
guiTest = new dat.GUI({ autoPlace: false });
for (i = 0; i < theMenu.paramNames.length; i++)
{
guiTest.add(theMenu, theMenu.paramNames[i]);
guiTest.__controllers[0].domElement.style.width = '350px';
}
但它似乎不起作用.
有没有人知道如何做到这一点?
Has anyone got any idea how to do this?
推荐答案
如果 domElement
实际上是 Element
,那么你的语法应该是
If domElement
is actually an instance of Element
, then your syntax should be
guiTest.__controllers[0].domElement.style = 'width:350px';
这篇关于DAT GUI - 调整输入字段的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!