捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
5ihZzl'f 关键在于:max-width:780px;以及下面那行。
U?9QBWn&_"A,K [b]固定像素适应:[/b]
gD [!SB8f-N+W6s 7@5Q)ivR ^.w
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>  以下是引用片段:
m#pmKWe0[)oK(Z|[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
s;ch7SFr <html xmlns="http://www.w3.org/1999/xhtml";> 0P}U*~5Mh;l[
<head>
q2KQ,y;iUC4e <meta http-equiv="Content-Type" c /> ^];[_;H's
<title>css2.0 VS ie</title> 6Te S }yRDf||{
<style type="text/css"> dnS8^2{9np
<!-- :rKQn4F Y[.F
body { 2[_7TM}+a9l
font-size: 12px;
h"uI G \&A*B ^ text-align: center;
x+\(@+_6Fk]0? margin: 0px;
%`Ya4S'W+fb padding: 0px; l{ \|dU.u&{ g
}
\"d#v^J*{#W+O #pic{ Nt2K/]BA
  margin:0 auto;
b#J0u^7[-mx9r   width:800px; ?qD9s7]S
  padding:0;
.{7L5d7CM   border:1px solid #333; o%~p~(pLAS
  }
&OZR,A/K #pic img{ O6xho%[4ois2vo
    max-width:780px; VsK6G v*o+AB&Z
width:expression(document.body.clientWidth > 780? "780px": "auto" ); 7}G#U6I{
border:1px dashed #000;
;Q4V ]2U~ls~]u }
'NfE#U C/m -->
P mUg7\5L:_ </style>
1HX p)H\0u Z4X+@ </head> E BU Qw%Dzxw,x
<body>
"yf,R1f V <div id="pic">
{ttS)BD9d <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> c6FmB bS |au
</div>
l!`1[.h"| </body>
M$x&MRkp"eG </html> L5|5y*M!|`(R
&I{I2GaD
百分比适应::i_i)k^gY[Zi I
以下是引用片段:QYu-v YB,He3N
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
k:};O]f6?5^` <html xmlns="http://www.w3.org/1999/xhtml";>
0e(|$ez*qq+~#\-g)[ <head>
-[k\P9Aa xy <meta http-equiv="Content-Type" c /> ,_l Ab X/E2b
<title>css2.0 VS ie</title>
Zy9ta{6B <style type="text/css">
p'jT Y$eA ]v"Z/B <!-- j8~\\7| o y7]5Q
body { h+rd'A)d
font-size: 12px; :J;\;n p%d$z&~U&t1q
text-align: center;
_o2df&?\.v!s margin: 0px;
/y Ies PG)tL*s padding: 0px; g^z:r*_}
}
0Z#}}jE$`Y #pic{ WvU;K\ G^
  margin:0 auto;
4m OIAWqBe   width:800px;
E|0p$xn5LG   padding:0;
m3dH*\h{Y#?c5k   border:1px solid #333; | L+e^1_f#b Q8W
  } 1H~Hq(J~3vo$u
#pic img{
U'Rx q1i@t'y     max-width:780px; 4P jf9J8r2X
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
EQn+S,x,`B3` border:1px dashed #000; k-fJrMNO1Y5S
} }A(D:{,D2_m
-->
AJ3m c1m.W"h </style>
%IZ UH s t0Eq1Q4?Y </head> f-H(I5Z _ {8kmE
<body>
{fR3l&lT#l <div id="pic"> $Y0x'PV_.x;G
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
C4~_E2o&cC </div>
/Q2o6J|*Ca ~ iT </body>
^3Iq+@-M+?7t </html>

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


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