繁体   English   中英

如何在Javascript中的html中动态更改div样式的div样式宽度?

[英]How to change div style width for dynamically div tag in html in Javascript?

我在<div>... </div>内有<span>title</span> <div>... </div>

标题是动态绑定的。 我的问题是标题文本没有显示全文,因为某些<div>标签是使用Style="Width:150"动态创建的。

如果更改div标签的属性width: auto ,则在开发人员工具中使用属性编辑div后,我的标题文本正确显示。

如何更改为以下<div style=width:auto"..>

template: function (o) {
     return "<div> <span>" + o.Title + "</span> </div>"
}

html标签

似乎您正在使用WebIX时,建议您在生成WebIX时更改其宽度。

根据数据视图的文档,代码将如下所示:

webix.ui({
    view:"dataview",
    container:"dataA",
    template: "<div class='webix_strong'>#title#</div> Year: #year#, rank: #rank#",
    data:...,
    datatype:"...",
    xCount:3, //the number of items in a row
    yCount:4, //the number of items in a column
    type:{
        width: 261,
        height: 90
    }   
});

如果您使用的是静态宽度,请尝试将width设置为auto这样看起来就像这样:

webix.ui({
    view:"dataview",
    container:"dataA",
    template: function (o) {
        return "<div> <span>" + o.Title + "</span> </div>"
    },
    data:...,
    datatype:"...",
    xCount:3, //the number of items in a row
    yCount:4, //the number of items in a column
    type:{
        width: 'auto',
        height: 90
    }   
});

如果不起作用,您可以将整个代码发布在webix.ui({})吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM