捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。)~O'} G3Tb-h
关键在于:max-width:780px;以及下面那行。eNYp*QP
[b]固定像素适应:[/b]
U8f(DCQn .J!TKKP*[
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>  以下是引用片段:
8_\W'U!j2\ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
K8}"jm+A m <html xmlns="http://www.w3.org/1999/xhtml";>
[5J+hj"P!^ <head>
)nA!Ue&a"k8[b3h <meta http-equiv="Content-Type" c /> I!J0\hb f
<title>css2.0 VS ie</title>
| \jg+?(o3G \ <style type="text/css">
aP+H7]"N kY <!-- ,UTG/h&Br
body {
,~N)Rrv3nY ^ font-size: 12px; J2\ wL$[Vt(^
text-align: center;
/TT0J.i6s|z%X+hd margin: 0px; )Dj E!eb;gg+Ur
padding: 0px; -F.l'm0|8r?7QR l.g+c
}
[*N;WD8Vto tsC #pic{ 0y3s^Mz*Wg1lR@9m
  margin:0 auto; V:Yrl zqU{
  width:800px; cc^%O;a_&T |u
  padding:0; /h*K2jVz8R Pn-W8_
  border:1px solid #333;
x,Z aB%a @ vcs#cI   }
[7ND/~$w #pic img{
2x(B8w$M[     max-width:780px; ~C zN(@
width:expression(document.body.clientWidth > 780? "780px": "auto" );
o/H*K4tTp,r o SV^ border:1px dashed #000; .R,]rBEL YS
} K)~-TOM c+g.V)d{4y Z,y
-->
fH7er z*FME ^"E </style> /tch;a-{V
</head> 7C h9|8a MC
<body> ,_H5_Ta8v&?q
<div id="pic">
Xkdv9j+z <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
@i0] D*@v(X </div> d0x&[0lwNq
</body>
OA;H L8K K </html>
:S OB*b+s9[bkM
0v}My#GD 百分比适应:\)f7g1[$mY5q1w
以下是引用片段:
lT]YXzGA ]f <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> c1c&b;C9q Q3m
<html xmlns="http://www.w3.org/1999/xhtml";> ;Nv7Rw*u0J
<head> cd(j`a(SUE
<meta http-equiv="Content-Type" c />
"DQ tn"G3{o <title>css2.0 VS ie</title>
K(S-faA <style type="text/css">
H+ZZE/A;vR <!--
R;ks R3f#cS F body {
+M[:i"x1Y2d L'd8P font-size: 12px;
d+d8F$C6@.OX:eb)L text-align: center;
4_@d6ph4a*y a#z2b'c margin: 0px;
6Qt{,K/z^L)dD7z padding: 0px;
n4g(xj$vZ+u }
w(c)Om s6O ?^%rKj;] #pic{ G{2f8X8^+{
  margin:0 auto; 7qF6g4}LNr
  width:800px; mEb]*r4O5M'S
  padding:0; J(X7j6IGoc l$w7A
  border:1px solid #333; }(dH2E+qVd
  }
X bO_u0Z WP}Lh #pic img{
~iF+}R.Q2j     max-width:780px; fl ka:h%}
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); 7L-q3mk N
border:1px dashed #000;
4\YA,tC5q3N }
,i(k0D*o.v2MAu!a'N -->
0~K,m4DMq+lm </style>
,oncP!s9t </head> }F'j'p!SX)b
<body>
t7gLHEf\ <div id="pic">
|!h1zm:R8\ <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
W2kRO|5^6W%d </div> 'FM#q{o:Y\.CNE
</body>
D"Cb,k.V H </html>

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


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