捌玖网络工作室's Archiver

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

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

以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。3d)S*M/vKm3s
关键在于:max-width:780px;以及下面那行。
%VU]`E [b]固定像素适应:[/b]
2g+cay!n'S i
+d;^e0B$_U 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>  以下是引用片段:/n~/b0T6i
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 0bsADoe
<html xmlns="http://www.w3.org/1999/xhtml";> Jme ~,k L
<head>
^n1h Vh.M <meta http-equiv="Content-Type" c />
8gi6A#T1@+?-h u9yc <title>css2.0 VS ie</title>
xb&p@0Pv <style type="text/css">
{] Y&Wt$s2[T <!-- ,O4G7Ym*IY-\nk!x)g
body {
,x:@#]Aw@ j(nxe font-size: 12px;
#Ss!c[8K+fu1F&l text-align: center; fBf'|0zB%}
margin: 0px; o\9JK)o!C
padding: 0px;
`1iY4m `!b2w+[Pk } $S}p:y z9m"E^
#pic{
2^0ht,gh)Axg   margin:0 auto; 3~5D nT!j)?9jr
  width:800px; 0U;?r}1S}!\
  padding:0;
RoI Dp KMo   border:1px solid #333;
Xh2r)~Z6N   }
X7zewM5n3v y6I #pic img{
`7|\ s A!V     max-width:780px; #[%Uy"e:A-? x
width:expression(document.body.clientWidth > 780? "780px": "auto" ); hK3[9P.{\
border:1px dashed #000;
qi(qN1[n5a5r"H } L-OdzFN\3~+_o0M
--> /NL#_An|"J)Ko
</style> 6W `/SS3e:h
</head>
R'M6`;l.HKvq9u D0J <body>
0@;hjN f9C <div id="pic"> ;i,C P"I?
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> \ |R'H8Cdt*{tt
</div>
L/Mx @Mfs </body> A:rS"Wn_Pv"s
</html>
4rO G*D&t_ !{6avpM7o
百分比适应:
!B;n8J)Db[_]W1u 以下是引用片段:
rB0t FqnM:M4w <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
9Ck#kx*{ }R9lV_w <html xmlns="http://www.w3.org/1999/xhtml";> Ou"f:msO3VM!H'?
<head> H f'`x1H/E fp
<meta http-equiv="Content-Type" c />
d8Lv8ym,| zrLu <title>css2.0 VS ie</title> GM+wY7AM
<style type="text/css"> x4F3P[xD6`cD
<!--
z-r)]8w pT0@*LB body { pwq BQ3N)BQ
font-size: 12px;
HyL(r(E2N text-align: center; /m7q#g)D-ya-pT4V
margin: 0px;
O vu e'm-\ padding: 0px; ;i\V)iy)AO3i-P;?
} 'x [)\(M`(K3lQ0N
#pic{ 5DU|^(J W"B`5t&@`
  margin:0 auto;
+n.[;F)K'x2t   width:800px;
Efap+@M7I(j   padding:0;
_+v"} A@1\P"z'S   border:1px solid #333;
5L0o zs y0K   }
An qM8? rD"Ii #pic img{
+RdVDt+G5v5W     max-width:780px; 9w7Y[W$?GY
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
ZO F7}$f"|qr)Pf.}7W border:1px dashed #000;
|)?lK]:Q o } MM i;Sx4a
--> %cYs+NRr{ m
</style> %s%["IU6Zu'p {
</head> v/q xLT;cC4B"J A
<body> %c%MGw,eT9`1[
<div id="pic">
0S%o-\RE <img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> od${4BfX/[V
</div>
6~rnm/xJ!? vE </body> oTp.J:N-w
</html>

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


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