捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
!TJBL M+Wb 关键在于:max-width:780px;以及下面那行。g~#P8g0OF'Tp
[b]固定像素适应:[/b]
E xP/f0R^wh0C)Y(E4m .S:w4M2Y.p5xT7{.eV
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>  以下是引用片段:
4HsNH#hU g <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
%^0?x7Eb-CxE <html xmlns="http://www.w3.org/1999/xhtml";>
/g5]J#x@4@.{ <head> ;gT EiwW~1~
<meta http-equiv="Content-Type" c /> ,_9hF$|F;c
<title>css2.0 VS ie</title> G.`.z? fI
<style type="text/css">
8f }[pDIlq!R!Y <!--
v BEE-_M{6T body {
*Ib9~foT%I font-size: 12px;
#y&r qz _"w"U text-align: center;
d(p(o4Q6Lj adc margin: 0px;
8Y?0R7A]S{"RG padding: 0px; 8uc`&Qnj
} :M0B_U:j0X%UUo
#pic{
!}u XG2O^T   margin:0 auto; 9q^(T`9AY9kR/O
  width:800px; ] p6n1_S/y
  padding:0; lhOC ZJL
  border:1px solid #333; }?9c` _
  } !|te4\M9e
#pic img{
8gD0g"ZwO     max-width:780px;
5Wb/sE/{F width:expression(document.body.clientWidth > 780? "780px": "auto" );
N \6[-E-N$H border:1px dashed #000;
id;l'Vh,~ `7j(? } e!u q \%{,j qu:l
--> %gQec o#y
</style> qvclxD
</head> UAO/p,j8uBwqw
<body>
_$e)r)lr <div id="pic"> -J0D:~v(H'np"_/r
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
6hlUc"} Ziu </div>
8r*\jpOX </body>
w|)sa ti*L6Jw </html> [+j#B*m9\t0oEdh.k

^$c \;`k$I 百分比适应:b6ZoO9\]
以下是引用片段:l6~7s2t!d7C
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> u AU?&HR
<html xmlns="http://www.w3.org/1999/xhtml";>
7Y%^kri)K ^'T <head> 1K0\2I|7C0F[MIc
<meta http-equiv="Content-Type" c />
2A(d2E }t wg <title>css2.0 VS ie</title> u7L#] e}suU
<style type="text/css"> EO:^+}LK'U
<!-- v| dsT(o
body {
:Z3K Wl"zQ font-size: 12px; .[ ^0hS7Hh2J
text-align: center;
5^5{(sf }^ margin: 0px; &]3S D#V3T8q
padding: 0px; #wd,GX;r Re+R[
}
Vcj2iV^ #pic{ 0_ KT,o7EE
  margin:0 auto; T[5Tk?Hn {oxy
  width:800px;
s/^:l!o olAj   padding:0; ufncre!D
  border:1px solid #333; |(P\\0`W`'B
  } 'dR"U2a.G+|%@3Z
#pic img{ #Cn.o h&^ED2M*B
    max-width:780px; o8f3yWw@
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); #GV nI K.aeH+A
border:1px dashed #000; F O L2?/D2u(pz n
}
,S$o V4JM8I:X -->
N1EcE rW </style> +d.\-[/JC6`~
</head>
wMk*l8Kv <body> DP9T%Ef"jKJ1hYr
<div id="pic">
fCkDE*Ky:n L1O <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
#}-J\a b{e </div> ck*M$o d$F
</body> (mfC!MRZ"t
</html>

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


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