捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
9n%tJ7Q2A7st] 关键在于:max-width:780px;以及下面那行。
7mv8kW9e\9Q]b [b]固定像素适应:[/b])M+NY7OQ Z

\RFG"r 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>  以下是引用片段:_3w,j-o\u8?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
Ly+G8g @N2h| <html xmlns="http://www.w3.org/1999/xhtml";>
5`8yL~yI <head> PGV:Pa
<meta http-equiv="Content-Type" c />
_'K C;D_'E <title>css2.0 VS ie</title> "Db7m0J Y? k c4J
<style type="text/css"> 9aoU)I4q9D Z(\ w
<!--
g]F \/q x body { (_0C L7H sn)^C
font-size: 12px;
a+V,uZ3IK9X*T6c text-align: center;
2Z)Ido+J$O7j,}f margin: 0px;
,sol&v9Ck-S,F padding: 0px; Uy4JAnU
}
vm%rLU4o8a$z #pic{ 'b"^5]h-V)^5z+g;p?
  margin:0 auto; $ilG8U\HB6S
  width:800px; Rf2Q&CTUB
  padding:0;
%Z3}YR5Z:pJy3b   border:1px solid #333;
S o$L r"X-W   } c-c GN|*|5h8n
#pic img{ 4`{8^*o |:Z$z%|6c{H!a
    max-width:780px;
X }!r3ssx width:expression(document.body.clientWidth > 780? "780px": "auto" );
lA\-O)_/_ border:1px dashed #000; {9~FR,@(t$Q
}
3w0K2r#Ih -->
}a[qhB"} </style>
#W5f4OMv-g(`;\3z P </head>
pY8i0ycZ <body>
[$\Y/`+s*h"G <div id="pic">
IUn0Xp\ <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
"N!G9Tsl$J o s </div>
f#I'D"R i'h;ZPX </body> "K-k"E1S'xj.L
</html> 1jVNA(E_*p
|!o9y9Hg5Le$f
百分比适应:
fRZ%JT0EI 以下是引用片段:e%tQ NY*p)g
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> /yzV4j n~-}$Wkbz
<html xmlns="http://www.w3.org/1999/xhtml";> IS Q}8^Ijf
<head>
8q5GnG?L <meta http-equiv="Content-Type" c /> Uso\%m
<title>css2.0 VS ie</title> 1d G~8X[]p2o
<style type="text/css">
2\v/_2K)Ne}5| f,I{ <!--
KogK`,v'T7E0p body { x~*Pz1H?
font-size: 12px; UB;p3o D eD(``*i7?0[
text-align: center;
m{Q"IO7F margin: 0px;
6l*d8O|7HHw&u0h,R padding: 0px; $x y |2I,bs$]9A
}
u%X6} u-O$R!bv #pic{
7?(^df v ^ F_"y   margin:0 auto;
bl%Q%`[o X#Ht`1ne   width:800px;
V9J{"y+Q} E+X   padding:0; su:M$z"zy,Zk
  border:1px solid #333; s,H"hW%Q'^t
  } N)^&r8D9dJ
#pic img{
.`+oDG;x&E     max-width:780px;
Uu$f5CY?} E'X!W width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); Zr Dk2M,o
border:1px dashed #000;
2h$Z!M2S7Px }
*Zvq)u#`J HT --> 7c.\"j6^&a rq
</style>
Y6u[+O1F'nz{ </head>
]6n:d0Ri[;[5_ <body>
|8@7|]*NW <div id="pic">
8X/Nqv's*Qg1Y <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
MClU.?hV </div>
7I&Q$k8P5Q1g </body> oq#p%g LPW
</html>

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


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