簡體   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