捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。Tjo{ UPC j6as
关键在于:max-width:780px;以及下面那行。
sN&@u|9] [b]固定像素适应:[/b]
-l0uxhJ!F R
[&Q|7D-P]:w 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>  以下是引用片段:
T&I)a"Z8fiH3{ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
O"U0c"e$x <html xmlns="http://www.w3.org/1999/xhtml";>
LT~"U7k <head> -j(T r4^:_H)s&\S
<meta http-equiv="Content-Type" c /> 8{D|r8@&E j
<title>css2.0 VS ie</title> c9Bu/~-I sIp"Y:R
<style type="text/css"> 'x#|7i*M!i
<!-- ` U n7yiH
body {
/q;k%@EV!`F font-size: 12px;
3yy/N]R:K+G text-align: center; *nt_,Q rK Y
margin: 0px; /EJ K4_)P@,w-bdm \
padding: 0px; Un(Tz&L
} F8y+FVaI
#pic{ 3bXp0ZM7|t/V ^/tU
  margin:0 auto;
z7bh \4ib7NH7a}R5C   width:800px; CR b9A+OdX
  padding:0;
ym%Z _)t0\ T#z   border:1px solid #333; :o*_XEK+L0Lyg
  }
;h1H(IBdm #pic img{ h3|y!sYxo%U\&A/~
    max-width:780px;
/R^,Fkr width:expression(document.body.clientWidth > 780? "780px": "auto" );
1r5q;F2C1F border:1px dashed #000; q-B'y Md8B#RA
} z'hoR1p"Ko!AHu
--> 9YAj:L.m^p~?+G-C
</style> -AZ$@3KTF7ga2c
</head> -IB_c:}0uKe
<body>
$vPl1Ftx <div id="pic">
0gTBz-?tLJ <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 'Z%F.L'Sd2I6C&d
</div>
[vksy n </body> c"|i(d[g,C!R
</html>
$O&H'P r)C8F"M
Q4K!u+vYA 百分比适应:bs/];K~$|(g
以下是引用片段:
^9W4s~L(h!V9xQ| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
,p A+}P;Ukk*X1~KD)Q <html xmlns="http://www.w3.org/1999/xhtml";>
3\9RY&G ]+R5l&X7]F <head> elAGg#H"]7t
<meta http-equiv="Content-Type" c />
G2Q$H}ov|K&s-W <title>css2.0 VS ie</title> :n_)RM6oh|
<style type="text/css">
*hS2dkC M7Ts <!-- ~V |1h.K ^"h
body { w#[Ii:mZ[
font-size: 12px;
N3c] Z|;F*E1y text-align: center; b ](?2vnO
margin: 0px;
0kD#q3BNBs,ok'Yy padding: 0px; J5^%TO2K4x!Jl.k
}
5EiQwG\iY #pic{ SZ4U(l%{
  margin:0 auto; Yr&Ah7L9i _
  width:800px; f_O9BU4V a'e
  padding:0; "L:QD'iw@
  border:1px solid #333; 2id^$X4V!F*J,G
  }
(kfO6Zr-g-R#I-]?x #pic img{
Kw:[@P8h     max-width:780px; Y.])H8[:b({ wek6~
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
[*^}F2S_.n K border:1px dashed #000; |sfi,T];f
} %Y r8cBw
-->
r0Y2Z}l Y:\ </style> !b0k V:hpZ'k"H
</head> +r7A%u'M;S5]']@
<body> !H3i2h_D#GO
<div id="pic"> :d RNe$Y!z
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
*I7b7?6}I!th@!gqP </div>
$b7t8?)q0vNL]T </body>
)S xlD4eH </html>

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


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