喜欢本站并加入收藏
首 页 电脑学园 技术文档 图形图像 办公应用 网页设计 管理资料 PPT模板 方案合同
 位置: 北方教程网 >> 网页设计 >> DIV/CSS >> 正文
   div设计中图片自适应解决办法
div设计中图片自适应解决办法
[ 作者:佚名   来源:蓝色理想   点击数:   更新时间:2007-8-15 ]

在以前提到的解决方法主要是利用js来实现,但用过的朋友都知道该办法有点繁琐。

还有一种是在外部容器定义over-flow:hidden。但这种办法只会切割图片而不会自动适用。

关键在于:max-width:780px;以及下面那行。

 

固定像素适应:

 

以下是引用片段:
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";> 
<html xmlns="http://www.w3.org/1999/xhtml";> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>css2.0 VS ie</title> 

<style type="text/css"> 
<!-- 
body { 
font-size: 12px; 
text-align: center; 
margin: 0px; 
padding: 0px; 

#pic{ 
  margin:0 auto; 
  width:800px; 
  padding:0; 
  border:1px solid #333; 
  } 
#pic img{ 
    max-width:780px; 
width:expression(document.body.clientWidth > 780? "780px": "auto" ); 
border:1px dashed #000; 

--> 
</style> 
</head> 
<body> 
<div id="pic"> 
<img src="/articleimg/2006/03/3297/koreaad_10020.jpg" alt="感谢blueidea被我盗链图片!"/> 
</div> 
</body> 
</html>

百分比适应: 

以下是引用片段:
<!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> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
<title>css2.0 VS ie</title> 
<style type="text/css"> 
<!-- 
body { 
font-size: 12px; 
text-align: center; 
margin: 0px; 
padding: 0px; 

#pic{ 
  margin:0 auto; 
  width:800px; 
  padding:0; 

  border:1px solid #333; 
  } 
#pic img{ 
    max-width:780px; 
width:expression(document.body.clientWidth>document.getElementById("pic").scrollWidth*9/10? "780px": "auto" ); 
border:1px dashed #000; 

--> 
</style> 
</head> 
<body> 
<div id="pic"> 
<img src="/articleimg/2006/03/3297/koreaad_10020.jpg" alt="感谢blueidea被我盗链图片!"/> 
</div> 
</body> 
</html>

上一篇文章: 编写CSS过程中最常见的10个问题 下一篇文章: 网页制作中如何进行CSS布局
打印此文  收藏此页  关闭窗口  返回顶部
 相关文章  热点文章
 · 利用CSS改进网站设计的小技巧
 · Dreamweaver快捷操作技巧集锦
 · 使用Dreamweaver架设网站简明教程
 · 网页设计制作过程中常用的几个代码技巧
 · 高效使用CSS编码的方法
 
热点图文
教你节省Vist...
使用Windows ...
 · 远程管理Web服务器的方法技巧
 · Win Vista系统自带IIS7.0设置详解...
 · 详解Windows系统IIS6.0功能及应用...
 · 服务器集群系统实现方法及案例分...
 · IIS服务器实现asp,cgi和php+mysq...
 · IIS下SQL Server数据库安全设置技...
推 荐 阅 读
巧用Photosho...
Photoshop鼠绘...
 · Fireworks制作旋转的漂亮gif动画...
 · Photoshop制作都市满天繁星
 · Fireworks制作Menu按钮
 · 巧用Photoshop制作喜迎奥运壁纸
 · 巧用Photoshop钢笔工具绘制彩色美...
 · Photoshop制作浪漫动感花朵
 设为首页 - 加入收藏 - 关于本站 - 联系我们 - 广告合作 - 友情链接 - 在线交流 - 
CopyRight© 2006-2009 Eduai.Com All Rights Reserved
在线交流 QQ:524152258 辽ICP备07001851号
免责声明:本站部分资源来自网络,如有侵犯您的版权请通知,我们立即删除。