Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
<div> line 1 <br> line 2 <br> line 3 <br> line 4 <br> ... ... </div
CSS:-
div { line-height: 20px; height: 80px; }
jQuery:
$('div').css('height', xxx)
我可以使用上面的 jQuery 代码或任何其他代码来使heightdiv 再次灵活,即适应内容而不是手动预定吗?
height
Apply auto, 的默认值height,以实现:
auto
$('div').css('height', 'auto')
在你的 CSS 文件中创建一个名为“flexible”的第二个类声明
.flexible{ height: auto !important; }
然后使用jQuery添加类
$('div').addClass('flexible');
http://jsfiddle.net/WQcHs/