在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。p,f%i-^e^"F关键在于:max-width:780px;以及下面那行。3{-pJ/I[;ID-C)h
[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";>
<head>
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title>
<style type="text/css">
<!-- ;V;^'Q3xN/I
body { {iH&ZF(j B7s
font-size: 12px;
text-align: center; 8|,}K c q
margin: 0px; ac^'D Y vb6i
padding: 0px;
} ]9bN9XMl
#pic{
margin:0 auto;
width:800px;
padding:0; J @+GK u c
border:1px solid #333;
} 'Y7F7DFBTy
#pic img{
max-width:780px;
width:expression(document.body.clientWidth > 780? "780px": "auto" ); ,SQ2v(a4d pt
border:1px dashed #000;
} :\u!YXJ gO$BN&IT
--> /}#v6x+l*l#UI
</style> ,A4`5Y,rsrsd X
</head>
<body> E,K4V$ez?vAc
<div id="pic"> q'j+yM(~
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> r e5_*S^
</div> V9asm*Y
</body>
</html>
百分比适应:
以下是引用片段:
<!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";> .c}Y;zR6uX
<head> 9Jp)C$ANH
<meta http-equiv="Content-Type" c /> wqg%GZ9lw)v
<title>css2.0 VS ie</title> L)P*@'[ DG"G}
<style type="text/css">
<!--
body {
font-size: 12px; ?9A Uj&yL$@EV!X
text-align: center; I+Y7o:fe)h Q
margin: 0px; cI zCFL5l
padding: 0px;
}
#pic{
margin:0 auto;
width:800px; eF&N+].N av[D
padding:0; Tb$sS6n9CN_D~N_k
border:1px solid #333; N4x'Z)y2o'n
}
#pic img{
max-width:780px;
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000; Zp*pDEt
} ott6LIzy
-->
</style> "\&t.Gs.C!u|Zc@
</head> u SD7Bz
<body>
<div id="pic"> "qs-q5MNP'`
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> i$v M'e6QW
</body>
</html>
页:
[1]