捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
@7T*i4oi:[5V 关键在于:max-width:780px;以及下面那行。sp}7iL;O$^
[b]固定像素适应:[/b]
}!WIK8x6w1hnnNlW;}
0BEI2N;\(k 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>  以下是引用片段:
0@Hd\4Dl <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
H!a }b5r'k!Z(M <html xmlns="http://www.w3.org/1999/xhtml";>
EK8p$e!x$fu <head> y}QFr+`#J,i8s$DY
<meta http-equiv="Content-Type" c /> [ Kc.ZJ \jj
<title>css2.0 VS ie</title>
bH NW*me J)I <style type="text/css">
2[kIUB,Qg9_&S5zc6X <!-- q[ kuR@ d%~-sJ
body {
p\W+i DVQ font-size: 12px; 0?Vw8r2E
text-align: center; nVohKEB[(g
margin: 0px; 7\ od'JXo ||
padding: 0px; 1d`SeD4ytH4^b]
} V!b"w s"q!T2b0v;E m-M
#pic{
I2o.v8eP.w N!?#g0R   margin:0 auto; !b ya'e w(r/b BW&D
  width:800px;
#GnR7b[   padding:0; Io7zX#w:[|
  border:1px solid #333; ra,t*~C3D*i;\
  } 9u X^W${&^D;f
#pic img{
Q$Pn.\zAt     max-width:780px; tg0c6~ k}5Ln
width:expression(document.body.clientWidth > 780? "780px": "auto" ); 6a*O$A"S4d8pX{
border:1px dashed #000;
&O cdD5H } 1?TL,gZ|
-->
l uf5\0K{2ld!{ </style> 0l{ B.Trh`
</head> 2g-dC_*ebNI
<body>
0H hC1wk <div id="pic">
3k:n3uWG \ <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
h4vOL@.F </div> 2v [)z&a]&e g
</body> #jnQ y y'P4ze8U?
</html>
0@ L1]*f(o:A
yzi"q c1ksE$h.CS 百分比适应:
fN {&Vjj2el'w 以下是引用片段:
&Kjr$?)q2LYq(a O <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
&Q8NI S a&P"j <html xmlns="http://www.w3.org/1999/xhtml";>
oy BC,h]{ <head> 5O.Mqe"QV(voO
<meta http-equiv="Content-Type" c />
}!['C){/e8b MqY <title>css2.0 VS ie</title>
*|p!}5eKU%} <style type="text/css"> 2sfPh%M&lS
<!--
)e"G;Co6N i body {
i2e1H#Y;e&W font-size: 12px;
D^4l5N x6xQ_ text-align: center; `pC7i6](U5a7h?
margin: 0px;
V$K%p3K v,tn padding: 0px;
c8BE6ot1gr+N }
Qyd2MG ^pg}3{ #pic{
6kW9X*V c]   margin:0 auto;
n9i\7L;vPvJ2s   width:800px;
*R M,Vu u   padding:0; .u6fEl/Uv(Q
  border:1px solid #333;
0E6kel%pD8X`X(oJy   } $A*C+ox&}Qo |3ALx/G*a
#pic img{ !q}\7P4FWN,E1G
    max-width:780px; 5w.CQv8D#@
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
ru*U"S]u0`p border:1px dashed #000;
[mF*pQo4wI } ]hD#q#A
-->
5?IK/y s </style>
~Fcs ~O?BM`$J </head>
@(]uca <body>
B;p+H-v7~K$S4\m <div id="pic">
9{ y)X1j~C UQ^l <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
"F}fuA%X&f </div>
s;J7oy c!j_ </body>
9v:CW9{-bLq </html>

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


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