在DIV下图片自适应的解决方法
以前的解决方法主要是利用js来实现,但用过的人都知道该办法有点繁琐。还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。关键在于:max-width:780px;以及下面那行。
[b]固定像素适应:[/b]
!k0G](q;W,AQY5[.u:s
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> 以下是引用片段:x4zIqm8m
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> ,TA;I^V y Nxx%w
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" c />
<title>css2.0 VS ie</title> 4{{'po-eoY~Sy
<style type="text/css"> 0u*ADk$F-SzM
<!-- 'l_!c(Os?
body {
font-size: 12px; 9F_&t5k8l1d^ ^
text-align: center;
margin: 0px;
padding: 0px; )\[6q(@CNul
}
#pic{ U1b-F4N6Kb/@e|
margin:0 auto; +xc,]teC9j
width:800px;
padding:0;
border:1px solid #333; P%sJCG0G5vkP8N
}
#pic img{
max-width:780px; kT(p(@,tG)FC
width:expression(document.body.clientWidth > 780? "780px": "auto" );
border:1px dashed #000; L,@c"BpQ6A`e
} ao9r.l fln7c E6X
--> [] [^z5U:Jd
</style>
</head> NNhJ We0c
<body> Y\tof~*R T
<div id="pic">
<img src=[url=http://webclub.net.cn/images/Beijing2008/logo.gif]http://webclub.net.cn/images/Beijing2008/logo.gif[/url]>
</div> 8f6b/y2gh(o.kLA\5G
</body>
</html> *W#P%_{7K
TlJC ky
百分比适应:y+c4G Y)nL!{ SU
以下是引用片段:"M2_(Zt.u?{FlZ$u
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head> "K#n}hZ1p] l
<meta http-equiv="Content-Type" c /> c2o^v D0K0g9Z
<title>css2.0 VS ie</title>
<style type="text/css">
<!-- 0f K'D:r/N7g
body { v@~c:?7[ `+{
font-size: 12px; 2y'e:La1Y9kr s
text-align: center; {GR7eig vue1I
margin: 0px; :X%G5a,B0w%~,G
padding: 0px;
} ,c,Hc4Z&xzPo
#pic{
margin:0 auto;
width:800px; i3Re lfRNt {:{
padding:0; V:Hbu(e
border:1px solid #333;
}
#pic img{
max-width:780px;