捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。/xRw*Y(U(b4c
关键在于:max-width:780px;以及下面那行。c7O inQ0Azh,x
[b]固定像素适应:[/b]
.x4Hm*^U)M(b0r "?a k)Kkj
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>  以下是引用片段:
8P:_:PRJv-W <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> p_5q_#] eW|
<html xmlns="http://www.w3.org/1999/xhtml";> 9O!~N0h?
<head> :N:[QND#t6]$d _ [
<meta http-equiv="Content-Type" c /> ]l ~ B9` R%y'x8L"xI
<title>css2.0 VS ie</title> 1Q1j GG{c:h
<style type="text/css"> 8s ?6j)y\/lj
<!-- }_ E#h7g
body { 7G)qx C cy#eD _r
font-size: 12px;
sH"Gbd P Q9f text-align: center;
h(n*c)LP? margin: 0px; $g'F+`*b8R[3~O#q
padding: 0px;
Mjm T*] s o } \-@,^5r/{*~4Amj/R
#pic{ ${7r3P-? ~2l
  margin:0 auto;
!Xg(b&N.eC-F L'{0I   width:800px;
Z&p&}.eJ,p!yH],T.g   padding:0;
mw!mSO N0Z   border:1px solid #333; ,j:BH*h.~0Z q"g)b H`
  }
'g"di]W #pic img{
(ld!Z r(uq*og     max-width:780px; xo9i6ZD}!a+h]"C
width:expression(document.body.clientWidth > 780? "780px": "auto" );
k*A t9Q|6V2Z+R border:1px dashed #000; K,p A!ki~8`d
}
FE,eoi/a -->
M*xL+yz"[ </style> L.A1n'pk
</head>
,Le r5wa8W <body>
$YL/N'U*U_$R <div id="pic"> %m&FG/A0E:B
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
4W6{,Af$A4i </div> *C@C#b*Fc6U
</body>
u k6EN\ i f </html> \S9k4X0b|'AB
8pOOU&x*yjNgG
百分比适应:,}T [sy+S
以下是引用片段:g9{%L-Ua&pGg4E W
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
l&w3M-\a <html xmlns="http://www.w3.org/1999/xhtml";> Kl~#B d
<head> .a;_q&ax1SsA |
<meta http-equiv="Content-Type" c />
.W]7lw(Q9D!r.i <title>css2.0 VS ie</title>
6c/K$\7eva <style type="text/css"> bLv1@0gttL
<!--
6t j-J@WH-h body {
h,xdk3Z:l;Aj'H0H2Y font-size: 12px;
s#W T^$iH text-align: center; h(m c J?vs
margin: 0px; )l0]dM/I c |'J1Q
padding: 0px;
/}$iOr\Z } ~} c_"P!m
#pic{ .v7j$^9n~%] ^4{h
  margin:0 auto; /u H%V N q
  width:800px; i/B)b1d~
  padding:0;
S9wl"L8Q w2`?gL   border:1px solid #333; ^:sl.Cb5Ng1k a^a
  }
0x#F4q-my(y1n #pic img{
3z%Y!H NU4a     max-width:780px; Hj7ZJ l;u(an
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); Lp7n1H s(g
border:1px dashed #000;
VR eg3J1U }
#vi*pd0f+e&| --> F/O1E1s u u4l
</style>
3@0{W!?'pQK </head> 7^n2}Bm~Mc;C
<body>
cF M j lZ <div id="pic">
u9MFqvBS$] <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
;P ^,c7M8Qm3`p'{(_ </div> 9X~+M ED4h\
</body>
*w Nranl </html>

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


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