最近接了个政府项目,政府项目要求响应式,并且兼容IE6,不想用媒体监测的方法,于是用了百分比布局的方法,但是IE6真是名不虚传,做第一个界面就遇到了个bug

  ①两张宽度各占50%的图片无法在同一横排,只显示左面的那张图片,于是我加了float:left , 不对,去掉图片的border,也不行,于是就用了一招障眼法,两张图片都是49.5%,完美解决,并且这一点偏差根本看看不出来

  

  ②百分比布局菜单位置,左右可以按照百分比,但是高度和上下距离无法确定,于是用js获取图片的高度,然后用比例将菜单的上下距离设置好,但是在屏幕尺寸发生变化之后,菜单位置发生偏移,我用了window.onresize检测屏幕尺寸,代码如下

  

    代码如下:

<!DOCTYPE html>
<html>
<head>
<title>菜单定位</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<style type="text/css">
*{margin: 0;padding: 0;border: 0}
body{height: 100%;overflow-x: hidden;overflow: hidden}
.center img{float: left;}
.door{width: 100%;height:100%;margin: 0 auto;overflow: hidden;position: absolute;z-index: 500;}
.pp{float: left;width:49.95% !important;width:49.95%;height:100%;position: relative;display:inline; border: 0}
.pp img{width:100%;height:100%;}
.pp img{position: absolute;left: 0}
img{width: 100%;display: block;position: absolute;left: 0;height: 100%}
.box{width: 100%;height: 100%;overflow: hidden;}
a{display: block;position: absolute;z-index:400;text-decoration:none;outline:0;cursor: pointer;width:100%;height:100%;text-align: center;overflow: hidden;}
#door{cursor:pointer} .mine{width: 11%;height:55%;top:55%;left
: 7%;font-size:300px}
.jap{width: 7%;height:55%;top:55%;left
: 22%;font-size:240px}
.land{width: 5%;height:55%;top:55%;left: 32.5%;font-size:240px;line-height:200px;font-size:200px;}
.imp{width: 5%;height:55%;top:55%;left
: 62.2%;font-size:240px;}
.base{width: 7%;height:55%;top:55%;left
: 71.5%;font-size:300px;}
.his{width: 11%;height:60%;top: 45%;left
: 82.2%;font-size:400px;}
#end{width: 6%;height: 40%;left: 47%;font-size: 400px;}
.center{width: 100%;margin: 0 auto;height: 100%;overflow: hidden; }
</style>
<script type="text/javascript" src="move.js"></script>
<script type="text/javascript">
window.onload=function(){
var oBox1 = document.getElementById('box1');
var oBox2 = document.getElementById('box2');
var aImg = document.getElementsByTagName('img'); var sb = document.getElementById('sb');
var sb1 = document.getElementById('sb1'); var oMine = document.getElementById('mine');
var oJap = document.getElementById('jap');
var oLand = document.getElementById('land');
var oEnd = document.getElementById('end');
var oImp= document.getElementById('imp');
var oBase=document.getElementById('base');
var oHis= document.getElementById('his'); var l = document.body.clientWidth/2; oMine.style.top = sb1.offsetHeight/3+'px';
oMine.style.height = sb1.offsetHeight/2+'px'; oJap.style.top = sb1.offsetHeight/3+'px';
oJap.style.height = sb1.offsetHeight/2+'px'; oLand.style.top = sb1.offsetHeight/2.4+'px';
oLand.style.height = sb1.offsetHeight/3+'px'; oEnd.style.top = sb1.offsetHeight/2.3+'px';
oEnd.style.height = sb1.offsetHeight/5+'px'; oImp.style.top = sb1.offsetHeight/2.4+'px';
oImp.style.height = sb1.offsetHeight/3+'px'; oBase.style.top = sb1.offsetHeight/3+'px';
oBase.style.height = sb1.offsetHeight/2+'px'; oHis.style.top = sb1.offsetHeight/3+'px';
oHis.style.height = sb1.offsetHeight/2+'px'; window.onresize=function(){ var l = document.body.clientWidth/2; oMine.style.top = sb1.offsetHeight/3+'px';
oMine.style.height = sb1.offsetHeight/2+'px'; oJap.style.top = sb1.offsetHeight/3+'px';
oJap.style.height = sb1.offsetHeight/2+'px'; oLand.style.top = sb1.offsetHeight/2.2+'px';
oLand.style.height = sb1.offsetHeight/3+'px'; oEnd.style.top = sb1.offsetHeight/2.3+'px';
oEnd.style.height = sb1.offsetHeight/5+'px'; oImp.style.top = sb1.offsetHeight/3+'px';
oImp.style.height = sb1.offsetHeight/2+'px'; oBase.style.top = sb1.offsetHeight/3+'px';
oBase.style.height = sb1.offsetHeight/2+'px'; oHis.style.top = sb1.offsetHeight/3+'px';
oHis.style.height = sb1.offsetHeight/2+'px'; } }
</script>
</head>
<body>
<div class="center" id="center"> <div class="box" id="sb">
<img width="100%" id="sb1" src="img/door.jpg">
<a href="mine/mine.html" id="mine" class="mine"> &nbsp</a>
<a href="jap/jap.html" id="jap" class="jap">&nbsp</a>
<a href="land/land.html" id="land" class="land">&nbsp</a>
<a href="front.html" id="end" class="end">&nbsp</a>
<a href="imp/imp.html" id="imp" class="imp">&nbsp</a>
<a href="base/base.html" id="base" class="base">&nbsp</a>
<a href="his/his.html" id="his" class="his">&nbsp</a>
</div>
</div>
</body>
</html>

IE6下图片无法正常显示:用PS打开图片,将颜色模式改成RGB格式,完美解决

    

    

     

百分比布局实现响应式布局在 IE6 中填坑思路的更多相关文章

  1. html响应式布局,css响应式布局,响应式布局入门

    html响应式布局,css响应式布局,响应式布局入门 >>>>>>>>>>>>>>>>>>& ...

  2. 浅谈静态布局、流式布局,rem布局,弹性布局、响应式布局

    静态布局: 特点:没有兼容性问题 PC:居中布局,所有样式使用绝对宽度/高度(px),设计一个Layout,在屏幕宽高有调整时,使用横向和竖向的滚动条来查阅被遮掩部分:移动设备:另外建立移动网站,单独 ...

  3. 自适应布局,响应式布局以及rem,em区别

    一.自适应和响应式 先说共同点: 两者都是因为越来越多的 移动设备( mobile, tablet device )加入到互联网中来而出现的为移动设备提供更好的体验的技术.用技术来使网页适应从小到大( ...

  4. Bootstrap页面布局5 - 响应式布局(格式)

    旨在优化不同上网设备中页面显示的优化 响应式布局:就是根据浏览窗口的尺寸,改变页面的变化 原理:利用css的media-queries判断浏览窗口的尺寸,在CSS样式表中设置一些规则! 例如: 在&l ...

  5. [学习笔记]viewport定义,弹性布局,响应式布局

    一,移动端宽度设置viewport视图窗口,<meta name="viewport" content="width=device-width,initial-sc ...

  6. viewport定义,弹性布局,响应式布局及LESS和SASS框架应用

    一,移动端宽度设置 viewport视图窗口,<meta name="viewport" content="width=device-width,initial-s ...

  7. 静态布局、自适应布局、流式布局、响应式布局、弹性布局简析、BFC

    静态布局:给页面元素设置固定的宽度和高度,单位用px,当窗口缩小,会出现滚动条,拉动滚动条显示被遮挡内容.针对不同分辨率的手机端,分别写不同的样式文件.例如:浏览器窗口是1000px,那么最小的宽度是 ...

  8. rem布局及响应式布局

    流式布局(100%布局)(可能:做的页面不是很美观)效果与弹性布局一样 不设置宽高:表示宽 auto 最外层:保证100% 等比例缩放的算法:  320/10  已知的一个比例  =  已知的宽/x  ...

  9. 移动 WEB 开发的布局方式 ---- 响应式布局

    一.响应式简介 一个页面布局兼容了 PC端 ,iPad端 和 移动端 所谓的响应式就是页面中的布局会随着屏幕的大小变化发生了响应而做出不同的页面布局模型 特点: 响应式布局是不需要单独写移动端页面的 ...

随机推荐

  1. Django搭建及源码分析(二)

    上节针对linux最小系统,如何安装Django,以及配置简单的Django环境进行了说明. 本节从由Django生成的manage.py开始,分析Django源码.python版本2.6,Djang ...

  2. requireJS心得

    最近有幸接触到前端分模块加载JS框架,并且结合avalonJS使用,在此记录学习痕迹: a.实现js文件的异步加载,避免网页失去响应: b.管理模块之间的依赖性,便于代码的编写和维护. (1)requ ...

  3. php5.5新函数array_column

    php5.5新增了一个新的数组函数,感觉挺使用的,低版本的实现按照如下实现 if(!function_exists('array_column')){ function array_column($i ...

  4. Servlet之HttpServletResponse和HttpServletRequest

    HttpServletResponse 1.告诉服务器应用使用UTF-8解析文本的两种方式,告诉客户端要使用什么编码 response.setHeader("content-type&quo ...

  5. vim之旅

    本人是今年的毕业生, 大学很莫名的选择了一个电子商务专业. 由于专业没有实质性的东西可学,加上对电商不敢兴趣, 于是乎我有了大量的时间在宿舍里折腾电脑. 折腾了几年大三决定转业, 大四在还没找工作之前 ...

  6. 9.css背景

    这节也是关于盒模型的扩展,而我个人喜欢把盒模型想象成图画.元素的尺寸调整就是画布大小的调整,边框的设置就是画框的镶嵌.但是,作为一个最终要将画作展现到美术馆(网页)的艺术家来说,仅仅是这样还是不够的, ...

  7. Python脚本控制的WebDriver 常用操作 <六> 打印当前页面的title及url

    下面将使用WebDriver来答应浏览器页面的title和访问的地址信息 测试用例场景 测试中,访问1个页面然后判断其title是否符合预期是很常见的1个用例: 假设1个页面的title应该是'hel ...

  8. SRF之日志和异常

    日志: 日志功能采用log4net实现 log4配置文件在站点目录下的log4net.config. 调用log4写日志的代码如下: log4net.ILog logger = log4net.Log ...

  9. spring事物的七种事物传播属性行为及五种隔离级别

    首先,说说什么事务(Transaction). 事务,就是一组操作数据库的动作集合.事务是现代数据库理论中的核心概念之一.如果一组处理步骤或者全部发生或者一步也不执行,我们称该组处理步骤为一个事务.当 ...

  10. DIV指令一般用法

    本文最初发表于2015-8-14,是由别的地方迁移过来的 (本文所讲为无符号运算) DIV指令是8086汇编中的除法运算指令,它的结果不是浮点数,而是两个整数:商和余数. 我们来看王爽老师是怎么讲的: ...