在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。%\QU} SM4e1J关键在于:max-width:780px;以及下面那行。
[b]固定像素适应:[/b]
)u:AUZ1B!k
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> 以下是引用片段:7c h'J ISw Z{
<!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>
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title> vqP'lG8X$o
<style type="text/css">
<!-- OLS5E~|YdJ
body {
font-size: 12px; CJ$cjqe8O C`
text-align: center;
margin: 0px; @U"v9W/be$t
padding: 0px; KT.HZ!y{`
}
#pic{ "|H9[5b9Q`qT&O
margin:0 auto; ^F5uh7[1b#@
width:800px;
padding:0; M,cl&Iv"TE
border:1px solid #333;
} $HB.fP"l/?yR8b
#pic img{
max-width:780px;
width:expression(document.body.clientWidth > 780? "780px": "auto" ); &aO @K m$X&x b7J5j
border:1px dashed #000;
} &F@N K h%_
-->
</style>
</head> V8Z y%o?4?+L+X
<body> 8l.M @6pN i8]&V w
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> +q7_3VR h$}Hh
</body> 6G"] @:ZhC
</html> |{Z;U6H:j u
@&w!~ I5f
百分比适应:,O7x9yo&tm~8Xu*m
以下是引用片段:,z6DI3oE(G'|g|&P
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> $mR$I&s,wE$je9Nl
<html xmlns="http://www.w3.org/1999/xhtml";> 'DY\3C WC"Y,T6^
<head> yyEc9~_ A)f&`
<meta http-equiv="Content-Type" c /> 8x2{QZN#qhdo
<title>css2.0 VS ie</title> 'q|@r$gEiO
<style type="text/css"> 0_.{9m%u}
<!-- 1pd&Z/v7sNPB]
body {
font-size: 12px;
text-align: center; KQBHN{&q8f
margin: 0px;
padding: 0px;
}
#pic{
margin:0 auto;
width:800px;
padding:0; {F&CshB N
border:1px solid #333; !u:{Z&_^
} 5w3nl_-g KMlhx
#pic img{
max-width:780px; /@]S,zU1zs
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); :x8y Nv,L1{D c
border:1px dashed #000;
} B(` xkt`9a-}4N'h5S3f
--> ^ ZOW#D/V:isl/g
</style> T(U/T:v|u2Gw
</head> ;P_w'v6m y
<body>
<div id="pic"> {0x5T8q f
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> .i Lu9^+H7TT
</div> 4DlRhO
</body>
</html>
页:
[1]