在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。关键在于:max-width:780px;以及下面那行。
[b]固定像素适应:[/b]m$l"l8B%Y;] tU
6m ^_c!LVk5R6x%O
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";>
<head> /nZ?7N P6Mghk _
<meta http-equiv="Content-Type" c /> d3VzbF(t6l1\
<title>css2.0 VS ie</title>
<style type="text/css">
<!-- U"YD5r'Sk3zC4g(J"ux
body { 4{ p'P7bj
font-size: 12px; tFZ1e&]#k1Q
text-align: center; #Q#K]7[c&|u1zf,v)O
margin: 0px; +i,J[F_S/Q
padding: 0px; 0Lq%K4Sr1t O
}
#pic{
margin:0 auto;
width:800px;
padding:0;
border:1px solid #333;
}
#pic img{ QKRvU*g R gT-mP
max-width:780px; ,DX+MIVc \
width:expression(document.body.clientWidth > 780? "780px": "auto" );
border:1px dashed #000;
} K2l'LDKA8Y%{)Q
--> N:}!m8g5g4Vh;u
</style> H6Z Lyc8XE}M
</head>
<body>
<div id="pic"> 3B` t)Rc2vi[ y4A
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div>
</body> sUO Y`{A.G
</html> /t3q_3e aK$f1B
O4l|KgG/h%p
百分比适应:n4DiFf smk
以下是引用片段:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> :Cx"p,E-oa J:`3e
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" c /> ]c w_N s.k
<title>css2.0 VS ie</title>
<style type="text/css"> 2b$k}3f"y3w6bS
<!-- 4Z$S"O3rb0~z(L
body { "_L/G+KkP W&H
font-size: 12px;
text-align: center; 4T k.q_MXE#h
margin: 0px;
padding: 0px; tQv&Uu]
} dBou4z1Ta
#pic{ ,hKWH'~"r
margin:0 auto;
width:800px; CH?)Psi/Q6[ wG5y
padding:0; 8CO7EW6zx8J
border:1px solid #333; e%Yy osK*II
}
#pic img{ -P.cx/^:b,cW{
max-width:780px; *f6[X-l3@Zm'Q.Gko4W
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); :rk+x`yr
border:1px dashed #000; 5D(`7S8rGMGN}+B
} tRg]6r5\hjW'Z
--> 5atguKhi7M2j
</style>