捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
Ce%a6SUq%O,_ 关键在于:max-width:780px;以及下面那行。
;\(RD*Zyy/D-g1vB*h [b]固定像素适应:[/b]]j1M!sp {X
P o)Y!?{
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>  以下是引用片段:C]L_g&uR
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> |HS o7A)i)jx
<html xmlns="http://www.w3.org/1999/xhtml";>
#c;s!z/Rs!@n-p <head> i+T.B^9`PJ&Et
<meta http-equiv="Content-Type" c /> Ef%V n2BJ)N
<title>css2.0 VS ie</title> lp J ^"S7z
<style type="text/css">
].o#ot L3A#f ~ <!-- O'{*Z~m&Z
body {
c r(c D?4[ font-size: 12px; #PV&I0Q{ i w!CwuL
text-align: center;
'r n7aG"~7b margin: 0px; 0X Qb$v8A0W
padding: 0px; "`f6}~5DW
} 4U%Dc!E[G6e
#pic{ S v$Y/]*P;` ^e7u
  margin:0 auto; W0D I)\'np ~P
  width:800px; dqd b-A3g g
  padding:0;
c#l0DKF4LBG   border:1px solid #333;
@)P.j7|3IdY   }
m!q)F yD n/p#WZ #pic img{ 9SemVN&x*z)OD
    max-width:780px; oE]R:l
width:expression(document.body.clientWidth > 780? "780px": "auto" ); G*v%m7O;yl
border:1px dashed #000;
5p,k2[b8S'rO+@5y] } H@ o ]]};V
--> TMTM7^6N v j
</style> 5|)w&N5] j#e&Vi
</head>
zz)ZY l&w <body>
jR"C!~@%{I!^ <div id="pic"> f YY/aT't!hD
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> kjUwm_9d c*d c"z{g
</div>
:J?a$iF R </body> o:\#[ D#d bQ
</html>
%k~2KsM%A.d /pO8M xB%i%H3hS/h
百分比适应:z2?1x C Fk*t ]
以下是引用片段:-W/aX}B$^
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 5Zm uI#k8m^ z ]
<html xmlns="http://www.w3.org/1999/xhtml";> ,PuG!FKG-V%f M
<head> 6q7dx4H OJP
<meta http-equiv="Content-Type" c /> ` wa)U.RoTg
<title>css2.0 VS ie</title>
S+C3QL8dCS3@ <style type="text/css"> y7d-yyP
<!-- `w\k?;u(grMO
body {
FK/M)O4n+?'XY font-size: 12px;
R%cX#r;b3O{ text-align: center;
"a)C K/Y$cq margin: 0px; X k(NWpk-N
padding: 0px;
v7\p@ rxp } .g7b6w^G ]#O
#pic{ dwW{#P)a(u
  margin:0 auto;
xk;] Ov}&f B3z T   width:800px;
4SgBJF(X4f:F g:OV   padding:0; Jo.s3CN
  border:1px solid #333; 'r [#o9V yYK
  } P DqF&m)a Wb?4l2nJ
#pic img{
?'Yv%^*K h G     max-width:780px; 3G0b1uz2D}E
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); 7mn!Bi qen|4Zw6D X
border:1px dashed #000; ^ _4Q n/`D2`.qY
}
)z;oXrH#D -->
] S3}6c`;Co5p` </style> \ T7zFwe|*T
</head> 8w6lQ9e sL
<body>
O(f `{w6g <div id="pic">
||#D!} J&?N$Z;a <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> \%|V1`1C7f"FtC
</div>
2S/W6D ~r$Y </body>
pu3U"BJ` J </html>

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


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