在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。t2p9G|\[ Q关键在于:max-width:780px;以及下面那行。 d%}%I%Ye,P
[b]固定像素适应:[/b]
T r vd~y'c
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> 以下是引用片段:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> 7G(gpE$AId
<html xmlns="http://www.w3.org/1999/xhtml";> R'w4x.h Hes
<head> tP"~s^
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title>
<style type="text/css">
<!--
body {
font-size: 12px;
text-align: center; "@W/CjSt
margin: 0px;
padding: 0px;
} _6_r2DZR|?$?[
#pic{
margin:0 auto; z#NQ.yG
width:800px;
padding:0;
border:1px solid #333;
} 8[ ` p~,F'RJ Z
#pic img{ 7G6pdlH;S
max-width:780px; ,?R+[hw%C"t_
width:expression(document.body.clientWidth > 780? "780px": "auto" ); p VCs ^a;cm2m
border:1px dashed #000;
}
--> uilV8EwfkI-g
</style> ,sb)Q8|]{5p
</head> q}6w's$xT
<body>
<div id="pic"> T%t+l0R6Sg$h;B6d
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div>
</body> ]t5VW*T9v h
</html>
百分比适应:;M,i)X1s(d UJ
以下是引用片段:?#uv^r cY'mz
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> I'z-r!rx-|!_Q6N E
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title>
<style type="text/css">
<!--
body {
font-size: 12px;
text-align: center; |k$Z@#WaA0VZ){3j+s
margin: 0px; gL DM[!|O
padding: 0px; *jGp A2S6f"pS$j&I7C~
} qn1J/am{%\mZ@%u
#pic{ VVNb c`M.v
margin:0 auto;
width:800px; ;E;xJ_wm}i3V
padding:0;
border:1px solid #333;
} f9CjR&JZ0i
#pic img{ 1Z%j7age'{~l(w
max-width:780px;
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" );
border:1px dashed #000; "m)sp}8Oa1I q
} j|c4_ w
-->
</style> L0Ile3vY/C$m
</head>
<body> Q C5L&gz{!q
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]> 6zmWc ft
</div>
</body> G+G4yFUs*C!q)oG#oy
</html>
页:
[1]