捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
X+R Y;Z4D[A 关键在于:max-width:780px;以及下面那行。5\ WBvJ l"f&y
[b]固定像素适应:[/b]
wCB5MM
x1U+t P+R5a:[ @:f,c s 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>  以下是引用片段:"aq4|+S)T^3n
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> "O;j'A M1uz l C
<html xmlns="http://www.w3.org/1999/xhtml";>
MMz(G.}zcY2gh6e <head> I YE%]_ {;oNw
<meta http-equiv="Content-Type" c />
TrF T&R.Z,B'B/A <title>css2.0 VS ie</title>
"E*d@1F2|;E@9b <style type="text/css"> _C d0J?8F\
<!--
?7Q U+T9rS&J/MY4B^ body { 6w,Dr'xh|
font-size: 12px; FZ^9_+N|!g6o
text-align: center;
%{S,G"n_i9e margin: 0px;
t(@J+z$r+CQ padding: 0px; vR2l!sN
}
,S(R2B4}'X} #pic{
8sz3v;Y7a8M   margin:0 auto;
rr(l+\/m,E   width:800px;
i2V5|/fi jo   padding:0; Tj)j{*R.[t;v
  border:1px solid #333;
'X8l _m+Zv#MZ   }
4N-p }!t6G/b2P6x2`g #pic img{
Yk6Y.Q&Io7mf     max-width:780px;
0J7e]%D8GiPv \4C width:expression(document.body.clientWidth > 780? "780px": "auto" );
HUvF%I,^;{+[ border:1px dashed #000; JH JAEE#l
}
}]^-r+F-P5~ --> Q4MN*AcN#i
</style>
~nI-Z'C!loi R </head> xjBa*E!Q
<body>
*~eq b,lT <div id="pic"> -} ukA iW6t+c
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 2{{C7|5iCLO
</div>
Z&h({ @d&G3G }Gv </body>
/sM_8q0_ub </html> JM1SRt ?

I?Of a Sm 百分比适应:O m(gyk8pU sm
以下是引用片段:
O(DSd$t1D^ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> R%w!n[)C k"v
<html xmlns="http://www.w3.org/1999/xhtml";>
S Dk#K4x Ao N~ <head>
q5B `c)N+HI <meta http-equiv="Content-Type" c />
GC4C C3f FX <title>css2.0 VS ie</title> }2Gyb gc3Rm
<style type="text/css"> oB6F'x gL-`0bN
<!--
"o U PO"Hi1]\ body {
-|6@6Rg C font-size: 12px; Pm!_dl+|?F
text-align: center;
*B L&z _Y"VNDw-?(md.} margin: 0px; EH7g8Y `O
padding: 0px; )`@b/n8U
} 2oP2] m f
#pic{
g$b\ T+O f:~U   margin:0 auto;
ySN:e:I6H:H"s   width:800px;
3Ys3pE'n;UN   padding:0; I)|UurhHMf
  border:1px solid #333;
I^(t)p`5z   }
~ j;h8u,z0g;Ic#P4V #pic img{ o?Y0mV {7_
    max-width:780px;
w/~1Nb$J width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); 6T k#Y+^&B{D(l
border:1px dashed #000;
X9z2j Y)jq }
K&i-?p@w+O --> *L4@P$G#e+gD}
</style>
!kkA4ci3? </head>
S&Y1rR1y@U5~$@^ <body> "mQ/_vas#W p
<div id="pic"> R!|-ZYXF5T9[
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
GZi,NBk{2W} </div>
~c(QwV`Ld </body> #}:E.TUL+eB
</html>

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


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