Make Div as wide as it needs to be

后端 未结 5 577
我在风中等你
我在风中等你 2021-01-01 21:47

To explain my problem, I\'m trying to make a div wide enough to accommodate a dynamically generated title without wrapping it, but the div also has other content, which I wa

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 22:33

    If i understand your correctly you can easily set the same width for yours text as for yours title using JS or jQuery, for ex:

    $('.text').width($('.title').width())
    

    and run it at jQuery(document).ready or by event if you add it dynamically

提交回复
热议问题