捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
*Rk!YV%Bn 关键在于:max-width:780px;以及下面那行。
b.}~k5R1?-Kx$l [b]固定像素适应:[/b]
$rYK7wC7LQ
p y8l7]t 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>  以下是引用片段:
"\e7S p,P <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
Y@7~ \hb <html xmlns="http://www.w3.org/1999/xhtml";>
M]5^/R ]d:K <head>
*J4l B.r,W)W.t <meta http-equiv="Content-Type" c />
-T _7p G6I`VzH <title>css2.0 VS ie</title> .S-|;hP2t\ C"}:AM5m2EI
<style type="text/css"> 9[2^1Px sh#}
<!-- :r4Q ^ @re8^j
body {
#K$s1GAV font-size: 12px; #D([ o!e@3krm'g^
text-align: center;
+I] V9o h$v_f margin: 0px; a#\VOz*y0g8~!}I
padding: 0px;
3X\9k s[Fz,z }
uG,T(KK*H #pic{
+E'`4e&rbo$M&k   margin:0 auto;
0Cgb'A;X   width:800px; 5H]"sD J!|6xfD
  padding:0; \Nl)UoX
  border:1px solid #333;
!j]i9z YY   } "v/{*PoF)HT
#pic img{
6a0O KWG&~k1Zn@     max-width:780px;
9t1D;oS-a;q ? width:expression(document.body.clientWidth > 780? "780px": "auto" );
f2\ X"AI"? border:1px dashed #000; }8IX K)il
}
q\6HC7owL --> 7KLMZ)Zv+w.b
</style> d8^.EI6gXx(T
</head>
/I1F.m4x&?C"B <body> ?iE7L"s:U-@K+g
<div id="pic">
'G0i3N3vY.A <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
3Yz@K3V7|fBA </div>
B3vu/Qx(w,d U </body> t5F6`,_%e]
</html>
w k%SVpxM eH
q&?'JA)dC a$k8K 百分比适应:
$SgY/Z}j 以下是引用片段:BY*\:n6ujD*f:I\
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
OR.BU$A#A { <html xmlns="http://www.w3.org/1999/xhtml";> 4K&_2N d*z.}k
<head> (u!DG\&q%i!pw
<meta http-equiv="Content-Type" c />
T2a.[a{}.S <title>css2.0 VS ie</title>
g:x.Qi1l$?&h <style type="text/css"> *@%U,d5s/}/t
<!--
;Z)Y1S4M$P body {
"g(J.bT+y}aC font-size: 12px;
Ulq{$O'Ci0aM0m.VU9U text-align: center;
R/H_1b%@+k ~ i margin: 0px;
p|-a3~To n^JPi%z padding: 0px; $B.Vh&X^.`,t8}2m+L
}
pW1dF0l,^ #pic{
'tY rb6^9|   margin:0 auto;
!R8G H{$@![?C   width:800px; /X@4INKC8w
  padding:0;
^%??O/K$O/IF   border:1px solid #333;
$poi+~;_$CQ&i[ j   }
0O;T,y*Ofw?F #pic img{
3]8I:H Vi     max-width:780px;
%N5I3P_.z width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
RT'@ Q ~`:a2n r border:1px dashed #000;
1Av Au$Q7py } 0{"a;y \9IxZ
-->
NWS/Du]/? </style> BOtb;~
</head> (fES*^6V#hA'x6JQ
<body>
T3s-iZ\4m <div id="pic"> Kf8z }l&o/t5s#`
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
OtL$zi)VrLkf+j </div> 7ge,N?#Wd-C*^.S2e
</body> &aX6iJBo/}W
</html>

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


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