捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
7T-x z$YQ~E 关键在于:max-width:780px;以及下面那行。2S"x b `~g }'T
[b]固定像素适应:[/b]$rX*|#B5{ Mu n

#Ga(q0L O^ 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>  以下是引用片段:y%x?/i}S%h,W
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
Mp%F`.R(s <html xmlns="http://www.w3.org/1999/xhtml";> (?SS4^&D F` c?&lys
<head> 7FJ0X)B*v#zwuZ _/f
<meta http-equiv="Content-Type" c />
"cu$R t9e <title>css2.0 VS ie</title> W:caP`QTEG*U
<style type="text/css"> 2|M? [X
<!--
2e.dyB:y body {
aM~D.w1C:CJ.Z;c font-size: 12px;
;t9xcK#|}.] C text-align: center;
1d}S@?n4lDdU:k margin: 0px;
ki;UH Q2f7I padding: 0px;
ufA"EP-Z*NpM*m }
,k)r cJxid.kG #pic{
H1a Byu j   margin:0 auto;
v.GK Z#m t"oeu   width:800px;
7z|7~Y[ H;bU}"p_   padding:0; ] v6k0gJ!V$_7y.cS
  border:1px solid #333;
!z&j1Ld9un   } .R/Wm`Q
#pic img{ } Hj$v)A5oK
    max-width:780px; "wD1S%A]n5R Q0q
width:expression(document.body.clientWidth > 780? "780px": "auto" );
UW ^i1d7l[v^Yg border:1px dashed #000;
Td [QU9K|.{s/n ho } u6m9O"L3m
-->
;Y|1M-b8[ </style> Q(x6{j9K;R
</head>
U.d!GZ9DDm <body> 4L0VvV#w;Ov N9s!Qk
<div id="pic">
[`ns$AvH)z <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> $EI*_:`c8z$F'\*S
</div>
u$cS s fg8OY </body> Dx r+|+["Y|
</html>
MW@2` l.F-jY(dp
'cN-zuV\diI@-? 百分比适应:4Sj#U/L0k\kv[{
以下是引用片段:
C/Cm'd,j x2} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
1Z7f,A$q`"NE,S <html xmlns="http://www.w3.org/1999/xhtml";> 8lX(eHm roR
<head>
)W9}*[:Xs|M:C <meta http-equiv="Content-Type" c /> 2IA/?-F0wN/w`A
<title>css2.0 VS ie</title>
,n`V5e/E-c%[K <style type="text/css">
)AB"bI)^(r'E <!-- p\'FJ+W
body {
Q u e.{{ font-size: 12px; W M(^PhiV
text-align: center; nk4ovf[y9T$wN
margin: 0px; [b@|bJ
padding: 0px; )beG9G.e"w
}
q`6\J3?+E+D Z #pic{ \@a(or&J{)?!G
  margin:0 auto; *m.]1y}jtBF;u
  width:800px;
YB/[6oh"q!w:eue   padding:0;
3n%tkx2m(^0r n_6Zc   border:1px solid #333; -e ^Jv0}3`6vO"B
  } b%Z6S,QT S"d a
#pic img{
LAv+t$U}     max-width:780px;
0`tn(b4E? width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
&j/L9C BW|M border:1px dashed #000;
;G3w-f9j!RM;L } va7RmX
--> )eF%[]1x6{1{
</style> U!s)l1_ Sx#f
</head>
*r*uWW7p@9uk <body>
'U2RICS)lu;y3l <div id="pic">
G&k$j3n7`6g J <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
-R-PWuKY/i </div> fBfts/ab7~6Ng*g
</body>
8Y P$A(b EKj,V </html>

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


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