捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。Oz j7z:FnKX
关键在于:max-width:780px;以及下面那行。FloE1i)B gu
[b]固定像素适应:[/b]
u |N;v2{;Q? `Sd
NA z1lz W ZgB 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>  以下是引用片段:
!f4] v0hY(c <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> ,j9fn{[9Ku"Y
<html xmlns="http://www.w3.org/1999/xhtml";> .u)|/xK1C`:qj\
<head> u8?+X2^ r Y
<meta http-equiv="Content-Type" c />
4w6d*g5BB5p3|9K| <title>css2.0 VS ie</title> I"EgzY6b
<style type="text/css"> [%[ S(URj5]XUei
<!--
f?7O0h9pr|x body { cAc O6u u${"J:F
font-size: 12px; W#e:Xw3y'Gn#i
text-align: center; ,xAe,O(c)m:JH
margin: 0px;
P2V3C4gZv m&U"o aQg padding: 0px;
e+?Y bDua$C3_#V } e.XL e f"X[
#pic{
d,Bj DoS+?/I:m2X   margin:0 auto; A:n$D.R1_]6A f
  width:800px; Z%{n/U~*W,wV
  padding:0;
|+K] J Z'p+]   border:1px solid #333; p9qS2gl7y6b
  }
+~Ui9xP!E #pic img{
3m1X9?e-I     max-width:780px;
HmnDju5v Gcf6^ width:expression(document.body.clientWidth > 780? "780px": "auto" );
I+W'll0I] border:1px dashed #000;
U w kH;w ]5b'|!F }
;iKkONK f -->
7ui!pQ6\)|&|p </style> !Wp p5J/|$@
</head> {"m5F:Tz8[h8^U8~r
<body>
V f{I2W XJ$T8P <div id="pic">
_.h1c V0Zf r <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
g`L CyE </div>
#f}l/Hoy </body>
{Gr2d&G H </html>
p&b/N)_Z%fW6? bzD~A L
百分比适应:
$AT'B)w&W){+vcXA 以下是引用片段:B^]I&}\)K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
"Z$|b+C7@ wF6FB <html xmlns="http://www.w3.org/1999/xhtml";> Q|a|%[6a
<head>
jG Bp2M7S9[V"o <meta http-equiv="Content-Type" c /> Ruj i/\`
<title>css2.0 VS ie</title>
2g1m0R*IY%`6Ps <style type="text/css">
boLY [y <!-- d `-n%QF%A
body { }_!]'AE$PJ:m9w
font-size: 12px; 2Ow#p!}(GIM*PM
text-align: center; :@ YG8|M7n O+ho.U&{
margin: 0px; poid8@$\2EPq5~
padding: 0px; o?$V&U"h5g3oP"K3Ty
}
3WG!qTv*?(Y3S8k Y1v #pic{
`8n4t qm2C7](a   margin:0 auto; -C}9k} n2t
  width:800px;
zb\ t:BHz#{G   padding:0;
rz.jFIQ   border:1px solid #333;
h9P7Rj)T   }
8i[n2W/tp] L #pic img{
:}B1s~9I\'G%~o     max-width:780px;
P|^ [*u\_5@M width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); r8L!@y/Z+l} ua
border:1px dashed #000; "nm7tpbv'n8V
} P#z.o+w,p
--> 9JQ_p d'D
</style>
*UVSrN9k#Gd#o&c? </head>
Af3I cE.C <body>
&cc|W;Z(_b Aq <div id="pic"> :~iTA StMw
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> ]:C/}v)g
</div> )lw9Qx.Z-F/Yl
</body>
C^W C'Xg b </html>

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


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