在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。?$|RCk$Y关键在于:max-width:780px;以及下面那行。SVt \V;j)`B+^3G
[b]固定像素适应:[/b]
G1h(PZ-q%R Y#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> 以下是引用片段:?!t}]C*q
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> (y%C?h.V
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" c /> ;U-lf+k9d^
<title>css2.0 VS ie</title> Q{+B%{,~0kcJS
<style type="text/css"> :Z\,{2z7p'O%XN;UT
<!--
body {
font-size: 12px; "}K#pV$O-q)d
text-align: center;
margin: 0px; A%?y6eK
padding: 0px; 5w V+Q/E7r m3j PQ#c
}
#pic{
margin:0 auto;
width:800px;
padding:0;
border:1px solid #333; Ip |,tWM5Q1Ib
} 5@5YKsy|%h
#pic img{ h(j1am\4D%J"e+h!Z
max-width:780px; jd-C0oK eW
width:expression(document.body.clientWidth > 780? "780px": "auto" ); aK `Ec%r c&AC0Hz5T
border:1px dashed #000;
}
-->
</style> y_1i+kanu&U+Ks*T
</head> "WF5u']R_:w7{
<body>
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 'iImK8z
</div>
</body> ,w.kXB%o0d2T1Y
</html> $HQV%\8m
p}u Yp
百分比适应:MaXS YOg'Z|R
以下是引用片段:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> !Q#[T!TErJYH5{
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title> [@h1Ic)I)h7h"y
<style type="text/css">
<!-- -]T N;^9ih
body { )rzf%I[j+v
font-size: 12px;
text-align: center;
margin: 0px; pa5{8d2uSN{9}2J
padding: 0px; WX S0\Y$e
}
#pic{
margin:0 auto; { L*c8S6I,OH
width:800px;
padding:0; /FO8S6W0YV{k't/I
border:1px solid #333;
}
#pic img{
max-width:780px;
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000;
} :x0_4dj/H
-->
</style> ~3y+ye#p4q3D"{
</head> +f} A1U(mu-z{9o
<body>
<div id="pic"> 6T*N'K t!E vJU'G3i
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div>
</body> 5^x9gWq}w7B_
</html>
页:
[1]