在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。:D\7Nvt\$cfcq#a关键在于:max-width:780px;以及下面那行。
[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> 以下是引用片段:-B)m'pC6Em lLZ9on
<!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";> ,PU[ {7sr"G1c
<head>
<meta http-equiv="Content-Type" c /> ;K.Q@ aZ5k ua
<title>css2.0 VS ie</title> g0zv0a*^ w
<style type="text/css">
<!-- ;AD}vA9X1jL,SK
body {
font-size: 12px;
text-align: center; ;S:P4Z(Oo2|/x#L
margin: 0px; Yq$G$r {8Z
padding: 0px; yCKs*u6Y*s&y1^
}
#pic{ -T8P+X6I2Y8t
margin:0 auto; e`Hs Uk
width:800px; _z5XQ@)N8_
padding:0; :qzHHe@5]8y_/G
border:1px solid #333; $H7d(b;`u
} Y4Nr(I:C:^9Hx
#pic img{ ~0J*oA%AS `b
max-width:780px;
width:expression(document.body.clientWidth > 780? "780px": "auto" );
border:1px dashed #000; {3[c;G e~
} D6Op8u#g2X
--> q9A y6W3Nyn5ATN
</style>
</head> "~+n5q&agsVY(e
<body>
<div id="pic"> T E,NW p,cC
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> 4P;v+{\(v^ @1oy
</body> vY5F:^/T`0Oq*G
</html> Rn6D!d0LW
百分比适应:rzm4e F*u1d,s
以下是引用片段:
<!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";> B CN} h4@3[?C
<head>
<meta http-equiv="Content-Type" c /> Io2~-k9h"`5_
<title>css2.0 VS ie</title>
<style type="text/css"> (R6j$L~Mb A
<!-- \&o2[] c!y$d)`
body { m:i"sS6[+M&Z` G-a
font-size: 12px;
text-align: center; 2G-d({o(\A8Q
margin: 0px; 8}^~U+q${
padding: 0px;
} ^ K t T)jR
#pic{ 1n:t;cup c6EE
margin:0 auto;
width:800px; s@v"`(Vk_-s Gt
padding:0;
border:1px solid #333;
}
#pic img{ :\`6b3NKV
max-width:780px; &Ll)a ~Z
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000; 8Bx M-C%q0Eh
} z!gvZj
--> 2f$d9``/@
</style> m3k b*p:sWk{ i
</head>
<body> ;L:? F:oF,_1S ?(Q
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> .SzT1k4Ch:i8ps
</div> im@ydX_.p-vE H
</body>
</html>
页:
[1]