捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。&sV+HAP+x
关键在于:max-width:780px;以及下面那行。
:j6I)k| ] Y(q? h [b]固定像素适应:[/b]
${5p}:CPI
uQ,w!z!?C 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>  以下是引用片段:bf6qH/R/n1tP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
Q~*?9{%Y._#] <html xmlns="http://www.w3.org/1999/xhtml";> )Kc2K.Tyf:I\(A
<head>
VB-q I#R J4r;Oc <meta http-equiv="Content-Type" c /> +~ ` SQ8[g(\$K:Xs:h
<title>css2.0 VS ie</title> $A*\s&?5K`#Mb3c
<style type="text/css"> ,c2c+r.M oxZ
<!--
#gX @^+|o$Rp Ni body { s c(I"X|VCb
font-size: 12px; qi0VRCq9a)O2q]
text-align: center;
dXh9yB|8e margin: 0px; {{)] c9qHd9}k
padding: 0px; ,A]y5{&a
} L9`Tf"ry!_
#pic{
`F d.Ce,[b` }   margin:0 auto;
*~1IJ0F SR]K8u   width:800px;
EH C[Lhg/Fd   padding:0;
%x/?XV+t!Vz:J f   border:1px solid #333;
-S5\ko,{   } B J$Pt4}X6w)se
#pic img{ %f,]!X H3l&VVh-a"X
    max-width:780px; vQPd:aY&_}Gd
width:expression(document.body.clientWidth > 780? "780px": "auto" ); N9XV)kU*`F}
border:1px dashed #000;
.wa2}cg\hm0~ }
Ao)TV/^&h -->
f$Y1g f2^v3f/dVV </style>
cB-R^wG&d v/a </head>
Q9x)BIhs <body> &X1vS1v!v]
<div id="pic"> +EZu|T'\
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
K1G)^mw1uK s5x </div>
;QxW yn9Aav </body>
`B+C J-H lRm7` </html> +X&HycWj0p

^Qv-K ]9{q 百分比适应:
sP"S+j;i"u7dVKz 以下是引用片段:
H+t)~F;H.jS[!?"w9k <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> $iZL b(N(oE&d
<html xmlns="http://www.w3.org/1999/xhtml";>
x)N-L2|6\7um y <head> s4y,HQ!}"D,E2V[ i
<meta http-equiv="Content-Type" c />
"Dl|1l:Tp%f M <title>css2.0 VS ie</title>
J H1~;B$Kf <style type="text/css">
j"jIlCt <!-- B[ X8[J aml
body {
!cNlu2^|\9`~(z:n"W font-size: 12px; 1_#Cw$Y(Vd
text-align: center; 8S|3r6p1bF5`-w3oj4ml
margin: 0px;
@1UToO3n9Q padding: 0px;
1w:a8Fm.Q-IyKn9o5v&?B }
oq~kQ/E\ #pic{
pbUXE$Eq   margin:0 auto;
L4Q8c4[$[\%?6O:}   width:800px;
8h g6IC:@3Z-t   padding:0; +K0Qj"T+I"Z?
  border:1px solid #333;
w&l9EN9E   }
btQ|)bcZ #pic img{ :^0I9S+h O&gc1N8C.?
    max-width:780px; Tgp;bq
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); %p?4?~F(~x&H
border:1px dashed #000; :C~$UOD0X0G {`
}
-c0_h j)w)p T Lo!lx -->
e9c D9ta </style> %^7Zu#](r;|:h/I
</head> ^:Op)bTW
<body> 3V@;_,G2G
<div id="pic">
*|k~!R6K0egXC <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> QA&r sn}9K
</div>
L VU KS;P </body> 9xAb$U:nx yO
</html>

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


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