DOCDGA
asked on
How can I dynamically change the width of a div tag based on its content
I have a table whose height and width change dynamically(as the records are added), and the table is placed inside a div tag, I would like to have the width of div tag enclosing the table also change dynamically with the width and height of the table.
ASKER
Hi Joshua,
Thanks a lot for replying to my query. When I tried setting width to auto, the width of div increased to encompass with of table, but , the width of the table inside div tag has also increased considerably. I do not want the width of the table to be increased further. Is there any round about to fix it..
Thanks a lot for replying to my query. When I tried setting width to auto, the width of div increased to encompass with of table, but , the width of the table inside div tag has also increased considerably. I do not want the width of the table to be increased further. Is there any round about to fix it..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Joshua,
Thanks again for your suggestions. I have tried adding margins as you mentioned, I have not got results any different. But I think I will go ahead with making width - auto instead of using javascript to get width changed dynamically.
Thanks again for your suggestions. I have tried adding margins as you mentioned, I have not got results any different. But I think I will go ahead with making width - auto instead of using javascript to get width changed dynamically.
no problem,
the margin left and right auto should be added to the table class not the div. That will make a difference. It would be easier if you could post the page somewhere so we can see it.
the margin left and right auto should be added to the table class not the div. That will make a difference. It would be easier if you could post the page somewhere so we can see it.
.divcss {
width: auto;
}
Does that not work?