捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
v[ P+i5P 关键在于:max-width:780px;以及下面那行。
K-j|)F4`8Q7~:B A.Z [b]固定像素适应:[/b] C l4T*L;`:o

r9~_-V;S;nL 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>  以下是引用片段:
T_F*Mr <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
BqY{7Ce <html xmlns="http://www.w3.org/1999/xhtml";>
1K.?[UzD7Yv&a8M <head>
;y3h lI*^ <meta http-equiv="Content-Type" c /> 9ihG p.M.w
<title>css2.0 VS ie</title>
_;XDv(|&xH <style type="text/css"> 1C7z`4y8C^!d9H
<!-- ^&I K7Gj M,j)`T-j:i,B
body { )s8ZW6Y;iNUZ
font-size: 12px; ;P8hNhwA
text-align: center; ?-g-}$BlZ:S
margin: 0px;
|&pJ_k JW#d padding: 0px; ,Gi Otx
} S ^3SD&p D*A`\
#pic{ 8P F_`4F
  margin:0 auto;
7xK%A)Nv+T!g   width:800px; &g1Mr,[KaT
  padding:0;
e.`C2L Wu;cB$Z   border:1px solid #333;
#Q'T/?)a8d F   }
-n z._*WJS1t-b8Z #pic img{ 3z1hwHNt"DC"e
    max-width:780px;
+AF%DKtAKi0Ow width:expression(document.body.clientWidth > 780? "780px": "auto" ); v V$g2WxXu*L
border:1px dashed #000; Y2AFO t(R ly'g9r
} C9R;\p+FPP
--> *Lz4o?8d t R
</style>
$\~%I#z8w6u </head>
,e:D7YJ g Z1gC <body>
*R*h2PQ{0X5y j <div id="pic">
PI sMCO*h <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 5m MK&as.S \:y s
</div>
sE*N#Q Ip$\+L </body> g+fX YG3]cX Io3@$@
</html> %{$D&x&UcW,yv5~

3}6_Y:` ZiFH 百分比适应:
T,t2o0w$f$D]gn_ Q$_` 以下是引用片段:J&o%h Cthv
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
tOd{0E0F0xu8R/L)MA <html xmlns="http://www.w3.org/1999/xhtml";>
vO j4K1_ <head>
%SQ |~_,B5O <meta http-equiv="Content-Type" c />
)`.or[ G$FCr <title>css2.0 VS ie</title>
} };D3q Us*\ <style type="text/css"> ,m^%D!WQ
<!--
A"}%W!bJ8]~3i2bHr-YF!g body {
S8Qtr+?$M znm l4S? font-size: 12px;
"Y,G#dT O4q text-align: center; Z#]A;aK
margin: 0px; E*wiO mx sF
padding: 0px;
cPj N-r }
q/\:J;S$\iN;o #pic{ 4S#E'|8WHh
  margin:0 auto;
u;XbPo-Zq9W R   width:800px;
.o.W;FhN,H V9f gh/yZ   padding:0;
,Z-tE*T*z1\0p5l   border:1px solid #333;
i8h-N?x3csD(UM   } u Y/Sp&V!q9\#nj
#pic img{ p0xA:K]"dys5?
    max-width:780px; 9yG"k1O}
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
ZQ|5x8MRS border:1px dashed #000;
L9V#}#b}8D^@N }
1m!l2SP)uYy?o -->
ID6xkfQiv2O3c </style> T1s"I&g7|!z"ji
</head> K,W/o/i R OE5R
<body> WBT,B:R\
<div id="pic"> @&|euEH
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> S4gF4w)sO-J
</div> zG$v4c+[
</body> $\bpm(S}QK_n V
</html>

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


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