在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。关键在于:max-width:780px;以及下面那行。 ?g$^ hC
[b]固定像素适应:[/b]9Ci6i`A`G
4Q?3B$Pr'eh#L!_
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> 以下是引用片段:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";> M l&J^Aq5v C
<head> ?I#]#L!wb6PF!_q*~1x;v
<meta http-equiv="Content-Type" c /> lNP%puz5H1g
<title>css2.0 VS ie</title>
<style type="text/css"> :R;F w'Fqk"N
<!-- (VORDGO}l
body {
font-size: 12px; x \5PL)i
text-align: center; 3x&qW-A Rbl)qY
margin: 0px; @r7j'AW!i8Fh
padding: 0px; @j/s@"q)k0W
}
#pic{
margin:0 auto; PDdF+e&eWP{B&e
width:800px; 6B7{:Z{YR bZ5I
padding:0;
border:1px solid #333; -bm;d_!}KI
} rW$I2O;J+G#Q`Z;Z
#pic img{ e)h+AvL;W T
max-width:780px; PDS V],? k%{ v8T
width:expression(document.body.clientWidth > 780? "780px": "auto" );
border:1px dashed #000; pl8tl8v2[ln ?
}
--> D(]L:TU7G0k
</style> PB5HT#ma'oO
</head>
<body> F)t2FI`
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> mH7x0txY
</div>
</body>
</html> _}7U)Ca^m1G
X^q-N e;l
百分比适应:EI3iBv/C
以下是引用片段:d*]E"i1~}4Z{
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> T9fRkry;^U1b1p
<html xmlns="http://www.w3.org/1999/xhtml";> \FbO'Fva~N
<head>
<meta http-equiv="Content-Type" c /> )szO6B"Uy+s6}
<title>css2.0 VS ie</title>
<style type="text/css">
<!--
body { TEBe%mj"U+L
font-size: 12px;
text-align: center; 1BXu$g!f@hfU5` U
margin: 0px; 7pDP4Z]6Gr8c)V,n
padding: 0px;
} QJb K,cJ)u3V
#pic{ !G.g+@T!Q
margin:0 auto; ,{nY1[,N-{
width:800px; *X.AE#~(pP1m
padding:0;
border:1px solid #333; M2p)\4P/q2h/f
}
#pic img{ #R!GHrud[.r
max-width:780px; p U7I/J'tv3O
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000; 7^EH3Jz)B"|/bD*S1L\
} #s#e,]-jQ)|v!?:c
-->
</style> kJTZy0y5_
</head>
<body> _ fF(s-d
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> &P5c-L+Fz#a!?3M)CA3z.X
</div>
</body> ^6yr#f8M.EDV
</html>
页:
[1]