捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。OV+T:fH3_
关键在于:max-width:780px;以及下面那行。
9cb.w$Wh [b]固定像素适应:[/b]
.J}%@ e'd BirZ&S1w.sj$I
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>  以下是引用片段:
:D!o9G'^@E_ V3Y <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
c;rnA!]mGI)w <html xmlns="http://www.w3.org/1999/xhtml";>
|$Y)dqqY <head> #O?1UU a7Z"[
<meta http-equiv="Content-Type" c /> *m$f/R!V,x.}P uHnw
<title>css2.0 VS ie</title>
`i H,ST!LZ <style type="text/css"> $EgKi|2h
<!-- ] H8wb/Fp"^ o/e
body { M7[d]:@S tAfI.\
font-size: 12px;
\d G)]7{3S7D3}-V text-align: center;
W6{d%sN/x margin: 0px;
@zHhg3J^2c n padding: 0px;
Cgo#uW'iM } L;f2Lj/_#d7W:j
#pic{
Nw3OKc"FcV0b   margin:0 auto;
7V Nx\QG   width:800px; "D Yj0D9O5oCR o)D7h
  padding:0; OxC)^/X] q
  border:1px solid #333;
*TW2dh#ME V   } +sH!uXDl s7}Cc
#pic img{
5m o|v2P` e&}     max-width:780px;
G7iw7QRE K&m width:expression(document.body.clientWidth > 780? "780px": "auto" ); E.yL+Mxg X
border:1px dashed #000;
$Cl}:ad|dFC| } KS4Q'_-i,Xl
-->
"N;S{$o7C9U;o}2^ </style>
x3JLz!j%u6[ </head> w~4tt3E\h
<body>
8@SXW \ e/n <div id="pic"> r?,iz+bX;kRwo
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> hWO v;A g"W
</div> mdA8N7q;N-G]
</body>
y1w4K"F#jX </html> U&^%Og:O9@
W2R&~'p n&Zv
百分比适应:
G4cH!X%O@gd 以下是引用片段:
~(^*^3v2ro{+v2x <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> ;I)F+z'O? U{9f
<html xmlns="http://www.w3.org/1999/xhtml";> #J6L.Zv{ O&\
<head> 4] l!M0CQ:V
<meta http-equiv="Content-Type" c />
,pbN7Nf4k q <title>css2.0 VS ie</title>
[4x9U&K%Vk0q <style type="text/css">
%m.`klUs <!-- 5k-`&F/N4D%zZG
body { @(o F7[^3Q
font-size: 12px;
+O Z(o9y}4Py5Y4q text-align: center;
S6\/_9m/\ i margin: 0px; 5FZD"xm+A+H+IC!|
padding: 0px;
"^fB/n1x$XX } 0F [-MOch
#pic{
H9G%H.Uf   margin:0 auto; #kLy:K H-a!?
  width:800px; By(vna.hlo
  padding:0;
"M&z|6@$|:@)^{   border:1px solid #333;
_y&B*v}N$L"J Z   } )V DW-FNJ
#pic img{ 6qMm'h*M
    max-width:780px;
;O$UE_WHeb width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
2g^v)Hud;I border:1px dashed #000; *LWm7H zAe+~
} +Ug9EWKa:~
--> /d?bX9GI l1P%C
</style>
.N+b&AoR </head>
4RB |6Q~8NX:Uto:_ <body>
4[/A,K6u^9N/t|8I <div id="pic">
!MK"Qm7i-Jf1RhV s <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
3c8rJ-x^x3l+i+B </div>
\~gz sU f-J </body>
c5BG8YC$\b3~ </html>

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


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