捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。FA V.^O"S9L
关键在于:max-width:780px;以及下面那行。7jh \U,]W
[b]固定像素适应:[/b]
+HR)xF T7[%{j*o
|/r/DSG 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>  以下是引用片段: {{6A-Vfe"G2@S D
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
2GK i-p F7F2T g u <html xmlns="http://www.w3.org/1999/xhtml";>
rYYQ5^&P <head>
]kA*~_'H4] <meta http-equiv="Content-Type" c />
Dk!L/s |7~ <title>css2.0 VS ie</title>
)kq~ G/_*E!bl <style type="text/css"> &P yy5?5W2n
<!-- y,w'tqg,G
body {
e1f Xf6Iq[ font-size: 12px;
6XB6SrG3k/xRC*[F text-align: center;
2r`/d*sTk margin: 0px;
Z!L qM#qZ R[{cK padding: 0px;
6Pe1q?F0] } am5Z,CL q.AD
#pic{
s1h#yC*J(d1x,s*M z   margin:0 auto; o%[@`t.l f P
  width:800px; &nsx\+F%E
  padding:0;
%joU4k1|9R#g   border:1px solid #333; _&~?!lq$w;Y a#C_
  }
\[@5E]a&Lx #pic img{
0@:Ef0xvpj     max-width:780px;
)iL~P{Z^ width:expression(document.body.clientWidth > 780? "780px": "auto" ); d lC4Xi\{@Q9] S
border:1px dashed #000;
-Ra9l0i:`)Q8a } BG2JHo
--> yrkuNM
</style> Gk@e;r#D
</head>
/?q\#S js!n.}k <body> :V:OyY5s
<div id="pic">
}0Uv3Z?{ <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 'G DIb f'_
</div>
]:| f @:lCE5^ </body>
2rJ-J*qctY\ </html>
"nLe_H fi_ku
.W6x"`(U%K Oa 百分比适应:
AC2x4A4E 以下是引用片段:BbU!d5Xv
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
6IR'fyj/]4U$[ <html xmlns="http://www.w3.org/1999/xhtml";> (D3_#CY+E+](fRz(u h
<head> Q_+juZzw.cR_a[
<meta http-equiv="Content-Type" c /> R V+p[/fN#D
<title>css2.0 VS ie</title>
'@;Up!a_7WO <style type="text/css"> "];`&Yt0{*Ej
<!--
6w Znh#o0jm)g0l body {
Zt)l[C.S| font-size: 12px; :W6VfW:jGx:s
text-align: center;
1G7@ QE#r/^}8gB8~ margin: 0px;
VJu3Qj padding: 0px;
&U.O,t;H@ } Ih-Jj8TT(n
#pic{ &s*g8z2U R~Z
  margin:0 auto; 5F#Z,_wn6D1A
  width:800px;
fpN7P4h   padding:0; j!BV*{8w!k!N
  border:1px solid #333;
N1\&wK-]1?C#Bcs   }
{'cH*c.@ #pic img{ /q8F0g&H"uW
    max-width:780px; z5i&q&^ H8^P/V
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); %T#[Z(v1N5Z&b.i
border:1px dashed #000; E@!UL9?&|%]-Z
} )J,p$h m6o-m"N
-->
\x.KQ~;sX&| </style> ;rN+MU0G
</head>
C-{-Z5u Ny <body>
W"k"A}vQ| Gbc <div id="pic">
Z3SUG1|m5w <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
v.EW0PG'f </div>
)sCC X9hSG2s </body> #z&|#N\8L t.x[(x
</html>

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


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