捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
j`J,Uo%kE 关键在于:max-width:780px;以及下面那行。 j(bmT(}
[b]固定像素适应:[/b]W9@)DRaYo/~
(]0F,O:A v6K
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>  以下是引用片段:
.L/w-}m^+Y <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
-zvDdV l4|uo$M <html xmlns="http://www.w3.org/1999/xhtml";>
Z3e@$?B(sH <head>
.zop abk&_N[2? <meta http-equiv="Content-Type" c />
Y]*[3U N Wl <title>css2.0 VS ie</title> V)}f*vL~ [!r
<style type="text/css">
8x:ek$H9M)s&_-@ <!--
.D iF^-ck,J)y c body {
'E#^"u*}l ['k font-size: 12px; Q$k ]]*Bg*^+P
text-align: center; Q0C-f7M
margin: 0px; 7jFb rb2x:J:t@D
padding: 0px;
c&lfYMlW `f } L0X3_ Q|Z Lr1l@ c:s
#pic{
.P3E'R3e5P_1Z   margin:0 auto; 6mQBRV2B
  width:800px;
]d6o4W@   padding:0;
$| rPCtXL`   border:1px solid #333;
mj-E/}n\`Xo   }
*uQ,g6bS8` #pic img{ Bm}n$g]
    max-width:780px;
(YsxD*g width:expression(document.body.clientWidth > 780? "780px": "auto" ); /dkC}d4R]*llh
border:1px dashed #000; ,c+t8xw5_m
}
F y|E;H(c)y3RCkh -->
lY oF:Z!B~S1VL </style> d5T9X"V,TL6Uy.[
</head> 1K8u`*JMO
<body> .L(yU%@#q
<div id="pic"> t {,N {c[
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
l{?XR Nh$N </div>
"|/Bt5|8M4`B </body>
9y1fy'z(w(v </html>
s~/@!l&K)Uu-u 'gAgw9A1~&Y5X(?
百分比适应:]hnGL@6N
以下是引用片段:6mh!M(|;pg K#P(O6y&Y
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
j+d#u.WL5t <html xmlns="http://www.w3.org/1999/xhtml";>
QrwX*F <head> 'Q d3`2~WoV
<meta http-equiv="Content-Type" c /> ;RB4a:O7tuZL6Y
<title>css2.0 VS ie</title>
lk0ql/a@6~ <style type="text/css">
&_y:V2s#\;u3]Z S[;p <!-- 2A2M ^7?3aohk
body { h$eT F/}n+q,w
font-size: 12px;
2]6}U(z'~ v)vn text-align: center; 1p0z"r3C2[v
margin: 0px;
2h+f*N2S H s padding: 0px; 8z|0V2p y7b
}
UJLy%va2c #pic{
H!v)Sf-g   margin:0 auto;
O(n-X`#P`0S$t+K]   width:800px; |Tv!o&@[ g
  padding:0; c~B9_*n8~6D
  border:1px solid #333; 6lg6]JJ/NZ#[I}2B
  } Wv&p(v m/C&k1x
#pic img{
'Gq U#a}+m2Z K5g     max-width:780px; SK?i/jA
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
P6ez/yt,wD$W border:1px dashed #000;
t l9`p{$x{#Q4{+I }
MIUx(W d1F\ -->
dFAAlP </style> s ]BQe [+D
</head>
_6o.} E!}J7^c <body>
Xzr+{g.X5J <div id="pic">
-vt0S'|-a Hxf <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> RX$l`!c
</div> z"uOj!M:Q;N!t
</body> by j2P,J#f;q6}
</html>

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


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