在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。关键在于:max-width:780px;以及下面那行。K}~ g4mF/S{)Mp
[b]固定像素适应:[/b]
w7Z"VKe-e: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> 以下是引用片段:fp+{Na
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> C,{5bY5fB&N3D
<html xmlns="http://www.w3.org/1999/xhtml";>
<head> `Dwt,},w.b
<meta http-equiv="Content-Type" c /> _;` PtD
<title>css2.0 VS ie</title>
<style type="text/css"> W5kpZJH6tJt
<!--
body { ,@&sB&T,T k
font-size: 12px; Jl\ [l~5]b
text-align: center; 6Eux"ejl)t
margin: 0px; D.R BX.V@8m_
padding: 0px;
} 0d1PQG B-?
#pic{
margin:0 auto; +{_mT0Di,z3B@
width:800px; 4Fb GB ? p
padding:0; /r*M#L^4|%y5U9Z
border:1px solid #333; 1q;S]q/I"b
}
#pic img{
max-width:780px; ~d1fe3QW Puq
width:expression(document.body.clientWidth > 780? "780px": "auto" ); #y6HShd*S'nT
border:1px dashed #000;
} n{rVe
-->
</style> ]K6Ellu^Z Tk!w b5F+i
</head> 3AZ qg ~p/O;V
<body>
<div id="pic"> C:N}'_n
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> fw!Z;a1d"`~a
</div> OZj[:go^H
</body>
</html>
;Qa.TQmct9yj
百分比适应:
以下是引用片段:Pk0x6?"A9V
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> *xs2]?/B
<html xmlns="http://www.w3.org/1999/xhtml";>
<head> KQ2B0d1VR:j
<meta http-equiv="Content-Type" c /> 6[0o'~ Qfg
<title>css2.0 VS ie</title>
<style type="text/css"> Ia GN T3i
<!--
body { q_4[v0Uz
font-size: 12px; 7drBs0b
text-align: center;
margin: 0px; U xQ3F/|.Nm
padding: 0px; d9]Y,cc!t4?o
} ]M3{)cC.W ]-i
#pic{ p.{)y@U y b
margin:0 auto; H'ly8V]!y;BR
width:800px; L4FDzgp4g$P]E
padding:0;
border:1px solid #333; {f/N}M _Zue
}
#pic img{
max-width:780px; iAv7U-\
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000;
}
--> *PFZti
</style> 4e9yeFL1w
</head>
<body> tak|/s|L
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> ]"GM @W,z
</div>
</body>
</html>
页:
[1]