在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。#X-dd:A0b4j|关键在于:max-width:780px;以及下面那行。!khdKL,@ k@MA
[b]固定像素适应:[/b]
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";> 9L\0^6O@ enM3w
<head> E3o Ls"wQ
<meta http-equiv="Content-Type" c /> V-H IEK)G
<title>css2.0 VS ie</title>
<style type="text/css">
<!-- &KA]1VJ)f*p Z`
body {
font-size: 12px;
text-align: center;
margin: 0px; *ouP1b'{
padding: 0px;
} %~CP2q-u%R
#pic{ P6ie?!U0YO'I
margin:0 auto;
width:800px;
padding:0; $X0V8rO:CE
border:1px solid #333;
} U(h|$Hp \,E M;]t z^
#pic img{ J0Jb4RZPL$D
max-width:780px;
width:expression(document.body.clientWidth > 780? "780px": "auto" ); EE{S.y(iY+K
border:1px dashed #000;
}
-->
</style> !TPc jiz"Fv8R*X
</head> :Kv?G%Y,R#|O+Aav
<body> *r @A ];_
<div id="pic"> .cqej;PnF(D
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div>
</body>
</html> 7t `|ita{ A
百分比适应:1M6x#}l:Q6{Wx'V[aH
以下是引用片段:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> N1X RTq
<html xmlns="http://www.w3.org/1999/xhtml";> lbU-rV^C
<head> |%? g dxn
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title>
<style type="text/css">
<!--
body { ~:JvU%x j
font-size: 12px; *W @F+~+R7TS Gv
text-align: center; /t.B)k/yRN
margin: 0px; "_\gU*W a
padding: 0px;
} m vFc6o9_
#pic{
margin:0 auto; ;@.@O;x Koo;tAs-t
width:800px;
padding:0; 2S?2LhZ#r:G;[
border:1px solid #333; @3apwH.v d
} {Q5TI$V
#pic img{
max-width:780px; tr N5z1vsDyJ
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000; i:U^TC8?
} .Z}/E g K2b2@
-->
</style>
</head>
<body> -L%TET U,N
<div id="pic"> qC6WX;ZY b!] o
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 8D3sb5?~7\-X{c
</div> _)[P&B oz6g8c
</body> Zz;gF[
</html>
页:
[1]