惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - Smthhy

从公司管理到IT审计-网摘 如何为PDF文件添加书签 解决WCF传输大数据量时出错并提示:远程主机强迫关闭了一个现有的连接 ARCGIS DESKTOP 安装步骤 - Smthhy ms Sql server 中的getDate()函数使用方法总结 WCF客户端调用服务 出现套接字连接已中止...... C语言中time_t到.NET的转换与更改系统时间 Thread and Sync In C# (C#中的线程与同步) sql 跨服务器查询 js中event.x,event.clientX,event.offsetX区别 JS模拟出 getElementsByClassName 功能 - Smthhy jQuery对象与DOM对象之间的转换 - Smthhy - 博客园 语言代号一览表 收集 IE Flash10b.ocx加载项失败 解决 解决Aptana无高亮显示,无提示问题 WebBrowser 打印设置,打印预览,去页眉和页脚 ASP.NET State Service - Smthhy 尝试创建Web项目或打开位于URL“http ://localhost/WebApplication1”的Web 项目 C# winform 打印当前窗体 - Smthhy
div自适应高度 - Smthhy - 博客园
Smthhy · 2009-07-28 · via 博客园 - Smthhy

今天在做一个页面时,遇到一个div自适应高度的问题。即:如果div高度大于400就出现滚动条。如果其小于400时,自动缩小其高度,也就是有多高就显示高多,不会在小于400时,出现空白一片在那里。有开始用CSS控件。折磨了半天CSS搞不定的,只好改成了JS实现

 <div id="divSlo" >
 </div>

JS部份

<script language="javascript">
      var ctl=document.getElementById("divSlo");
      if(ctl.offsetHeight < 400)
     {
        ctl.style.height = ctl.offsetHeight+"px";
     }
    else
    {
     ctl.style.height = "400px";
     ctl.style.overflowY="auto";
    }     
    </script>