在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。关键在于:max-width:780px;以及下面那行。
[b]固定像素适应:[/b]
'K,Q)Q{I2H"` DT
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> 以下是引用片段: RD/c*?d6o!h/_{G
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> k!?4H0g$`5d'n
<html xmlns="http://www.w3.org/1999/xhtml";> Yv;f#Q[#c
<head>
<meta http-equiv="Content-Type" c /> uJ^tqTJ2n
<title>css2.0 VS ie</title>
<style type="text/css"> W._]EIj5Q` A%t
<!--
body {
font-size: 12px; S&yr5l#];A
text-align: center; 6e1`OL0m
margin: 0px;
padding: 0px;
}
#pic{ c V9Wf,@4N1D
margin:0 auto;
width:800px; 5M\eo6Qe
padding:0; /Y8C r&j[F
border:1px solid #333; $Ej9_\A*MD
} ?3n4[e[?@d2`
#pic img{
max-width:780px; fn;d GJg-qW7A3?v
width:expression(document.body.clientWidth > 780? "780px": "auto" ); q8x0C N ?8??+r1B+C
border:1px dashed #000; /E"aN2Bu5L]'WfX"}
} 0u9uY3{b&NR(i
-->
</style>
</head>
<body> 1zHiu!e^H
<div id="pic"> g;[K[u:];v
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> loX's"`&gzPE-~
</div>
</body> :I#Hq~!ky;a
</html> 7m%w5~S(goW,c$jy
百分比适应:.}0H6GmXz/O7s
以下是引用片段:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 3CSq&f[-[;_5Wx(}
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" c /> k | [PU [Wj
<title>css2.0 VS ie</title> :T3dBc k
<style type="text/css">
<!-- /{i&Rdf0~
body {
font-size: 12px;
text-align: center; K d[g7Tu
margin: 0px; d*j0X.\2d2h+a4cV
padding: 0px;
}
#pic{ xwuX&@(d8P
margin:0 auto; A!cq p l$S h
width:800px;
padding:0;
border:1px solid #333; 1b-}2@I){]3J
}
#pic img{
max-width:780px; Mr zH j.CB7p~
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); 7\2aN4P3C.hJU r
border:1px dashed #000;
} 0f9v`To5r-d
-->
</style> pO\ue&T"tK
</head> E_8v ]8Wyn
<body> po)r:Q8Z)qc
<div id="pic"> rGz7h)I#LwN
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>