捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。
gh'U3m9A 关键在于:max-width:780px;以及下面那行。
n w9F_(c]g [b]固定像素适应:[/b]
:lIqe/CD2} S k
R:f'JBX4[ 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>  以下是引用片段:$sqT#LR"eN?Ox
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> doofoe
<html xmlns="http://www.w3.org/1999/xhtml";> s|J.K[
<head> J?y)vNXRlr
<meta http-equiv="Content-Type" c /> ]D$@B.hs6\8b O RyC
<title>css2.0 VS ie</title>
H+wg8\nHYf <style type="text/css">
hbc@,Um,r J3p+Y <!--
*TL2p!]Fbx body {
nWn1Z6fq font-size: 12px;
G2T2?2YJ c\,h LI'I text-align: center; Mf MF6EK!?.F\n
margin: 0px; 5X&i?z|M$E*G
padding: 0px;
f5_E8PZIz-x }
.`;N~X;st3s$s:x#r #pic{
;wf7?8nz7|-|   margin:0 auto;
A ?;I4Qe lh   width:800px;
/hec*P(yt2WQX9|   padding:0;
4kJEE3CGL\b   border:1px solid #333;
^;S;Po?cU5\{   }
I,lS D'j)}-`/B #pic img{
ug*n8p6CO-B     max-width:780px; )_/[}p-_9pV^
width:expression(document.body.clientWidth > 780? "780px": "auto" );
j$nEK z,w5gOV border:1px dashed #000;
y5k3N*dXv } %~Rr9dh+^1J
--> %Hh+@J"t R
</style>
U8e ~~d </head> !Su8@2m;B*R!L(_
<body>
/y*?"~*[K]/o!f <div id="pic">
9{0zof%\CV+?{ <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> /o$qp9lHG
</div> w-|0p$Q%_
</body>
[ v/U$c.BT6h+`q U@6C9T </html>
l.l^L3hv|m |%gp
&hyi2\#]!w-a 百分比适应:1J:p9jN2Fz4[X
以下是引用片段:`0z\^;C"m4\2EU
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> .j as-E0A5s"Q
<html xmlns="http://www.w3.org/1999/xhtml";>
+FSn[,I;C8t <head>
o_$[p qA v6m <meta http-equiv="Content-Type" c />
`ah5~?e0sU <title>css2.0 VS ie</title> W!TGR$~ C?
<style type="text/css">
7ku6lI$?)a| <!-- V/K%z#Jy;P MS
body { Za@ LP
font-size: 12px; ,u.iB7x"?}y
text-align: center; ;_*CXg1@%L
margin: 0px;
? qJcaR~3^I7CK4O padding: 0px; du7R*`b v.|yq
}
Clo1i.J/? o2` #pic{
}2a'U X"O   margin:0 auto;
"B~5GV s0RP:U   width:800px;
5BuFcX%Z5t   padding:0;
!~N Ia.e'_)v_(h   border:1px solid #333;
t0D`9|3kF   }
2c3V#O7B }7uv5CA #pic img{ 0gc7n#bmLwX
    max-width:780px; '{0OoK$lCK
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
7n5s$`*a`(i%l!h0E border:1px dashed #000; 6d5V:a1{!~6y`y
}
?s!uJUOE --> %X2h `8C*vZ
</style>
7@"f3g j2~j"g </head> B`d$a&c-Y u
<body> } A#^*e UW8C)_
<div id="pic"> @AU`+i-hWY&L R
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
"Q8N;b3e&N!`1J`z </div>
0a0W$i5u'~ </body> 9F0Vf3i6c']0KVV
</html>

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


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