我有两个元素;即一个跨度,然后是一个div。跨度的内容应该具有长度为25到30个字符的最大值,并且div的内容可以是段落(并且这两个内容都是动态的)。我的客户想要的是将div的宽度设置为与跨度相同(不存在高度问题)。现在我使用JS实现了这一点,并且工作正常,我们可以使用CSS来做到这一点,这样我的生活将会变得更加轻松吗?根据前一跨度的宽度将动态宽度设置为div
感谢您的回复。
Tismon Varghese。
编辑:请参考下面
<div class="wrapper">
<span class="summary-headder"> Header Header Header Header Header </span>
<div class="summary-comment" style="width: 495px;">
test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment test comment
</div>
</div>
var summary_headder_width = $('.summary-headder').width();
$('.summary-comment').css('width', summary_headder_width + 'px');
我们可以看到代码做呢? – Naele
请参阅编辑部分 – user2869757