捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。+`%R(v s8b3NYVh{)q
关键在于:max-width:780px;以及下面那行。S([@2A3eq
[b]固定像素适应:[/b]
G3`f[2^4WS| jDwK.?~ j h
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>  以下是引用片段: InK#L,]2M
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> /XzrBl4Y
<html xmlns="http://www.w3.org/1999/xhtml";> b7a"F}(o.Lo
<head> t&nQ4l1m/}3DC$Z
<meta http-equiv="Content-Type" c /> U I!{J,f}
<title>css2.0 VS ie</title> [xq%Gy.?F
<style type="text/css">
l.p~(e:U `!OA$|!f p <!--
#rv[h;n9R9h body { ^h8D%^J$J-Z
font-size: 12px; *T!\'J3@$B {
text-align: center; O @1vm u3A#xO;o2Q
margin: 0px;
l \8]bOv padding: 0px; MNxg-zC
}
i%oS!DK)MB6~ #pic{ 6bc_P&F G
  margin:0 auto; X9w/j3f"D&l;Wq
  width:800px; Z5d.J)X+p*z"y}`1t
  padding:0;
(v:q4N+A^!RTw   border:1px solid #333; k,uBn}e
  }
T&c z]"B| |i #pic img{ i'e M)pj7G~3@5u't7p(r
    max-width:780px; xJ:C4[RIKm
width:expression(document.body.clientWidth > 780? "780px": "auto" ); I1z+`0k.f0x_
border:1px dashed #000; B_2\^&W ] @*lKe
}
%KB'zl-\ --> |1^ d7U5UI\
</style> jD%Y%@;A?9wf
</head> DZo }2t mRm Z;O^
<body>
.{'Yg e'[9\4y h1a*r <div id="pic">
SxD&U?:Xk3IA2B <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 1lA|~R hd8j
</div>
/u~Y/geN </body> (xo V+zf3Z-s
</html> p,FOL U&m0~9`
4Td7R$k2Yn7qU MzM
百分比适应: t]if%hFrVa
以下是引用片段:1j_3`W^5xv
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 4V R'Q;a1NS$DM f]5C
<html xmlns="http://www.w3.org/1999/xhtml";> vC~1FQQj
<head>
!@)D!M5h;{(F7a$N <meta http-equiv="Content-Type" c /> S+qT4h5s:ZG,Q
<title>css2.0 VS ie</title>
Yj P7KmX+z <style type="text/css">
a;dz%yJ@ <!-- `4\(|U8LME`6UO
body {
#fj+f.v+g rTF font-size: 12px;
*|/tMm s Z:z7q text-align: center; .Fp%f Q*KY
margin: 0px; `m c z X1@p
padding: 0px;
i-u`.kH }
/{)^nA8~ #pic{
'E f8E#Z0H1XXlei   margin:0 auto; _2a$ARdZF;D_
  width:800px;
}RF]'vx"dB'c W{   padding:0; #Kba6L0YFx2t'|
  border:1px solid #333; U{/x!c~9n W5f)_._
  }
#n}(Z-Z,F'hL%I #pic img{
7o3j+NYmXQ6{     max-width:780px; {!_iU?t.~M6^l
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
#h%|DD$k } ^ border:1px dashed #000; 0L6t$Q4K}6g
}
(icc|R4{r@u"m -->
)?R*s C'DN#o </style> n)o AC/J)wjBex
</head>
`"Ej6PI6D$hyQ!J <body> Q)o f|!O-{&u\pEHn
<div id="pic">
h7r%@tfl};O+r:_ <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 0@4h,_%Vt6O
</div>
b+j~D9pP </body>
GN li1Q6B:p8h </html>

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


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