在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。K3Z9r$i Z$h7E)[关键在于:max-width:780px;以及下面那行。
[b]固定像素适应:[/b]j m*Y,fR%w'F
l bt!f,?f0T g
dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; BORDER-BOTTOM: #cccccc 1px dotted" cellSpacing=0 cellPadding=6 width="95%" align=center border=0> 以下是引用片段:a1OLVQ%Y2K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 9n*Vl6}1uP.uZ
<html xmlns="http://www.w3.org/1999/xhtml";> MiM#v\2k0t m
<head>
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title> [/y4@`oW@9i\F/L
<style type="text/css">
<!--
body { /Bg]Hci
font-size: 12px;
text-align: center;
margin: 0px;
padding: 0px;
}
#pic{
margin:0 auto; A[{b/vd@s-\
width:800px; 3i j1l9F D]t,h:[
padding:0;
border:1px solid #333;
} dp@uHZ
#pic img{ 9v qq{*NJqD^
max-width:780px; 1w1|8cRUf.xp r"u
width:expression(document.body.clientWidth > 780? "780px": "auto" ); -U N?8T(H5X
border:1px dashed #000;
} k['Xbr
--> !a,w!QB'lD
</style> r1w(e$\f.d ~V
</head> #K.g)U)G9XIP
<body>
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div>
</body>
</html> k8]sU"d$A2Q.P1F
百分比适应:
以下是引用片段:}$EwU$J9r2Re
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";> -[?8|!k3M"?-s+I Dwze
<head> -n"\w/|?;FtHT
<meta http-equiv="Content-Type" c /> %E6|%DZraW/z
<title>css2.0 VS ie</title> 1vr9`8^C
<style type="text/css">
<!-- u F)X*J3ul{
body {
font-size: 12px;
text-align: center;
margin: 0px; |6k)y.zH
padding: 0px;
} ~-W%im b1Ba,L
#pic{
margin:0 auto;
width:800px;
padding:0; Y&tv n4HT+w;pe
border:1px solid #333;
} &bP(I,Uq2P(D
#pic img{
max-width:780px; IWVpUXP
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000;
}
-->
</style> &qJ5sCN/R&b
</head> yG&@\K d
<body>
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> U/m^*~Yj
</body>
</html>
页:
[1]