调整div大小以适合具有最大高度的内容 [英] Resizing a div to fit content with maximum height

查看:107
本文介绍了调整div大小以适合具有最大高度的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个动态内容的div。当内容加载在div我想要div调整大小以适应内容。但我想这个调整大小有一个最大的高度。如果内容需要超过这个最大高度,我想要一个滚动条。



我在这里搜索过的问题,但没有找到我在找什么(除了一个问题提出者回答说他自己想出来的)。我读过我可以用jquery做,但我很新的,但我做了演示,调整一个div,改变类和类似的东西,但我真的在亏损如何实现我在找什么。

$

   已尝试找到解决方案。

div {height:auto; overflow:scroll; max-height:200px;}


I have a div with dynamic content. When the content loads in the div I want the div to resize to fit the content. But I want this resizing to have a maximum height. If the content needs more than this maximum height I'd like there to be a scrollbar.

I've searched through the questions here but haven't been able to find what I'm looking for (apart from one where the question-asker replied saying he'd figured it out himself). I've read I can do it with jquery but I'm pretty new to that, but I did go through the demos of resizing a div, and changing classes and stuff like that but I'm really at a loss on how to implement what I'm looking for. I have tried to find a solution to this, so please be gentle.

解决方案

 div {height:auto;overflow:scroll;max-height:200px;}

这篇关于调整div大小以适合具有最大高度的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆