在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。^~6tOm关键在于: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> 以下是引用片段:+gfJ!J rYH
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> .v#s|;l]1Z Az,e
<html xmlns="http://www.w3.org/1999/xhtml";>
<head> (`+Kq3ybP3o%SJ J
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title>
<style type="text/css">
<!--
body {
font-size: 12px; -A;?T;u.n+k&W7d)s3]
text-align: center;
margin: 0px; 4q%~ n6r-L*K1R3n
padding: 0px;
}
#pic{
margin:0 auto;
width:800px;
padding:0;
border:1px solid #333; Q*x5h+bQZJ9w
} du9pn5^
#pic img{
max-width:780px;
width:expression(document.body.clientWidth > 780? "780px": "auto" ); SGfop4J
border:1px dashed #000;
}
--> %z H!bB1]u-H&m \ sZ
</style>
</head> oY!Ysr"dg
<body> i(Q'y5WE0l]T
<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> )CCd5s^SNJ
</html> Q tjF4J+QS
a4G.|2m#x [
百分比适应:
以下是引用片段:(R%z `v Hq'S%NQ
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 5K}UNWdK&y[^
<html xmlns="http://www.w3.org/1999/xhtml";> (Onu#Vdf
<head> JO{O{
<meta http-equiv="Content-Type" c /> y.D@.gK P
<title>css2.0 VS ie</title> 7y _7p3lC$Oi
<style type="text/css"> I:Rwf.i
<!-- Pr-l:xA|5r
body {
font-size: 12px; #Ro2Fd TDaP
text-align: center; 5WfdG4k4R? |u#f6H
margin: 0px; +I1HgT/X Qr*`
padding: 0px; 7^et+a/~/~aC3S&_2C
}
#pic{
margin:0 auto;
width:800px;
padding:0;
border:1px solid #333; U-]}*n,b!k
} !pTm uw3zH^
#pic img{ $RR1r0U[R|Y
max-width:780px;
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); WKI~1Affi:E4i
border:1px dashed #000;
} `N\B0iN.kf Q
--> M$N}@#d*^-A
</style>
</head>
<body> CX!h/V*` T
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> 7]8er*X$Y2S4U,pO-q
</body>
</html>
页:
[1]