css高度自适应怎么写

1.CSS样式中高度自适应怎么做CSS+DIV自适应高度布局,底部在底部2008-04-22 10:16ttps://wenwen.sogou.com/login/redirect?url=1%2FDTD%2Fxhtml1-transitional.dtd%22%3E" target="_blank">1/DTD/xhtml1-transitional.dtd">
">
无标题文档
#head { width:100%; text-align:center; background:#FF9400; height:100px; position:absolute; top:0;}
#head_height { height:100px;}
#middle { margin:20px;}
#foot { width:100%; text-align:center; background:#f00; height:60px; position:absolute; bottom:0;}
* html #foot { bottom:-1px;}
#foot_height { height:60px;}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
2.css,我有个div,需要给他设置一个最低高度,当超过最低高度时,高.className{ min-height:100px;
_height:100px;
}
注释:min-height 。zhidao最小属性的意思,当内容超出时div被撑大 。
下面是兼容IE6的 。IE浏览器当给顶DIV高度的时候且内容超出了该高度,那么DIV被撑大,而火狐和谷歌不会(可一个给个边框就能看出超出的效果回了) 。所以直接给height IE类浏览器是可以的 。但是火狐不行 。并且min-height这个样式IE6不认识 。所以用IE6HACK即_height只有IE6认识 。当超出时 也适应,没有超出时候是这个高度 。这样即实现了浏览器的答兼容性有实现了效果
3.DIV+CSS高度自适应你可以把左右的最外的DIV的margin-bottom值,设为-9999,然后再把padding-bottom的值设为:9999,这样,DIV就可以自由增大,而背景也不会被改动 。
left 溢出时隐藏
要随右边高度变化的DIV 用margin-bottom:-9999px, padding-bottom:9999px
其他的不用管,
关于LEFT要不要溢出隐藏,你可以试一下,我有点忘了 。
整的DIV可以溢出隐藏 。
有点蒙,如果不行,可能要用到JAVASCRIPT 。
4.css中图片如何自适应高度1. 在编写网页时,如果图片大小事先是未知的,如果图片过大的话,会影响的网页中其他块的结构
使用css可以将图片的大小调整到一个固定的值
<span style="font-size: 16px;">#mian img{
max-width:170px;
width:170px;
width:expression(document.body.clientWidth>170?"170px":"auto");
max-height:180px;
height:180px;
height:expression(document.body.clientWidth>180?"180px":"auto");
overflow:hidden;
}
</span>
2.html代码中
如果图片的大小是事先未知的,这样设置可以使,图像的大小固定,从而不影响网页中其他块的结构
<span style="font-size: 16px;"><div id = "maim">
<!--
在mian样式的块中img标签图片的大小会被固定在170px*180px
-->
<img src="http://www.xuexi88.com/zhishi/01.jpg">
</div>
</span>
【css高度自适应怎么写】

css高度自适应怎么写

文章插图