在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。Jpw"g j@关键在于:max-width:780px;以及下面那行。 q+b9Q%N}cI
[b]固定像素适应:[/b]
$qa-fusI}S
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> 以下是引用片段:4A#~r.uLMq.JT
<!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";> f;@$b;joX
<head>
<meta http-equiv="Content-Type" c /> z(Qek8pj'_
<title>css2.0 VS ie</title>
<style type="text/css"> 9eM"x,^w w
<!-- RoV;|D
body { "~rJ3V1R qS1fdQwJ
font-size: 12px; X~ oc1?qR(j"U
text-align: center; n4Hi%n4{
margin: 0px; /y`ayrBUCD5r
padding: 0px; k!j0h1nj
} ,gxt _5bzi
#pic{ I:{ r+{7Vl1^6}!@'b
margin:0 auto;
width:800px;
padding:0; &VJxZ%f
border:1px solid #333;
} ;L;V'b]7\M7l
#pic img{
max-width:780px;
width:expression(document.body.clientWidth > 780? "780px": "auto" ); -p2v;Pt\ D1y3y
border:1px dashed #000; zi0k&K?;Z
}
--> U2b3_z;Z(i-}V
</style>
</head> &Jx2Th.gNnf
<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> /cCW&[ c l
</body>
</html> 5kZp6CP
百分比适应:
以下是引用片段:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 3N/f J&x[|Zw9h|
<html xmlns="http://www.w3.org/1999/xhtml";>
<head> k Y"R]R&MK_
<meta http-equiv="Content-Type" c /> fni!`a
<title>css2.0 VS ie</title> (P%g9x z/k
<style type="text/css">
<!-- ;}q+H,s4q|:~;t
body { #Cz0sMU1aN{
font-size: 12px;
text-align: center; *uI+Nb0w-_!s
margin: 0px;
padding: 0px;
}
#pic{ ~U.zK%W$r+~p/|5H3X
margin:0 auto;
width:800px; vY&wQR8O#I1u
padding:0; X.w3Nq8Rp
border:1px solid #333;
}
#pic img{ 3N$B ]f{+^6\
max-width:780px;
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); 6@zW4wL/sb
border:1px dashed #000; w,C0Xt!i"a"cm0q
}
-->
</style> p d`:E:a
</head>
<body> dp!q4r\_
<div id="pic"> r)m.}VG_
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> t N"N%LQR?$p}
</div>
</body> Dl$^Sa)A,_[
</html>
页:
[1]