在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。关键在于:max-width:780px;以及下面那行。
[b]固定像素适应:[/b].Lvtq,A[Sy
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> 以下是引用片段:p4d-P [Bu?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> T SqS!z"bIL Vc
<html xmlns="http://www.w3.org/1999/xhtml";>
<head> !np%xcZ&W+d
<meta http-equiv="Content-Type" c /> -_fBx/W"zr)W~
<title>css2.0 VS ie</title>
<style type="text/css"> {)X H&LGV O"Ds
<!--
body { (VOY:R)`
font-size: 12px;
text-align: center;
margin: 0px;
padding: 0px;
} ,DL hB7p
#pic{
margin:0 auto; }1kIv G F3s\
width:800px; @b&aL;[!Y6~
padding:0;
border:1px solid #333;
}
#pic img{
max-width:780px;
width:expression(document.body.clientWidth > 780? "780px": "auto" );
border:1px dashed #000;
}
-->
</style>
</head> Z4eLm W}1i
<body>
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> %I9XFh%B-k4wL;lY
</body>
</html>
百分比适应:
以下是引用片段::JZL5Y?U qNZP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> _y DHF5t3R
<html xmlns="http://www.w3.org/1999/xhtml";> 0i h,}^mo O+A:D0w
<head> @]2G-{j%HbJ{8q
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title> f0}"A s!@BGM
<style type="text/css">
<!-- 6xb o8O$D$}l
body { %q1`)P*U%U Fb#MWb
font-size: 12px; hb7y)MeJ|qwY
text-align: center;
margin: 0px;
padding: 0px;
}
#pic{ ]@){5x,fU!WY_
margin:0 auto;
width:800px; 8^F9L1f*bik#V
padding:0;
border:1px solid #333; 8CmH2n A
} L;jAVo'T`
#pic img{
max-width:780px; `I.~d5Z`&?qE"t
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000; `Pv7ICV,}r
} bDPaKF5M
--> hU g_1[R8pFO%_
</style>
</head>
<body> C^.N\3S.O
<div id="pic"> :Y+Z_ UB*yQ6_9E
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 0v"^'k} a:|-R
</div>
</body>
</html>
页:
[1]