在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。ap5jvO关键在于:max-width:780px;以及下面那行。
[b]固定像素适应:[/b]G7k8ryh3Y
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";> NH-c{'giP
<head> !L SKn |?6K#P)p
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title> ;xU({-QA
<style type="text/css">
<!--
body { nZHy$laDN\c
font-size: 12px; ?TB~ldg
text-align: center; Bn3Ky.Z R
margin: 0px; !?] p`jk
padding: 0px;
}
#pic{ 7k3aFbS!t
margin:0 auto; N^VGU
width:800px;
padding:0; G*~(n}zX'iN@
border:1px solid #333;
} jW#^-\U1u,s
#pic img{
max-width:780px; "W M)Z/b!vw}M'z
width:expression(document.body.clientWidth > 780? "780px": "auto" ); ']2o%sjQY
border:1px dashed #000;
} 5EF%Ko"Irr
--> Tp*By^R
</style> l7P$Ff)V:BQ@:@
</head>
<body>
<div id="pic"> Owe ?8G
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> bmp ~*S(z+zo
</body> ,B/yu}:~
</html> H\KP;DS@tY
百分比适应:
以下是引用片段:Uh9e c9Cf&S`
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> m!y6f|j|ft*O
<html xmlns="http://www.w3.org/1999/xhtml";> y+v%u^4t-x3Hbz
<head> ;\ n5Q,W:o9I
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title> JNK YZ
<style type="text/css">
<!-- qVc6RL&l!hx"t1{O
body { blL?vt[
font-size: 12px;
text-align: center; 2nY:I[S y
margin: 0px;
padding: 0px;
}
#pic{
margin:0 auto; 3Z([RD9P-R
width:800px;
padding:0; KD ?L:]8FC
border:1px solid #333; +n.JnlD(Hh{q.f a
} ?a T4M R#]2qg9r3J*B
#pic img{
max-width:780px;
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); '\$ov&K&c
border:1px dashed #000;
} |:s&bi.`1s.T`6^
-->
</style> U2Um$i O7EM,J
</head> CA+cU9y&]
<body> Fg&I9K:WM?
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> DeRD:v{3@ `
</div> ZDS/I`"m~L
</body>
</html>
页:
[1]