在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。关键在于:max-width:780px;以及下面那行。
[b]固定像素适应:[/b])M+NY7OQ Z
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> 以下是引用片段:_3w,j-o\u8?
<!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> PGV:P a
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title> "Db7m0JY?k c4J
<style type="text/css"> 9aoU)I4q9D Z(\ w
<!--
body { (_0C L7Hsn)^C
font-size: 12px;
text-align: center;
margin: 0px;
padding: 0px; Uy4JAnU
}
#pic{ 'b"^5]h-V)^5z+g;p?
margin:0 auto; $i lG8U\HB6S
width:800px; Rf2Q&CT UB
padding:0;
border:1px solid #333;
} c-c GN |*|5h8n
#pic img{ 4`{8^*o |:Z$z%|6c{H!a
max-width:780px;
width:expression(document.body.clientWidth > 780? "780px": "auto" );
border:1px dashed #000; {9~FR,@(t$Q
}
-->
</style>
</head>
<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>
</body> "K-k"E1S'xj.L
</html> 1jVNA(E_*p
|!o9y9Hg5Le$f
百分比适应:
以下是引用片段:e%tQ NY*p)g
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> /yzV4j n ~-}$Wkbz
<html xmlns="http://www.w3.org/1999/xhtml";> IS Q}8^Ijf
<head>
<meta http-equiv="Content-Type" c /> Uso\%m
<title>css2.0 VS ie</title> 1d G~8X[]p2o
<style type="text/css">
<!--
body { x~*Pz1H?
font-size: 12px; UB;p3oD eD(``*i7?0[
text-align: center;
margin: 0px;
padding: 0px; $x y |2I,bs$]9A
}
#pic{
margin:0 auto;
width:800px;
padding:0; su:M$z"zy,Zk
border:1px solid #333; s,H"hW%Q'^t
} N)^&r8D9dJ
#pic img{
max-width:780px;
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); ZrDk2M,o
border:1px dashed #000;
}
--> 7c.\"j6^&arq
</style>
</head>
<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>
</body> oq#p%g LPW
</html>
页:
[1]