捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
!z$pu#P|@ 关键在于:max-width:780px;以及下面那行。~~jWhWED I m
[b]固定像素适应:[/b]
'|N[0P*e!]*L:D
;?$R9|1j2D ~&_3H I 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>  以下是引用片段:~r kx7f3s
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> #Mi Jr5A^4a*q'E
<html xmlns="http://www.w3.org/1999/xhtml";>
d|s~+n.?!T k(e <head> QA@2Z uiTz(J
<meta http-equiv="Content-Type" c />
4cmy8b6R(a9~1M <title>css2.0 VS ie</title>
D"\7a&x8bu"j)M <style type="text/css"> !e6^T6x#U%pwQv'O
<!--
S$Z P+w9Hn~K body { %qr;w:Um
font-size: 12px; p.rX@H*E4Y6B
text-align: center;
"e[})J4_D(^ margin: 0px; rcz'cL _K
padding: 0px;
4N(fs%O D:e } 1g.B$WkeM2b$h
#pic{ ~'_}1i1K%DJv
  margin:0 auto;
?H,tA|S\   width:800px;
$cq2B ug   padding:0; 5ja4r3p(H2d,_Y
  border:1px solid #333; 7g y;V.] \T[,td
  } F#P!]W0q;g#^,q
#pic img{ |gp&NB`
    max-width:780px; z]%S4`4[H-} \6N
width:expression(document.body.clientWidth > 780? "780px": "auto" );
s/N ~ C!KZjno border:1px dashed #000;
TE/u5?H-L5q } 9\pQc'C B%b
-->
*r^)Es%Lg8lR </style> 9UQT?H,X{x
</head> !GoWx}%lW3Ss
<body>
4A;F s7n'QJ <div id="pic"> 1g x2f'nD LmR`
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> "OR/?E` is#Iy
</div> \r|$`:?9Q f
</body>
aH0r+N G0PTgj F </html>
X7T,w/kUp;b-B q.m
(]S1?#d`L 百分比适应:6Xp'}} v3I
以下是引用片段:
)t.d+HW8]%E)pkZ LE <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
}ir-zZ+S5t <html xmlns="http://www.w3.org/1999/xhtml";>
f6H$m"w$Fq7Z <head>
:FqWG'SF,o4{}S <meta http-equiv="Content-Type" c />
Y,ut7?uZXqB <title>css2.0 VS ie</title>
6W8q i.Vw1p#G6?/G <style type="text/css"> 5i9w:b%w{C%H
<!-- .X0f[dV i)H
body { al)u'gHg;vQX&`G j
font-size: 12px; ~)? fF} |
text-align: center; G ?"s~f7R
margin: 0px;
q;t;HEd;df7l padding: 0px; q K&y'x-n
} :Z J_l M'ZIE W
#pic{ &U%Uw_q
  margin:0 auto;
9G[wc4Z ao"Zs   width:800px; i%e7jb.H;a+s
  padding:0;
,x^fg4v   border:1px solid #333; y-?w5j:es
  }
K"z k r^$`3p #pic img{ i B N gqZ X
    max-width:780px; 5qE(_0rC-XHP!Ab
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); }l5[4rX3p3\ b
border:1px dashed #000; 3`&l R}\3s3Z g1`
}
Ey~[-|j1A --> Tg3M^$mB
</style> J1NE1gfO8e
</head>
6g OJI+@8g!n$E!j@ <body> |p@`H4xt
<div id="pic"> 5[Njx)y
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 8?4N [H4o7],b
</div>
UR2KX#u;v*`7Lj </body>
k_9^&u/aV#^o </html>

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


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