捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。!T*PN.iE*q3L
关键在于:max-width:780px;以及下面那行。M"qr%S.AyFGVdh
[b]固定像素适应:[/b]
kAA7r gh7O f 5M KZ6ZU
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>  以下是引用片段:p VC9s7Ro
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> FO$_ lS ? TS
<html xmlns="http://www.w3.org/1999/xhtml";>
"xe^.c B <head>
~/wvz Yp&a8a <meta http-equiv="Content-Type" c /> f7c*r2} g/d ]n
<title>css2.0 VS ie</title> w;r b}4M9q;C
<style type="text/css">
@&p l \-f+iP <!--
:E Z}&n6iA D2Bl body {
/dhfj8z)OUC)v*nY font-size: 12px;
x%bK-}`@1y*c text-align: center; 8y H6](_3Z;ls-]1a
margin: 0px; h%PiS;g T(e/_b j4L
padding: 0px; *E\lj r|jS
}
|;?O4}0I l #pic{
*? n\D'w Uoi   margin:0 auto; !NI4n$W.p^:vG4v)i
  width:800px; 9o,GW~?'g
  padding:0; 3yBpz^%i*D9z
  border:1px solid #333; *as'eGo \
  }
? C#ebI4D SS'U ` #pic img{ ]#Y~$@'{z1lS
    max-width:780px; ^*u&A.OR
width:expression(document.body.clientWidth > 780? "780px": "auto" );
/IOE&T&P#CM border:1px dashed #000; %b j?R.VQw
} #RG3{Zb!Y!E|R
-->
N P^Q_1pJ+a </style> +xj.jb:@{)y
</head>
"D2C"D/uo~WA <body> k*h dgb)SLY-@,e
<div id="pic"> @t"mbC'kN
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> G7mOSsj H`
</div>
s9Fh jmj}yB </body> Mny T K%b{Y_#b
</html>
}u(]:Z8Ai ct,E$K2O4of*c a5?$R
百分比适应:
5W _5w.~R W7`_ 以下是引用片段::W2~#cgZ'i0e(h
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
9m kCtS <html xmlns="http://www.w3.org/1999/xhtml";>
,@3QelSy <head>
1?^|Qc7@]7Q <meta http-equiv="Content-Type" c /> x,q^ q-o2B@.b&E
<title>css2.0 VS ie</title> |-Y;~7F(N hyQ
<style type="text/css"> (~IG s bF |j
<!-- |2i8} P4cyxf?
body {
9[:_c |.R2vT font-size: 12px; dbB!\'N
text-align: center;
NtoA3@m9Tgt margin: 0px; rMA}.M
padding: 0px;
sF[z:Z)IB }
_ c C ta{g;Y#pV #pic{
u5Hl4_kk;A/~   margin:0 auto;
P#YE#Gx   width:800px; 9T-D(@'m"V\4d\]
  padding:0; &GW_Y1Vf
  border:1px solid #333;
b{k_ dP'{ c#i7B   }
8Y np"Dw #pic img{ 8gJx-lE%]:PK_Ae
    max-width:780px; v9v6djIm^p6~
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); n5cd h+Fzt
border:1px dashed #000; @I @ } s}
} w0ey%Y(sm:zK5FYNO
-->
VeDeh6VuXkW </style> $WV_{ o'N)?R5?
</head>
:riDwO#VX <body>
6|nN`7Y3O |/o <div id="pic">
/|7OQk T <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
%R T"q Sr H </div>
F_;ZX5G </body>
n!b'G%pc/V.hns7| </html>

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


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