在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。关键在于:max-width:780px;以及下面那行。Wha2u6g;Tf[
[b]固定像素适应:[/b]
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> 以下是引用片段:!vzqO?9` l
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> S_1y&D?
<html xmlns="http://www.w3.org/1999/xhtml";> 1VQ"IY+k|
<head> {.WZv_Q
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title>
<style type="text/css"> hB&rmss'T@)r3t T
<!-- G;m\J1^ mf
body {
font-size: 12px;
text-align: center; r5y/A L'z&[c
margin: 0px;
padding: 0px;
}
#pic{ Q%Klu0iy!~_ z:s
margin:0 auto;
width:800px;
padding:0; :g'e}W4`F
border:1px solid #333; Q5MAmn,}*~
}
#pic img{ 5?~Ko;Q[+U|
max-width:780px; 7E.yO2dC$y5Wco
width:expression(document.body.clientWidth > 780? "780px": "auto" ); e(\Q.lx]$L
border:1px dashed #000; gk J#p2@ GUL k&P&L
}
--> _8` E1w4n;Yb'j+Y k
</style>
</head>
<body>
<div id="pic"> *`0d$UC lR4u
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> VW0hzF
</body>
</html>
l~*v@i zz w
百分比适应:;P5Tf3rpyq,p(p-N.c'q
以下是引用片段:
<!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";> kX)|(O$N
<head> x!FE^*Y-c w@
<meta http-equiv="Content-Type" c /> ;t!S+|;b m:ey0^P3w
<title>css2.0 VS ie</title>
<style type="text/css"> +s;Gb*Mli]O&S
<!--
body {
font-size: 12px;
text-align: center;
margin: 0px; ?%i O`kmTT*g+`w
padding: 0px;
}
#pic{ L#R1[ q g
margin:0 auto;
width:800px;
padding:0;
border:1px solid #333; 8Y5G'U N6m7X
} 5Y rF| p6zh'n:DFT
#pic img{ w'SU;VH yC
max-width:780px; P ~}!pv
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); bTEkm)}0o5`_
border:1px dashed #000;
} Ith5^0k(q\+h3x
--> /x6v^}\0ASU+^
</style> ] D|$nu^N
</head>
<body>
<div id="pic"> O1t#}XG
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> ~8L(U0TEf@
</body> %}bV%po.F)Fd
</html>
页:
[1]