捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。aV%YDx
关键在于:max-width:780px;以及下面那行。
zm/x/F5w3c%r [b]固定像素适应:[/b]
N7h3Y8LM `9e*}
"?%T)]PO3G(]5l 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>  以下是引用片段:
3RzOq5\p <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
^[ug~ SZ <html xmlns="http://www.w3.org/1999/xhtml";> ?9C @-h;Eq.v
<head>
I|ya y[ <meta http-equiv="Content-Type" c /> erxE3_M6Oj
<title>css2.0 VS ie</title>
f `$l'[:INq*sk"R <style type="text/css">
9crt kCe <!--
'_*G!j!E ?] body { u,Js,I;~ Bi@_i
font-size: 12px;
,ftl3g ~T GNn/Z,A5a text-align: center; 0`0[bNV&_a
margin: 0px; 3|*FJqvKj"Qw
padding: 0px;
!K"?WHwAN%^-P } @!ADMFgI
#pic{ 0` P1|#BW\ gKX3l
  margin:0 auto;
&Z#az9IoO:D   width:800px; z["k3cB-H9@ FjW[
  padding:0;
:]m Y w#[9\   border:1px solid #333; N3d t j ~5u
  }
cm5b*v_fT #pic img{ u%ENig1]"c&ankR L
    max-width:780px;
g?En_4v6HW'] _ u width:expression(document.body.clientWidth > 780? "780px": "auto" );
+r-oG U8`i6S border:1px dashed #000;
r)b2EP&nnL1z } ;@&~HDq-b2Y;tL
--> #No c6w6LK1PKe2p(N
</style>
t6bscGs bg5bp </head> q*y ^`n h3cN
<body> *mdE7qEnzFR
<div id="pic">
3Bqeh \1?5hUA <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
&R JWP g </div>
_RQ3O4d </body> Jw&F'cx:j
</html>
k"qufa1k9zpo IvH Gu1B
百分比适应:
@q{2G,Z |/I7U ft 以下是引用片段:4X aP.x-gG:tfi
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
1sZc*?r1LlD-jk(d <html xmlns="http://www.w3.org/1999/xhtml";> .kdc1Z_ lu|
<head>
MH,M[(A-oq <meta http-equiv="Content-Type" c />
(Hb]"^.T[)e8X1E <title>css2.0 VS ie</title>
{]D*X%YV~6V`} <style type="text/css">
4G.qN,v C"L N <!-- 4D{D?"Rn
body { 5U*M:]&E2z2]
font-size: 12px; y-wua_H
text-align: center;
/Y!G'gj}r margin: 0px; 4\ }/L%p*g6M.?M/D
padding: 0px;
7aI'LIqr}W } 0c2?CLY P,Q&ne
#pic{
z i5suk%bL c OF   margin:0 auto;
.~\*I(h(q   width:800px;
t9}jX7Y{   padding:0; 7n:f.d3U9s#I g
  border:1px solid #333; (RbAmLTfD
  }
x*GE NY4O #pic img{
"W3c c6\yjU]S     max-width:780px;
%M0X Wq{ width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); "{~.r5@*[{`
border:1px dashed #000; 3Mw cuJ D{,h)f"Q
} W5JR9~C
-->
*Fn%l-L'A(?,Y </style>
1wb%P e2D </head> )NL9J5p,IV-X/shb
<body> :h-o0T&?)n(~*M N'P
<div id="pic"> D cH#_&M LfE)Y
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
W8qLmJ |U{:I </div> M7| q1l x`#U
</body> h8FxCG3kJ
</html>

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


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