捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。~J5A fsx;T7K
关键在于:max-width:780px;以及下面那行。m8Rr G#Hu
[b]固定像素适应:[/b]6V4o|G YB-O_P;I;Bx

%L kR.X)Gg 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>  以下是引用片段::s SJ1n\ y ~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
IvQ6d?s(U(Ey9` <html xmlns="http://www.w3.org/1999/xhtml";>
T:MI8e@4gI u6c <head>
g5MT0q{_B <meta http-equiv="Content-Type" c /> (Y}7kJ#u3O
<title>css2.0 VS ie</title> S%Gq l"]b!l*u
<style type="text/css"> d'UR5bn;A uP
<!--
#X+P4}%vO body {
~+I|9DjIEX7\M font-size: 12px; ~!z,pw/t6{$k3YC#P
text-align: center; ~)VH(W.D
margin: 0px; $S!A LQ FC(pO!TrKI;c
padding: 0px; 'G)Iq.` o@
}
Kv f#UH5| #pic{
O4mqMtZO-v(J   margin:0 auto;
)v$} ]D;id)u   width:800px; t ]5WBK+OO_/\x7K
  padding:0; ISs Sz*o K
  border:1px solid #333;
XO_1xZ o'U   }
+pr|,J;F.~ #pic img{
k`%| k.d&A     max-width:780px; _ r.nvv4|
width:expression(document.body.clientWidth > 780? "780px": "auto" ); ,fY@c `q+Ayx
border:1px dashed #000; *DE[vX)O2g T:uC
} +~(p7}$eZ!N0?
--> w(gB+Z'W#c*KH@
</style> +W'@ u)c2Rv
</head> Oi3ps;D.t6g
<body> tJ Z?.fc F
<div id="pic">
vRn$mV@1D <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
j.g)mT M </div>
;`jw/Al)wL*V </body> 1c6yX@4d]5Y$Y
</html>
q~?8kj]i.oxw y(FQzt
百分比适应:KL| D!ss.n)s
以下是引用片段:
w"cQA2^U%Y <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
Z m7uP&?#hNY <html xmlns="http://www.w3.org/1999/xhtml";> W9|9wb+C!vk5coM
<head> XX8h ^kK[
<meta http-equiv="Content-Type" c /> 6se$C s~s$L d5^ Q l
<title>css2.0 VS ie</title>
Pb c.p h <style type="text/css"> tl(~!Bv4o C&c
<!--
+s#n1\kZZC body {
Nrz Ha"?n font-size: 12px;
z4f"nfDS_sd text-align: center; 5V#I-|X4}au
margin: 0px; qyy[q Gt%fb-E
padding: 0px; D @Km \Y
}
orS5W(W*W #pic{
-d~,H'Qq{ Zo   margin:0 auto;
6aOB)E X+vu[   width:800px;
-F"P o)dYk   padding:0;
)W2c3rW({8B}t   border:1px solid #333; 4i6Ei)U O(d:x"f(p3s
  }
0Bx:TJz Y+VU #pic img{ 5Pc:M'lx^|l.R r'F
    max-width:780px;
CK%~|9Y~$v'|U8\.? width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
tW/y*T7W&^ Kq border:1px dashed #000;
(I8\3EzVai }
0g xw{3Lp'? -->
7NJ1Ssm"w|y </style>
9Z}Jo-Bd6@Lp </head> %RT-i$xC6kQ
<body> B#_@'m?t
<div id="pic">
*c `jD2Xz+I5\ <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
?P_[3hD sb </div> ?+?w h,P[
</body> i'v`+em+PRd#l
</html>

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


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