捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。K3Z9r$i Z$h7E)[
关键在于:max-width:780px;以及下面那行。
D9}KQ%b l AG [b]固定像素适应:[/b]j m*Y,fR%w'F
l bt!f,?f0T g
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>  以下是引用片段:a1OL VQ%Y2K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 9n*Vl6}1uP.uZ
<html xmlns="http://www.w3.org/1999/xhtml";> MiM#v \2k0t m
<head>
3W0m,n j!e3l-Y}*Z <meta http-equiv="Content-Type" c />
9cC Ic+i z ~ <title>css2.0 VS ie</title> [/y4@`oW@9i\F/L
<style type="text/css">
gO9hEc wM&U <!--
V,tv^ zi%e body { /Bg]Hci
font-size: 12px;
ES9T!z ZpF text-align: center;
D6`|2R)k@l margin: 0px;
pVM:U)p:{K(c padding: 0px;
2k)KDc1Z }
yI7wS9{yg #pic{
|'w$xb{(rs-u@ JQ*x\   margin:0 auto; A[{ b/vd@s-\
  width:800px; 3ij1l9F D]t,h:[
  padding:0;
A D/cHK K~7o`+G5^   border:1px solid #333;
8?q(k!h%\T#ew   } dp@uHZ
#pic img{ 9v qq{*NJqD^
    max-width:780px; 1w1|8cRUf.xp r"u
width:expression(document.body.clientWidth > 780? "780px": "auto" ); -U N?8T(H5X
border:1px dashed #000;
7yGM;Q,ax0| } k['Xbr
--> !a,w!QB'lD
</style> r1w(e$\f.d ~V
</head> #K.g)U)G9XIP
<body>
2D j,J;mwjj <div id="pic">
o h2Hxd'K)?+VU <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
9~g#aO&W e+_e </div>
j"J aa bN q </body>
|'z-_#H%E&H </html> k8]sU"d$A2Q.P1F

!nM~.C^vMQx%A4l 百分比适应:
]+G/r ~ x8jx \ 以下是引用片段:}$EwU$J9r2Re
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
9~.T'| yqQ&d <html xmlns="http://www.w3.org/1999/xhtml";> -[?8|!k3M"?-s+I Dw ze
<head> -n"\w/|?;FtHT
<meta http-equiv="Content-Type" c /> %E6|%DZraW/z
<title>css2.0 VS ie</title> 1vr9`8^C
<style type="text/css">
^ p2F.u0G/CM <!-- u F)X*J3ul{
body {
'c _;cR%f]'P3b4Y font-size: 12px;
d0m |"O;^-P Y {%^ text-align: center;
$_LlHF!T[6Ot/| W margin: 0px; |6k)y.zH
padding: 0px;
5t&F&I(JM!JQ1R4w } ~-W%im b1Ba,L
#pic{
-ow]!^ O)bw*b8u   margin:0 auto;
!DkDV#qf@   width:800px;
y`;^)b]E(u1G3R   padding:0; Y&tv n4HT+w;pe
  border:1px solid #333;
+AT a;r0h}^'AV"@   } &bP(I,Uq2P(D
#pic img{
6x0q"W cPp     max-width:780px; IWVpUXP
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
aE~&T1cchz&c border:1px dashed #000;
_M+Y^ B2O N }
L#T%i+x;|;\y N@0f -->
*G\f/U6E9A </style> &qJ5sCN/R&b
</head> yG&@\K d
<body>
[xz)v*LB3u <div id="pic">
io p$S6|)Z*KZ%u <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
(N'Os`${ ?9Xm9SXP </div> U/m^*~Yj
</body>
3oaZj0X/b </html>

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


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