jquery 通过文本切换更改 div 大小
我有一些标题可以在鼠标单击时切换文本。如果切换的文本溢出当前 div 大小,我希望包含的 div 通过 jquery 增大大小...目前,文本仅与包含的 div 重叠。 :(
文本切换:
$(document).ready(function(){
$(".parents-toggle > div").click(function () {
$(".parents-toggle > div..iteminfo-toggle").not($(this).siblings()).slideUp();
$(this).siblings(".iteminfo-toggle").slideToggle();
});
});
html:
<div class="container_div">
<div class="parents-toggle">
<div class="itemheadings_toggle">Description</div>
<div class="iteminfo-toggle hidden">
text description
</div>
</div>
<div class="parents-toggle">
<div class="itemheadings_toggle">Description 2</div>
<div class="iteminfo-toggle hidden">
more text
</div>
</div>
</div>
div 容器
.container_div{ width: 400px; height:500px;border: 1px solid #000;float: left;position: relative;}
我尝试摆弄类似的东西,但显然这是一次非常失败的尝试!有人知道我能做什么吗?><;
$('.container_div')({adjustHeight: "dynamic" });
});
I have some headings that toggle text on mouse click. I would like the containing div to grow in size through jquery if the text toggled overflows the current div size...at the moment, the text just overlaps the containing div. :(
text toggle:
$(document).ready(function(){
$(".parents-toggle > div").click(function () {
$(".parents-toggle > div..iteminfo-toggle").not($(this).siblings()).slideUp();
$(this).siblings(".iteminfo-toggle").slideToggle();
});
});
the html:
<div class="container_div">
<div class="parents-toggle">
<div class="itemheadings_toggle">Description</div>
<div class="iteminfo-toggle hidden">
text description
</div>
</div>
<div class="parents-toggle">
<div class="itemheadings_toggle">Description 2</div>
<div class="iteminfo-toggle hidden">
more text
</div>
</div>
</div>
div container
.container_div{ width: 400px; height:500px;border: 1px solid #000;float: left;position: relative;}
I tried fiddling with something like this, but obviously it is a very failed attempt! Anyone have any ideas what I could do? ><;
$('.container_div')({adjustHeight: "dynamic" });
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 div 中使用自动换行。
这将解决您的问题。
div { 自动换行:换行 }
You can use word wrap in div.
This Will Solve Your Problem.
div { word-wrap: break-word }