捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
6}w4p C#o-ntH"qh 关键在于:max-width:780px;以及下面那行。
/tq }-^v_3R6z i [b]固定像素适应:[/b]MSp/ee[
hOA*@9r!X
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>  以下是引用片段:
"J7M ?2m0~ v)a <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> bpR p3j#j1HKr|:V
<html xmlns="http://www.w3.org/1999/xhtml";>
)CLbtiePi <head> k(_ t }:c;iO!B:R-}
<meta http-equiv="Content-Type" c />
5oZ:_A5S V0\ c <title>css2.0 VS ie</title>
YS{ G4vc'K"O <style type="text/css"> l"r"?*` p1j yP n ^
<!--
R.D,J pUAU7~ body {
/E_{x_ zk font-size: 12px;
c*b#cuhhdL7\ text-align: center;
us7{6n+S^ margin: 0px;
(}'e.Y8T(_] padding: 0px; /BVbH6]yl O k G3B K
} J u5UMSS3E
#pic{
W9c'B&r7B R   margin:0 auto; 3h,]_:RZ.P$n l#VA'BV
  width:800px; up/y;q.k9i
  padding:0; c,hR]A`px
  border:1px solid #333; E!j8N!i b@JJ
  } \2`#m/hS'W7VM.z%lO
#pic img{ U}/jS7J
    max-width:780px; zL,\(z ]1b4j(~i
width:expression(document.body.clientWidth > 780? "780px": "auto" ); a`5r{Je
border:1px dashed #000; $P B}$V(xz%J
}
(C hr:T.F8{[5i5gj --> YT-?5[pZz'UXs#V
</style> A{t1S:`@}
</head> ]_L*}KO4N T
<body>
EMr;AdT|P <div id="pic"> d9{R*{.di9I&z
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
J L gcAg i i? </div> BkLi3p&vx8hY
</body>
o0I^ _7Lq </html> $P/sog,x.A/G

v&F+A2tQV"Y~ 百分比适应:
*ks-PUbu9oy 以下是引用片段:W7u.s_d~S2d
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
.G6x0s|&iv.k[l <html xmlns="http://www.w3.org/1999/xhtml";>
;RCH4v.{~ts|,Ds <head>
.|&au#c:Rc9q/fj t <meta http-equiv="Content-Type" c /> d0eW#ppROKew
<title>css2.0 VS ie</title>
^yHj'b <style type="text/css">
+`k'd3Q1pHn~ <!-- +}\1N [.V
body {
+M.J_7}%X't z font-size: 12px;
3cp*\ d3O.c#u#Xv text-align: center;
QWJh p2bK7_*{Q margin: 0px; \`7t%MSS'Ne
padding: 0px;
B-UxsD Pv8p*b rH } h(_](|:hG&A(k;x"H
#pic{
_1Y!NJ0BVuIv   margin:0 auto;
RV%v#s\hR^Q6E K:R-f   width:800px; bB x d&M+x ]{Bl8O#i
  padding:0;
-{2pT,WNQ._f   border:1px solid #333; G}8bs&i3~:s
  } 3Lc,?'{:D*d Zla%x
#pic img{
E6h8U&q4`@ f A     max-width:780px;
5K;W2ym#R width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
5oH0]*Zi vW border:1px dashed #000; 4C)U7[$a3T)y9m
}
Dlz-t Do*N*| -->
6N)Ew7T0P(\'KN `K;K </style>
?bSkR$d`V </head> ^L!o L!~ W8h
<body>
kP}b#jL'|'T <div id="pic"> "EbX\2hT)Sa
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
B!LON&J a </div>
Bnv*Tg2?,k M"h9b </body>
#X/G2mI2L1W </html>

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.