捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
$[!spJ0yYZ 关键在于:max-width:780px;以及下面那行。&zQ"xA,V
[b]固定像素适应:[/b]
~]"b {/Qz Pp r+H+|.b5@
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>  以下是引用片段:bf7m6F/aXK6K"v0{
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
r pt.X;mO7bK <html xmlns="http://www.w3.org/1999/xhtml";>
]R4kc3F <head>
SMqee <meta http-equiv="Content-Type" c /> "G|0U ~(yYZj
<title>css2.0 VS ie</title> e?bf |"x
<style type="text/css">
Rp$S*iw'W t)x <!-- hW*l.d8wT
body {
(O(EIrX1|$M~ font-size: 12px;
$C ~&HJhsJ?xU text-align: center; ?iC)~1kp]L&}
margin: 0px; %?}!S-it@"k)t
padding: 0px; 9b6K$EF.c,[-?
} ynV1wsbe
#pic{
0w+\O*N&n}@N S   margin:0 auto; ,s~ FlDD'H)~a%H
  width:800px;
e[+Rq0e;V0IF   padding:0;
G#r1Ez(b)|%F%j};m   border:1px solid #333;
]/Mg6p D V   } 2o9}:xJk e~$k9N
#pic img{ $Is:l F@r
    max-width:780px; P-IGu3_)] ~
width:expression(document.body.clientWidth > 780? "780px": "auto" ); MZ a#b2NH
border:1px dashed #000; 5kchb-E/S
}
|xH0pSD --> plp"Y(x:p
</style> ([,|6b'Bv
</head> 'D ?]Mc8B
<body>
p"P[I&n~fl4o <div id="pic"> ~/B q9B.Wc2l
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
.b oj(M k7s </div> 1~u0[4qBK
</body>
.RGt ^9V_"x}F(E </html> K$~5HIQe
0@+MG-K!iM.}8dP{'o
百分比适应:
ke(_3y&B"NDrQ 以下是引用片段:
^ac#R4l0N <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> S%i_`4`L u z w @
<html xmlns="http://www.w3.org/1999/xhtml";> *p'T3a}*_4{7`2b
<head>
9x2sb/f8D$r-nM-I <meta http-equiv="Content-Type" c />
DBCfnKT2\u)RF <title>css2.0 VS ie</title> `'S+U t'skN)M$mw
<style type="text/css"> L(fJDf E
<!--
rq bQ0J sr`` body { n+ngfe Uu
font-size: 12px; r9|/L)yX T1B,jW
text-align: center;
h3IRO@ margin: 0px; w7d)RW%cNC*IV
padding: 0px;
$}U'o4C5^Y*r-Z)\ } b%`4q;NVN
#pic{ _#L|q-ua9U _
  margin:0 auto; P0~A|N'[c
  width:800px; 4J5A;SesCs W
  padding:0; &m*N$e ~ X/m Y
  border:1px solid #333; Dm5R;C VC'~t
  }
5ig2F[*] t~q\j #pic img{ U rM&u([4a/H$k
    max-width:780px; QP-nHGH,Y
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); ;n C9iC&w bC+jc&X
border:1px dashed #000;
8~^/d5w+F }
2h"{ L)j6V!{8xw --> Af.|G9a,@zh
</style>
B%O?*Jx wy1Pd </head> %h]&lzq
<body> -O?/x Z!sN
<div id="pic"> )aQ(g hF;B5|+\'y
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
t's.wG`wv9U/X0Q2])eB </div>
}5L8@-I~*Vv </body>
`*V!Do VtHRUs </html>

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


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