捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。p,f%i-^ e ^"F
关键在于:max-width:780px;以及下面那行。3{-pJ/I [;I D-C)h
[b]固定像素适应:[/b]
/tgG ZB'q(q ]/g\
+]4C%C0c t P 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>  以下是引用片段:
A+h.e8w0@ _r5} <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
$r7N`Ug <html xmlns="http://www.w3.org/1999/xhtml";>
#w/VX,ekK$} <head>
zLho7],fn <meta http-equiv="Content-Type" c />
m FZP aME3j~ <title>css2.0 VS ie</title>
u.Z(z(zh ggO|,lj <style type="text/css">
QE9|&g$q <!-- ;V;^'Q3xN/I
body { {iH&ZF(jB7s
font-size: 12px;
gF}s{4Ji text-align: center; 8|,}K c q
margin: 0px; ac^'DY vb6i
padding: 0px;
4iI&A3][ } ]9bN9XMl
#pic{
%z#D ?(om xa#jj   margin:0 auto;
0a X:N`6H9C(^0nS   width:800px;
i/Fk"Z Rb8|   padding:0; J @+GK u c
  border:1px solid #333;
)GZ'KWt H1F/p[R"|   } 'Y7F7DFBTy
#pic img{
!n1yj6O m3D/Yj0Gh     max-width:780px;
Z)H)exQ:X0djQV@ width:expression(document.body.clientWidth > 780? "780px": "auto" ); ,SQ2v(a4d p t
border:1px dashed #000;
Kx^(SY4}-`H!A[6O7W } :\u!YXJ gO$BN&IT
--> /}#v6x+l*l#UI
</style> ,A4`5Y,rsrsd X
</head>
9JB C@(@2zq V <body> E,K4V$ez ?vAc
<div id="pic"> q'j+yM(~
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> r e5_*S^
</div> V9a sm*Y
</body>
&o,W}6}-Gwq r </html>
"~q.v#kj@p
W1ey Z O1{ ovb 百分比适应:
@p c4`{ x [/h AF 以下是引用片段:
As`i0T!on+q h <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
e~"w"hE@k ^ <html xmlns="http://www.w3.org/1999/xhtml";> .c}Y;zR6uX
<head> 9Jp)C$ANH
<meta http-equiv="Content-Type" c /> wqg%GZ9lw)v
<title>css2.0 VS ie</title> L)P*@'[ DG"G}
<style type="text/css">
1^d;q5Zkz\bb <!--
|.a&ci ` body {
f+I7w\D-e {4s9c'U font-size: 12px; ?9A Uj&yL$@EV!X
text-align: center; I+Y7o:fe)h Q
margin: 0px; cIzCFL5l
padding: 0px;
+n ot;n6?5r]L-J }
q:w*EI7P.N #pic{
` ~e#l,H*j? LK   margin:0 auto;
Ha8|9i2ui   width:800px; eF&N+].Nav[D
  padding:0; Tb$sS6n9CN_D~N_ k
  border:1px solid #333; N4x'Z)y2o'n
  }
z%G8CA(b&y #pic img{
-Q&xG.A a/V T*um8|     max-width:780px;
,G@:aa:t9qO width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
Cx%@7CzV border:1px dashed #000; Zp*pDE t
} ot t6LIzy
-->
/fta7~%jS.Y#s </style> "\&t.Gs.C!u|Zc@
</head> u SD7Bz
<body>
}3Rj,iY <div id="pic"> "qs-q5MNP'`
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
6?6Z+B~1W @$_ </div> i$v M'e6QW
</body>
mN{TdY^&B3]Ad </html>

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


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