捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。[o:q5kb0t
关键在于:max-width:780px;以及下面那行。Mw [9X1qvA
[b]固定像素适应:[/b]
lO4}V4m"EqNejL ?'s+eN?(p
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>  以下是引用片段:
K0^W$p:V F`,_O| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
r+`b6AIKp W <html xmlns="http://www.w3.org/1999/xhtml";>
zY?&K8i0[;m/g <head>
qa`Q T <meta http-equiv="Content-Type" c /> 3P6O&]j*c9N3Bh
<title>css2.0 VS ie</title>
8lZ A,B3| d'LUa <style type="text/css">
)Ymh3BI| <!-- f\?&d+\%vz
body { -v rdd F2~Y1B
font-size: 12px; T;D1@#Q2I)A e6N
text-align: center; 1gmLoA/`q3~
margin: 0px; #`)A:Kq5yiC
padding: 0px;
j*]*K6F-p%Jjl5Y|+N4L }
/a~V7v,{z)V6M4W #pic{
8hgzhlx3\:rG*a   margin:0 auto;
K+vy/H#sO"M(ba;\;qh   width:800px;
S*ZQks)q,F"B   padding:0; 9X&a*K~$Xv:R\
  border:1px solid #333; #^\6H \mZ)tA1pu
  }
yG/v:d*m!uf #pic img{ 2^3t&gy'Cg Y
    max-width:780px;
_.^ cmcx'@+] width:expression(document.body.clientWidth > 780? "780px": "auto" ); o(I.|J)J.i
border:1px dashed #000; z#T:F2f1~J
}
*qy!Y!Uq4g -->
z/erd2pKG"@X </style>
N3a-D'ghY </head> M n0LO/O i7s
<body> hUV!Ay,[
<div id="pic">
C%G KF+y'\ B+R <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> G`&~ |2lP'y{B
</div>
k"F`W'}H%K/? </body>
v2Uh Z?"]f </html> Ib$J.J1GSe
@ef&]B.}
百分比适应:sp9S9QQ
以下是引用片段:
T.h[{M,LL'I <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
QRP5EZ%|0^0r$w <html xmlns="http://www.w3.org/1999/xhtml";> Y7zCB5L n.x
<head>
fW |9Js <meta http-equiv="Content-Type" c /> ({IPe2e{
<title>css2.0 VS ie</title> 9j;TMuO`-RG
<style type="text/css"> wC WbZ:n:|e
<!-- q OHoh4~Bw
body {
d5ie;aL2F y;b9L font-size: 12px;
n${(P-H U E'm3WXi5o text-align: center; (NmO2f of!A
margin: 0px;
9[?-j}A%mq!|a padding: 0px;
b:dW N0??B-V(Z/} _ } 1~%II o^ f
#pic{ $m Z2HNJ8H
  margin:0 auto; /tUkiI
  width:800px; \M.q,t/MP-sx
  padding:0; ic9x1o|W
  border:1px solid #333;
4vS-rt!V,~3K+s3S1m   } D gtj w2DCF
#pic img{ Zl8dDS8miC
    max-width:780px; B{id wx
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
Y;u-M7j [ f @ border:1px dashed #000; m"I_p)wGN
} *a$bBQ R*CO
-->
U:DO&]Eo;GG\@+H </style> q9Y|$sa4rE
</head> /SC KUT9mP.au5? ng
<body>
#eR{7OHh <div id="pic">
pl%l(v#mn <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> ]6F'a'X;v e9?#XM
</div>
+^ALKj </body> )W.Y(Eo C
</html>

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


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