DAT GUI - 调整输入字段的大小 [英] DAT GUI - resizing input fields

查看:29
本文介绍了DAT GUI - 调整输入字段的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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屋!

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