捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。6W([rf3R)|\R:`#v6Z6T
关键在于:max-width:780px;以及下面那行。.d%T$b3Ww/RJ
[b]固定像素适应:[/b]wD.g"F{W?+R
l8n7`AO+D"u*a4b
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>  以下是引用片段:*r;t K2E7t~"WXqS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> s1Y-B;hZ?E%]
<html xmlns="http://www.w3.org/1999/xhtml";>
*e-X:[ fi$k^7?2u <head> (Pu tI%i)nshL
<meta http-equiv="Content-Type" c />
4?.hFV6Pr1mc <title>css2.0 VS ie</title>
9G m+hH O:C <style type="text/css">
,^4o8iuG6[Gy i <!-- 2Z`,pq%oZ s
body { ~)T H!Pf:CR@I@_"t6y
font-size: 12px; 4}T%s+?up#K^
text-align: center; r w)q&b kK:s3{?(L
margin: 0px; M5RO%@!n o
padding: 0px; 5A|/^+t&ap*C;H4w5Q
} iN l![!e\ w
#pic{
NZ+c4wBc'T   margin:0 auto; 4xlfbw
  width:800px;
%U G u W"^2^   padding:0;
5ar~4BZ+W;F   border:1px solid #333; W-|_1e~r;u@
  }
~l2R^2} #pic img{ #{1|;a J:f\W+Z
    max-width:780px;
i'd3n'w Z?M3x width:expression(document.body.clientWidth > 780? "780px": "auto" );
e @L Eg2G border:1px dashed #000;
n4nCv&Y#P!a`'Jo4Y } 1~@dHc&b
--> M9s3\5Y Iis
</style> RPDfT V
</head>
S f5w#?6s <body> 9{*{!K&ME A
<div id="pic">
|8xf LSOL"R <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 1a4T C8D#PU
</div>
f$[ H ac2?'O|6\#^3R-lC </body>
'I#eO%nFa4|LO </html> /q#JnKn7Z C

&{w*?y\'r!E#R0D _-{e 百分比适应:H4aV9_'e:j$h|
以下是引用片段: {La%X0C{WL7Fzx
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 6Z*Bp^/`c'VS
<html xmlns="http://www.w3.org/1999/xhtml";> 2oL2x*xf/T
<head>
'S?p"FJ0Z <meta http-equiv="Content-Type" c /> UaUy]-IlD
<title>css2.0 VS ie</title> -H+z/b+n"bd ?l
<style type="text/css"> .L{ t jf ^
<!-- Q-sd5WotO
body {
B(^}%?X#M$r| P1h font-size: 12px; ]4Jvyc5O'_-zJH
text-align: center; *pN.Sr7D^/`\^K
margin: 0px; #Y~/BV-u6jY?
padding: 0px; y~ [1gt
} Ns}0B"x&G8[
#pic{ 'jx@2`$}~`
  margin:0 auto; @)\p_d"T#I)s ?
  width:800px;
8^'rbA)s2GA,y_|   padding:0;
3f? E$c L}*gy   border:1px solid #333;
+Xt6{oRE+@#\   } V `)F&v Cv
#pic img{
MFL3? }m(F"H TL     max-width:780px; t N7j5i8P;b3M
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); dj|ip2ZW
border:1px dashed #000;
8W l\/rx t-HMhf${4h } n\`j }+K
-->
a"d(]:}!mM </style> -c#xdk"Z"FEh(Y1HZ
</head>
"\r"?9wL \"o <body> wC3Bm YZ
<div id="pic">
V@)vgtwr0h <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> _ ~M6E*wDY9c"zVC
</div>
J{3U5Ao|)M ] </body> i F9T$RPka,n?t
</html>

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


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