捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
0k3n7Www-AU1K 关键在于:max-width:780px;以及下面那行。
w(B5^U+aH~ [b]固定像素适应:[/b]
J^.Jd }L;|!]
Vr8f H!mJ 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>  以下是引用片段:
0gyn:_B7i <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
/oW+r)v6[-a <html xmlns="http://www.w3.org/1999/xhtml";>
D%VE_#K&d <head>
*y)`&i5G+G <meta http-equiv="Content-Type" c />
+z:B0eo Rbv%ak <title>css2.0 VS ie</title>
RV e#tm,z ^SC <style type="text/css">
Hi6j"D)s6} <!-- ,D&u)Ff*h~ oF$b\
body {
&CRN$`Gve2hn font-size: 12px;
Sf;p;D:X.L ~,hp d text-align: center;
]"r$b~Ei9h margin: 0px; (oKr}?cG9g
padding: 0px; } z+q LCh'x&riPx
}
'?I-eDg2Fe #pic{ 8N zeh1Ly^9};Z
  margin:0 auto; (QD6~E3M7@ e.uj
  width:800px; $DcRV }.O
  padding:0; }Ao7CP U0~Q
  border:1px solid #333;
4p uzSFm   } ,W5I t Mz I]M;u!r%{
#pic img{
3_8rJ x6ja%S A     max-width:780px;
DY|Exs/] width:expression(document.body.clientWidth > 780? "780px": "auto" );
!PX$~sT@h(ud border:1px dashed #000; K7K5io)n
} i.B,NlY8eHw
-->
YfN2{x5G} g3S%v </style>
*a&L)qh*` </head>
#M2|@z2oU.D(d <body> Vm v:uX-Gw:x
<div id="pic"> c+MB5WY`
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> u#_~ jLn{ uO1M
</div>
B }a8~1l-HH5X;y </body> ([(\ C~F%?
</html>
VU9I#v%Hq i]MC d
百分比适应:%m1[/H2C/p8y
以下是引用片段:8M M ?l"M#J/G
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> +R j&B%i P!T T1c9R
<html xmlns="http://www.w3.org/1999/xhtml";> 7h0a Ot\K$Obd:O.p|
<head>
5Z'd5ne9wi|C3^ D <meta http-equiv="Content-Type" c /> I BG1qm"B
<title>css2.0 VS ie</title>
D*p1K-R:D0n <style type="text/css">
1C3HmI:B |z R2L <!--
G'|['z6`o"c body { Su9PI-p`+f
font-size: 12px;
y|%ijw(h"i text-align: center; h/{A Q@L_ g&l
margin: 0px; l3U1l%u-c`
padding: 0px; 5_-l`,uOv9]I
}
#oay;N,{t}:j #pic{ xM"A]8\? Mu%{
  margin:0 auto;
'Vc8Zh#CzL,E   width:800px;
oo8|jMM   padding:0; e@]3h6{4X
  border:1px solid #333; G6{2N#JG
  } BX5]S_ hN!D f7gI
#pic img{ $L8XJ{%D9MU9OG
    max-width:780px;
"wd`R:L$\ width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); c)E![Qe-I{2ew
border:1px dashed #000; B`3t,j^-[e
} -Qx%`n@r
-->
4p;_/V\(PMb </style> d7A&w3u.}-X P
</head> &Y G&h-H5b-}i
<body> ;_*v{W J Qn y'Y
<div id="pic">
} e i*D5ONH { R <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> a"dfj9M(C
</div> %g|4\.f9G
</body> _U t q"O8S$rS_
</html>

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


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