捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
3T~ atB gV 关键在于:max-width:780px;以及下面那行。FwI;IG&|;[Yx
[b]固定像素适应:[/b]
i.ap!u4it.J}7BY;v zT8~c*F pgwY
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>  以下是引用片段:
$T5o^3_ A2_)r*|'K'z <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
5@!?)@+V9U`;l <html xmlns="http://www.w3.org/1999/xhtml";>
%tS#_Z'{ <head>
M[:zF;o\ <meta http-equiv="Content-Type" c />
/Dc,q*Jr+gw {:t <title>css2.0 VS ie</title>
&wh/wG PJ <style type="text/css"> c.aw9JS&}w
<!--
~1Z J'j!u8`.^1U body { ,f _6{V-E0c
font-size: 12px;
S`S.{8[]*C text-align: center;
u1NNdk8ASZ margin: 0px; qV:F*y6P\c
padding: 0px; *NJez8D'p
}
B'Ca0D%B#T-P h #pic{ /L I2V8@Srf
  margin:0 auto;
jl[4_!x0n   width:800px; Qq[I)i8}&Qx
  padding:0; \.^rci
  border:1px solid #333;
Vf d,Q/a4a   } dj e H9j2nQ(asx*v;B
#pic img{
l:|2Aq U7wKF     max-width:780px;
$GJ2}-|U0E9g$U%Q width:expression(document.body.clientWidth > 780? "780px": "auto" );
7E6x2s'C(Ie border:1px dashed #000; 5tj JB~1XT+W
}
)YPa&eK QM4b:Y M --> 0_K;b/i.E]s-k W/l:T
</style> k1V}/qLt)OU
</head> c6d*Bt4G.e
<body>
/`U-RwHJ <div id="pic"> M'~ Za4D4o W ~N}
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
)pV0_fhQ2|H </div> 2V2^ ~#b!K8|
</body>
1|h4`7eAm,` </html>
|(ZNtQ
2al+}8F7h+_ 百分比适应:%[_5SO Z Iz
以下是引用片段:2J-h2Gbr0C
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
'_(X+W(LGLC(k <html xmlns="http://www.w3.org/1999/xhtml";>
ot|H.T4Ni)OM] <head> C%|2},vw
<meta http-equiv="Content-Type" c /> ~5P({ER#kjf
<title>css2.0 VS ie</title> 8G2~sgM-lR2L9Z
<style type="text/css">
.t&BQ3A!O Ag*Bq2] <!--
8J+aa;sh%[ body {
#st3}eIpiq^5ts font-size: 12px;
"\fO^/He~ text-align: center; #_ E3}"LbQE Ow"z
margin: 0px;
A8` f6E/F padding: 0px; [EZ{ e0t:K:]T(s
} U.E&\'~[FP
#pic{ #Z!V e.mt
  margin:0 auto;
$T/{Tmt'C.x   width:800px;
]4k-\qN|I   padding:0; q;V'_e Y.a A
  border:1px solid #333; hU;\a\l8CD
  }
Hr\~'@8euiL #pic img{ 5m dJ4Th'j[hq-q
    max-width:780px;
+s q$P"f!S width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
clG&F~-A:o~ border:1px dashed #000;
6[5r_'X)Y? ` } [] O~-\DA
-->
Hi1wpu$@ </style>
(I])~!W9l(Md%{ </head> Rj'u8VT'_6B7\
<body>
#@'_:M ^_;P+r <div id="pic">
dd)@|/o8w&m w6\*\i <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
(g w#x+@&B*@5o+w </div>
)ZAc0l1OD!InD </body> )s.W5EC;jxY
</html>

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


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