在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。R$MT8@:I(O&_0p关键在于:max-width:780px;以及下面那行。4u~2wv%mS!M*]U
[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> 以下是引用片段:*_gj'|i.@"d7gn+P
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> [S{$r*B9^)|P
<html xmlns="http://www.w3.org/1999/xhtml";> 8X:d6aLPw6~Bsl0M1b1Z7`
<head> i5uO(E2L B
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title>
<style type="text/css"> By+g+\P
<!--
body {
font-size: 12px;
text-align: center;
margin: 0px;
padding: 0px;
} $e$h5O6d I5j
#pic{
margin:0 auto; $Z:TY#N S!rm6`0U
width:800px; %M?/n!s[G
padding:0; %Jp v(G*F
border:1px solid #333; %Nq#r,{6F,Y!s&^7d
} U.c'KD?6Z7HE-r
#pic img{
max-width:780px; u ?'p lV)w)m"Y
width:expression(document.body.clientWidth > 780? "780px": "auto" ); a'zY ~1B*k{
border:1px dashed #000;
}
--> S9`(s2X0mr)K
</style>
</head> 6a r he^&S.Z
<body>
<div id="pic"> v|%d G4G
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> a Y9EC;p#d%q
</body> &z*XgNF#dx1Y2G
</html> K8Z#_ S;C
+z1tMHJ8B;|M;d
百分比适应:
以下是引用片段:
<!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 /> K `O#M&J,@J^;a U
<title>css2.0 VS ie</title> pzP_9^ y9i
<style type="text/css">
<!-- 9~6~U&_&y5c"H&l|o"H]
body {
font-size: 12px; $PAi~*~
text-align: center; 1oGEAh)w1?
margin: 0px; 9R,`1qxb/nUz
padding: 0px; &NlO#F fM)r a
}
#pic{ #?"O"CPU L |
margin:0 auto; eE?$Q*x
width:800px; )rp W/EMdS/y-O
padding:0;
border:1px solid #333;
}
#pic img{
max-width:780px; uDZGYopc2[Y'a
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); #TjEV m1p4i
border:1px dashed #000; r8t+E@[5T)Qrkn3U
}
--> 4S!q/bkbT'c @v~
</style>
</head>
<body> 1y-a(w"p2by6Y8F.t
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 7GFI0C P7Wk1u
</div>
</body> 3G:~:U#r&Y}t#B
</html>
页:
[1]