捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
} a;KhF!VO']G 关键在于:max-width:780px;以及下面那行。
W7_X']j{L [b]固定像素适应:[/b];N0}6\9l^
-y }$A/V)ENrJ+`
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>  以下是引用片段: C(yl8I q\!y0I
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> f&I&aV#J
<html xmlns="http://www.w3.org/1999/xhtml";>
BAwCbk`5V @ <head>
S~Z,Br2w <meta http-equiv="Content-Type" c />
)[S,C%Y)`L <title>css2.0 VS ie</title> ]5| g@YXm\
<style type="text/css"> 7?/]4@#k2]o:`2qc2du
<!-- h-e!\T6edX!T
body { 9m9vf6H#wv
font-size: 12px;
,P tM#Dz%b~#n j;zHPe text-align: center;
E$x$ix0j&SKVn margin: 0px;
k;Bm/P$H7{ padding: 0px; *X$C&{ D J
}
2}I j!h+YI#` #pic{
` G2spO:V:Q!p   margin:0 auto;
w jz t.TB   width:800px;
{`'Sur'Qm   padding:0; X&{^%y'?0QO*Q^wv"t
  border:1px solid #333;
GUp lt;yh   } j!a'rC2p;YQ_\ @
#pic img{ m5Hs#pV
    max-width:780px;
kN `2ECm-P[)lo1E width:expression(document.body.clientWidth > 780? "780px": "auto" );
PCyTE TQb.Z^ border:1px dashed #000; +vs,apA8R'O*`q
} 7d'e*J!d$_N
-->
R+PB~7]'h1@d </style> j9GY hC(]
</head>
`%A}1W$| <body>
8M1N _IXVC5C <div id="pic">
6GI)pg9L+Z <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> cqIJ3Jo uCYz
</div>
Y+mJD6\G </body> Jtf.H#^+] |+W
</html>
)O7O1{v*@H8o
S&| eDJPb)h(r4QIO 百分比适应:
;i8At'u;N6hlX 以下是引用片段:
o `!xWa[1UHd;r <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 7R1zD_1I `"h"dF0@)vU
<html xmlns="http://www.w3.org/1999/xhtml";> Pnv&Yk?py
<head>
5y2Ty_1c&DK t <meta http-equiv="Content-Type" c />
OUJ1t4R8Zm[N <title>css2.0 VS ie</title> 1A7g[ p8sx!l
<style type="text/css"> (]WT2uJ
<!-- GZ YV#`5K6Yv;m
body { %}]!t+D7{3cQ O^-D7R
font-size: 12px; J;\1[U$cV
text-align: center; 3MV%avG(_
margin: 0px; ,|k3Eo*c
padding: 0px;
/A1W;al~i,e }
-_Q)O%})^ #pic{
9P j(i I~` k   margin:0 auto;
$d-s e;M3G6py:j   width:800px;
CKu z)qw#A|   padding:0; osW,p5K5pL
  border:1px solid #333;
`(^q(n5iP'm1Wt   } y?/U `3u
#pic img{
I5zJ|2d'y+il%}     max-width:780px; 2iP!cY2B0M6@1@"`
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
F%^/N*[q9dD0sM2I T border:1px dashed #000; P v#{.t)ZE
} wS[l7H(@%]L P
--> Ogx2D RhP+A
</style>
mnV(]{L </head> S'tG&sPs0Hs
<body> ` Smn;X9A_X
<div id="pic"> k m0S6tsCh
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
P(]3MXn&p"L-q$o </div>
^veOS"m(tU </body>
~@+Gi ]6E/B*w6|'f </html>

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


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