简体   繁体   中英

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

I have <span>title</span> inside of <div>... </div> .

title is binding dynamically. My problem is Title text is not showing full text because some <div> tags are created dynamically with Style="Width:150" .

If change div tag property width: auto , my Title text was displaying properly after editing div with property in developer tool.

How to change to as below to <div style=width:auto"..> ?

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

html标签

As it appears that you are using WebIX, I suggest changing width when it is generated.

According to the documentation for a data view, the code would be something like this:

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
    }   
});

If you have a static width, try setting the width to auto so it looks something like this:

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
    }   
});

If it doesn't work, could you post your entire code between webix.ui({ and }) ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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