捌玖网络工作室's Archiver

admin 发表于 2007-12-8 14:55

在DIV下图片自适应的解决方法

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
3OR c@.`Z'W Z+O 关键在于:max-width:780px;以及下面那行。
!~Y RZ$}+Ln B mo [b]固定像素适应:[/b]
4j3rq"N:RM#L#y !k0G](q;W,AQY5[.u:s
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>  以下是引用片段:x4zIqm8m
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> ,TA;I^V y Nxx%w
<html xmlns="http://www.w3.org/1999/xhtml";>
p~/q\.vFL3E x <head>
@$q8Wo0j2s <meta http-equiv="Content-Type" c />
)fd+h1n-t{Q,D <title>css2.0 VS ie</title> 4{{'po-eoY~ Sy
<style type="text/css"> 0u*ADk$F-SzM
<!-- 'l_!c(Os?
body {
]7m@ V9X6k font-size: 12px; 9F_&t5k8l1d ^ ^
text-align: center;
+m*FP(_yZ7`(rb margin: 0px;
6o3L!^6S)G#C:r q padding: 0px; )\[6q(@CNul
}
-_'f3o AP,e #pic{ U1b-F4N6Kb/@e|
  margin:0 auto; +xc,]teC9j
  width:800px;
TX6rR3f+a   padding:0;
wZL ^ PCeV8l*a   border:1px solid #333; P%sJCG0G5vkP8N
  }
5z8^w(@E8kl#Mg"|"~ #pic img{
3h.Nb`0S {P C$sN0k     max-width:780px; kT(p(@,tG)FC
width:expression(document.body.clientWidth > 780? "780px": "auto" );
q_II;MM-j border:1px dashed #000; L,@c"BpQ6A`e
} ao9r.l fln7c E6X
--> [][^z5U:Jd
</style>
kO*}[5j$~3] </head> NNhJ We0c
<body> Y\tof~*RT
<div id="pic">
{A&s})I1N.v <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
$|#A%wE] ] </div> 8f6b/y2g h(o.kLA\5G
</body>
*}2L^!T d,v W'E </html> *W#P%_ {7K
TlJ C ky
百分比适应:y+c4GY)nL!{ SU
以下是引用片段:"M2_(Zt.u?{FlZ$u
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
[6Nt8Z&?X <html xmlns="http://www.w3.org/1999/xhtml";>
o)c4M2@ KV6v bK;P <head> "K#n}hZ1p] l
<meta http-equiv="Content-Type" c /> c2o^vD0K0g9Z
<title>css2.0 VS ie</title>
rL:V\M m b <style type="text/css">
X+WPt(m1C <!-- 0f K'D:r/N7g
body { v @~c:?7[ `+{
font-size: 12px; 2y'e:L a1Y9kr s
text-align: center; {GR7eigv ue1I
margin: 0px; :X%G5a,B0w%~,G
padding: 0px;
7NN1GKfx%T#L } ,c,Hc4Z&xzPo
#pic{
@%`1M.D'[u|+a9I   margin:0 auto;
D-U;J ro'|   width:800px; i3RelfRNt {:{
  padding:0; V:H bu(e
  border:1px solid #333;
)d.g l~I6m z   }
9u1RA T:_+Z #pic img{
0P`/o.U7Q N     max-width:780px;
|Rt|uc width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
7Qh.{Sp'I border:1px dashed #000; 3K,~ Q!LU0ADN&Z
} p6s zA I&d%X6|
--> 7DX!X)O9J
</style>
dz&Z4\,}J </head>
#Ibp#c-Z!h1P <body>
X;lr7Td <div id="pic">
V[(`ongB <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> R,PS6J_l
</div> _*G1kfsu"W T
</body> /R^(py_&E
</html>

页: [1]
【捌玖网络】已经运行:


Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.