捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。.kI+y.r|/\Z
关键在于:max-width:780px;以及下面那行。
I|"N@n`3k [b]固定像素适应:[/b]
P|l0K8S~V
~.Cy,Q?/]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>  以下是引用片段:o8~6|4b4Z.}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
4u sAK.Oj+P <html xmlns="http://www.w3.org/1999/xhtml";>
;k y3V)Y)S p <head> j!a2xPn(f9n#k
<meta http-equiv="Content-Type" c />
yZn)J-jiFg <title>css2.0 VS ie</title>
H`K)L].o%c$O9K,L <style type="text/css">
1DM8yi&Fh(u <!-- +a)v/|7j"d;|u$D;eX
body { $}%NYL6Y o hO3u
font-size: 12px; 5m0TeS7l$Z0Xz
text-align: center; 3K?\qE
margin: 0px;
R_r_C padding: 0px; PcoyI4_
}
RK DQGZpy #pic{ g`_#U3C(i
  margin:0 auto;
~neAT/@ Y   width:800px; 0z.P2V-]wo
  padding:0;
sh"Ve%`E   border:1px solid #333;
XJz%V4e+Tml   }
h%U5t,Er/l #pic img{
^2jyOb%?.H$m"[     max-width:780px; ~!T|g7Re[
width:expression(document.body.clientWidth > 780? "780px": "auto" ); t_qVs@M }c
border:1px dashed #000; +r'dQ*X&mPA4G_"I
}
rad~7iy){^?3c --> 0D L0^U7^ Q,v}
</style> tk},{Kum
</head> /CSD-p+{7s8aX
<body>
tni5N_9cM <div id="pic">
FTF3\o <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> d1P;y/MI2znaQ g
</div>
{.r$S2rK\ </body>
5gj%mQ;I </html> m7JoIZ*_
Fn3Na%q:q
百分比适应:CA$_ d~P
以下是引用片段:2n([O;ck;Z2a%i}:b'v
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> -Z}'E,{?-K.w v
<html xmlns="http://www.w3.org/1999/xhtml";> ej$cw_sO'G
<head>
3{!W3I E9oV;kd:NX-P <meta http-equiv="Content-Type" c /> :PxA$jy?nyC
<title>css2.0 VS ie</title> |x]|}s\T
<style type="text/css">
bvZf s+`}a <!--
;T'cf#U;C-\wM2a body {
q}e+Q bw/p/\D font-size: 12px;
:{)`[9C+DG~l?4` text-align: center; [~n*A0V-_)M,Z
margin: 0px; V3V(o;g,~7i'n
padding: 0px; 7g6?K!RF R-cF7Z
}
t)tN }*pW #pic{ 4P} | \0OuB Y9b7i,G&K
  margin:0 auto; ;\eu)\1u9Ve}iP
  width:800px;
}8nF^ fd"q"L   padding:0; 3y$D)m;d.^?*f
  border:1px solid #333;
/m6})iQCYwx-O   } ,C9rpuL"Eh
#pic img{ h8sxV Lvh9E/ycm
    max-width:780px;
;oR3RA)a5IJr])A width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); rH0v|;|t8m#vy
border:1px dashed #000; O o&t$ap5h7h
}
0G9mru~?s$x --> YFl1]y4qb _9} i
</style> 2v-El W?2w$c^i@a
</head>
z+Y U9G E <body> vN0@`W-W4@(j X#{
<div id="pic"> Vx9|1j:@WF
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> z yr,N'F d n$mr1i
</div>
$Ur5L_ Z1Er </body>
H0S"WI/R X6A\ </html>

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


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