捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
+SL4MR~t 关键在于:max-width:780px;以及下面那行。Wha2u6g;Tf[
[b]固定像素适应:[/b]
6u,p/\'O9g^9^3i
E];k;fD.NJ7f:H 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 />
%Q*P7V `z(X)o <title>css2.0 VS ie</title>
8o*C.cF&iD@ <style type="text/css"> hB&rm s s'T@)r3t T
<!-- G;m\J1^ mf
body {
}+muN/a suyE font-size: 12px;
N2yignN9I Px text-align: center; r5y/A L'z&[ c
margin: 0px;
)O0IwJ b padding: 0px;
;] b,RC,Bb+j.p_ }
&Be&P:P9LR #pic{ Q%Klu0iy!~_ z:s
  margin:0 auto;
6O6kLq;hRu}se"r   width:800px;
z,Bg&u @'N   padding:0; :g'e}W4` F
  border:1px solid #333; Q5MAmn,}*~
  }
m:qlmhx;iQ #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
}
h)|;O ["k --> _8`E1w4n;Yb'j+Y k
</style>
f8e,`[S ~"u </head>
Q#dS:|3l}0q <body>
/G ?d)Z4fZ;R]YU2K <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]>
1@0cU&Qgj/xF)[\r </div> VW0hzF
</body>
AA2U3`as U0G8L </html>
p5^ d1jwCw#} l~*v@i zz w
百分比适应:;P5Tf3rpyq,p(p-N.c'q
以下是引用片段:
D(Gp XL <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
2t2fk)u p,Hoe"~7m <html xmlns="http://www.w3.org/1999/xhtml";> kX)|(O$N
<head> x!F E^*Y-cw@
<meta http-equiv="Content-Type" c /> ;t!S+|;b m:ey0^P3w
<title>css2.0 VS ie</title>
p0\J6T^Vu <style type="text/css"> +s;Gb*Mli]O&S
<!--
8_O*Dl]4H2V(s%EG body {
$s,Q*W4aFBm font-size: 12px;
(W#g/naf7]O(UX0e5B text-align: center;
z\:^NE)x6}9h margin: 0px; ?%i O`kmTT*g+`w
padding: 0px;
,EuA0|v'n/} }
{7wc"uxWXm #pic{ L#R1[ q g
  margin:0 auto;
p UM|`R.@rW   width:800px;
g i5yY"BT   padding:0;
Vk%iX PQUqS   border:1px solid #333; 8Y5G'U N6m7X
  } 5Y rF|p6zh'n:DF T
#pic img{ w'SU;V H 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;
N9{&T![3B)m'd } It h5^0k(q\+h3x
--> /x6v^}\0ASU+^
</style> ] D|$nu ^N
</head>
)f;DO/f;yo qn <body>
s rD_%pK <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]>
&?m#C@?%P} </div> ~8L(U0TEf@
</body> %}bV%po.F)Fd
</html>

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


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