在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。[o:q5kb0t关键在于:max-width:780px;以及下面那行。Mw[9X1qv A
[b]固定像素适应:[/b]
?'s+eN?(p
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 /> 3P6O&]j*c9N3Bh
<title>css2.0 VS ie</title>
<style type="text/css">
<!-- f\?&d+\%vz
body { -vrdd F2~Y1B
font-size: 12px; T;D1@#Q2I)A e6N
text-align: center; 1gmLoA/`q3~
margin: 0px; #`)A:Kq5yiC
padding: 0px;
}
#pic{
margin:0 auto;
width:800px;
padding:0; 9X&a*K~$Xv:R \
border:1px solid #333; #^\6H \mZ)tA1pu
}
#pic img{ 2^3t&gy'Cg Y
max-width:780px;
width:expression(document.body.clientWidth > 780? "780px": "auto" ); o(I.|J)J.i
border:1px dashed #000; z#T:F2f1~J
}
-->
</style>
</head> Mn0LO/O i7s
<body> hUV!Ay,[
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> G`&~|2lP'y{B
</div>
</body>
</html> Ib$J.J1GSe
@ef&]B.}
百分比适应:sp9S9QQ
以下是引用片段:
<!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";> Y7zCB5Ln.x
<head>
<meta http-equiv="Content-Type" c /> ({IPe2e{
<title>css2.0 VS ie</title> 9j;TMuO`-RG
<style type="text/css"> wCWbZ:n:|e
<!-- qOHoh4~Bw
body {
font-size: 12px;
text-align: center; (NmO2f of!A
margin: 0px;
padding: 0px;
} 1~%II o^ f
#pic{ $mZ2HNJ8H
margin:0 auto; /tUkiI
width:800px; \M.q,t/MP-sx
padding:0; ic9x1o|W
border:1px solid #333;
} D gtj w2DCF
#pic img{ Zl8dDS8miC
max-width:780px; B{idwx
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000; m"I_p)wGN
} *a$bBQ R*CO
-->
</style> q9Y|$sa4rE
</head> /SC KUT9mP.au5? ng
<body>
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> ]6F'a'X;v e9?#XM
</div>
</body> )W.Y(EoC
</html>
页:
[1]