捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。k5h*J ?t*aD'y
关键在于:max-width:780px;以及下面那行。
i#sW"]-kx9y1| [b]固定像素适应:[/b]7EO {+up-V

-k7AipH7C Iy 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>  以下是引用片段:)al? l#?zq
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 3P&E,d @"yp&DEl
<html xmlns="http://www.w3.org/1999/xhtml";> e+E,KDv+R0I
<head> k@P&j!~9] NOj
<meta http-equiv="Content-Type" c /> e z0CX`O+kj%p
<title>css2.0 VS ie</title> V ^3}Q nL
<style type="text/css"> I)x5\S}2S$k}:a"T
<!-- #L/vWEo
body { &q"G6@:@JXaLH
font-size: 12px; b!k!bA!X Z
text-align: center; ~ y?daQ L4tZ
margin: 0px; 5Q9AO ]~ A'w
padding: 0px; 8g7@eS#k7@*T
}
wU+@:T m3Z #pic{ O~`ERD$}
  margin:0 auto;
WqW$gl/c,X/B.xBp   width:800px;
}fp/v~.g~1S   padding:0; il0sC N7Q
  border:1px solid #333;
\'ThUp+P/]e*R6d   }
-Y)U@}.g\x'y #pic img{
#I`'Q3N}*h(ka     max-width:780px; 4c m1k0`Z%C cu5w
width:expression(document.body.clientWidth > 780? "780px": "auto" );
6QS_t'A2A| border:1px dashed #000;
B6v'M3OH{7k } 9m+zi[5_8`C(Y
-->
:?*i4m{3gX~o </style> !agn+vu_q Z
</head>
-ilSK/p{ <body> *{pfJ.d Mh+? _H
<div id="pic"> 2NEi$]#im'{y(T-E
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
1J+em[eb A-s </div> pdk_W\ p
</body> L,D@y b k*o
</html>
?ZO2{8e+N(@
!{fU}*I0_G1Xh 百分比适应:
_U ED h}P}U 以下是引用片段:XDr-o Y} G'] A
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> mPi N E!A7[.B6G
<html xmlns="http://www.w3.org/1999/xhtml";>
s1h4YM(mjsr8k <head> 9s0vH8qDpb|O
<meta http-equiv="Content-Type" c /> (A }?k)n6R
<title>css2.0 VS ie</title> %Uy#y ~-T/}mX
<style type="text/css"> NU:f1[w[
<!-- [J9Xtp!qe#|:X^5so
body { Om Hb,c+gW
font-size: 12px;
nI ?ar tg] text-align: center; "r];B7F.T
margin: 0px;
Pm7C t QR|/C padding: 0px; 2k edH'ms s
}
?/cI!t!F9} #pic{
7zo Q3biy&i9r   margin:0 auto; 4J3F o @!b7z/y
  width:800px;
7} OY f r0x tg   padding:0; :@J#K^4\
  border:1px solid #333; 8K$LL@0{
  } 0_.]G+sX
#pic img{
(g-L)z3rWO Yp4Euz     max-width:780px;
g eEsL)?G:X'l width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); qrEV+{z%P9Q3B
border:1px dashed #000; 8}(@O4Yo"gs
} $B|Y8H'v:V
-->
{(m8b} d3UeZ ?G </style>
1Q C+iH7Idt </head>
b Y4H*w#G <body>
2BpnjcF(m0O <div id="pic"> c\"htn4]5N2u
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
!X;gb LQ4],B </div> +d a _:W)u)X.YU U%e
</body> 6u3mg iQ9W6Z
</html>

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


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