捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。2SQ_ni7Pt
关键在于:max-width:780px;以及下面那行。 o(],Y$PO5p%oJ
[b]固定像素适应:[/b]C!whi'l#d qo;Q$J/P

?*X#k9Q'`'t O 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>  以下是引用片段:
6F&oVA'g6[5s <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
8z:v8h/Wui <html xmlns="http://www.w3.org/1999/xhtml";>
0qH7Z j!np,i*Tq <head> u w |*_%^%a
<meta http-equiv="Content-Type" c />
.xc@[3C {uQ <title>css2.0 VS ie</title> #v7Pk{6Bm
<style type="text/css"> (| n$P$H8].r7j?o `
<!-- J m1zx/yp(T8T
body { 3@ a-|OO/YLvS&J
font-size: 12px;
X;|#d$E8iB`$g text-align: center;
jK$mt/o6?uN{} margin: 0px; U*?1\!LV9f
padding: 0px;
ksw z |9qW&O } v,o|'d qHT
#pic{
|e6AkVL4s?T4h   margin:0 auto; 8E g}Ged
  width:800px;
:W-EK#yWgC?   padding:0;
m'|^I#{ B@p   border:1px solid #333; lqE,a d@)x
  }
5QGz-Sc #pic img{
ZF"Db e(?8l$wl     max-width:780px; cB8pSP
width:expression(document.body.clientWidth > 780? "780px": "auto" ); /F)oD2b5x)QH:l
border:1px dashed #000;
j4`IVMlm7PM6I } uI5CP-^%}-od
-->
-V'x;L)oWoqv </style> A,pf;O!q
</head>
\ rU.k@ <body>
(KZx vM9eLOW <div id="pic">
c6M1lh#|K],X6l q \ <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
O#X3Y_fv </div>
7R4f%e&gJl;w9o </body>
-k0R3a:A-kWeU </html> q2@+J&B w ~2~eft
@X#cByl'L
百分比适应:C!ZS X'Jt'y
以下是引用片段:
bc,t!m#v*nW%DM9s <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> /s3Z%K7u YGO/G
<html xmlns="http://www.w3.org/1999/xhtml";> .uy6VPDI:E&u$F
<head> w$`d*l.\9zf
<meta http-equiv="Content-Type" c />
p9W#@,p(S0L A <title>css2.0 VS ie</title>
rR)Z4P7Mz <style type="text/css"> |:o"wb} U9hSu1u
<!--
X-@E'Bv body {
1NQS!L:NoN"A font-size: 12px; x#djQh.L
text-align: center;
p8E A7_5[/Q-o margin: 0px; _,n uv:[g&z
padding: 0px; 1E{2S l qXaD1N
} /EM s,\v$v)Sr E
#pic{
n7or\1x   margin:0 auto;
8|B7Q%Y-x   width:800px;
f dEFx   padding:0;
f6cW%fo]%C)]N   border:1px solid #333; U F6Yx:koL
  } lwB x/b3k$y)@g
#pic img{
+@c(\7T YW4WH+qa     max-width:780px; 0F#OO~#g?n
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); Z3Shu*i? WQ
border:1px dashed #000;
)[h9P&K.D } 8RCKa7IQ~(se
-->
`&Z*UF1Mkco2pP </style>
8X6g)o&V Q)aN </head> {l,r d} uq
<body>
)[ZZ7uT vs3y <div id="pic">
,lmG5M z <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> Q:i9lu4g pH
</div> 7W`7~!bZ-ltMr
</body> h;u(p#p$R0\o
</html>

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


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