在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。关键在于:max-width:780px;以及下面那行。
[b]固定像素适应:[/b]
7@5Q)ivR ^.w
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> 以下是引用片段:
<!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";> 0P}U*~5Mh;l[
<head>
<meta http-equiv="Content-Type" c /> ^];[ _;H's
<title>css2.0 VS ie</title> 6T eS }yRDf||{
<style type="text/css"> dnS8^2{9np
<!-- :rK Qn4F Y[.F
body { 2[_7TM}+a9l
font-size: 12px;
text-align: center;
margin: 0px;
padding: 0px; l{\|dU.u&{ g
}
#pic{ Nt2K/]BA
margin:0 auto;
width:800px; ?qD9s7]S
padding:0;
border:1px solid #333; o%~p~(pLAS
}
#pic img{ O6xho%[4ois2vo
max-width:780px; VsK6G v*o+AB&Z
width:expression(document.body.clientWidth > 780? "780px": "auto" ); 7}G#U6I{
border:1px dashed #000;
}
-->
</style>
</head> E BUQw%Dzx w,x
<body>
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> c6FmB bS|au
</div>
</body>
</html> L5|5y*M!|`(R
&I{I2GaD
百分比适应::i_i)k^gY[Zi I
以下是引用片段:QYu-v YB,He3N
<!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 /> ,_l AbX/E2b
<title>css2.0 VS ie</title>
<style type="text/css">
<!-- j8~\\7|o y7]5Q
body { h+rd'A)d
font-size: 12px; :J;\;n p%d$z&~U&t1q
text-align: center;
margin: 0px;
padding: 0px; g^z:r*_}
}
#pic{ WvU;K\ G^
margin:0 auto;
width:800px;
padding:0;
border:1px solid #333; |L+e^1_f#b Q8W
} 1H~Hq(J~3vo$u
#pic img{
max-width:780px; 4P jf9J8r2X
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000; k-fJrMNO1Y5S
} }A(D:{,D2_m
-->
</style>
</head> f-H(I5Z _ {8kmE
<body>
<div id="pic"> $Y0x'PV_.x;G
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div>
</body>
</html>
页:
[1]