捌玖网络工作室's Archiver

admin 发表于 2007-12-8 14:55

在DIV下图片自适应的解决方法

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。jM&G3U&z
关键在于:max-width:780px;以及下面那行。!z n0B~4W@M
[b]固定像素适应:[/b]
6i;YB,N2T%j{\7T)A b.n9@R{bLU5\
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>  以下是引用片段:V9V5r?)d`4Yn0p
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
]G-s1b:q <html xmlns="http://www.w3.org/1999/xhtml";> QJ.p@T S pcL dT$Y:F
<head> z x@v{+v5?i6b w
<meta http-equiv="Content-Type" c /> :^z/? `-|(m'z M-j
<title>css2.0 VS ie</title> *fP` ~D;W$?o,h
<style type="text/css"> r iY ~Xk,ee Z
<!--
J6x(~Q{n Bpe p body {
[o2gzfm font-size: 12px;
$Ts^\~k@ text-align: center;
"b#o@'`@*U margin: 0px;
GwB[8{ F8ft padding: 0px; Z6J^$T#S X9l8zR
}
D%[;g%PO_5u #pic{ 1YL%FD8]%U/oh
  margin:0 auto;
4O,K@+q,|W8B   width:800px;
)M+dV;W*[   padding:0;
A(g3y&T4Yv   border:1px solid #333;
'eQn/F3{   } u.IA Un {
#pic img{ m5g(]\9c0x5B6N9[6rN
    max-width:780px;
d/s X/S gY I5K+nJ width:expression(document.body.clientWidth > 780? "780px": "auto" ); ] c?5Yaf
border:1px dashed #000; (J-VR#M4}2e-a6zkIw
}
6rk;kY!H -->
7E"OQlv'kh+E </style> h0d:B tEzLg Qll
</head>
B BQb"D5c*efX[ <body>
+C [Xh3fe <div id="pic">
8~5w;m6N8f$jN <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> :M.Bg@E2g W
</div> b9dLv&X[8U%V^
</body> 2f~A\)[1Pw5F
</html>
Mm6[#b};Zh#H/v
hJ6a,KjT:i,Cv 百分比适应:
0RuC)tG OB_-bz/a 以下是引用片段:x(DK)KS&YO7@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
?6]4}M HOE <html xmlns="http://www.w3.org/1999/xhtml";>
6?m8J3[m[R <head> L8QEo H!r5[x
<meta http-equiv="Content-Type" c />
y8Me jkQCJ <title>css2.0 VS ie</title>
wxd ZOi7W <style type="text/css"> ?-X4L{6? a;g
<!-- UwLa6P~
body { tkiK8G^/V
font-size: 12px;
eH@P2PWA i text-align: center; 'r*^l.fwDx u3\
margin: 0px; -f)W&Zde v"bDe
padding: 0px; "x!Y(F6Q8wg0^{
} N.n0t-W @
#pic{
@l2tL)U   margin:0 auto; X!m `[aN)nP2{
  width:800px;
cZ&@!T+[}H*Z/is   padding:0; a!EG6C N? j i
  border:1px solid #333;
Pr c-DH;kmU   } ^ eKd7U_
#pic img{
]PzdLe k o     max-width:780px; 2K4EX~Fh7W
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
[i s y,w4_h7\ border:1px dashed #000;
^4bZd/P5e6Pl } g K"_Rn6n
-->
$g&?3hku!mv </style>
/r`u'B7r;a Z |Ar </head>
2bE Y eJ <body>
N._El7joy <div id="pic">
E6g H w,n9z3g <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
|%~;`r9p2_{ t'p~*Ti3? </div> $c.v mFW H1E,w
</body> ~N8E F,Vm7ld9@
</html>

页: [1]
【捌玖网络】已经运行:


Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.