百分比布局实现响应式布局在 IE6 中填坑思路
最近接了个政府项目,政府项目要求响应式,并且兼容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">  </a>
<a href="jap/jap.html" id="jap" class="jap"> </a>
<a href="land/land.html" id="land" class="land"> </a>
<a href="front.html" id="end" class="end"> </a>
<a href="imp/imp.html" id="imp" class="imp"> </a>
<a href="base/base.html" id="base" class="base"> </a>
<a href="his/his.html" id="his" class="his"> </a>
</div>
</div>
</body>
</html>
IE6下图片无法正常显示:用PS打开图片,将颜色模式改成RGB格式,完美解决
百分比布局实现响应式布局在 IE6 中填坑思路的更多相关文章
- html响应式布局,css响应式布局,响应式布局入门
html响应式布局,css响应式布局,响应式布局入门 >>>>>>>>>>>>>>>>>>& ...
- 浅谈静态布局、流式布局,rem布局,弹性布局、响应式布局
静态布局: 特点:没有兼容性问题 PC:居中布局,所有样式使用绝对宽度/高度(px),设计一个Layout,在屏幕宽高有调整时,使用横向和竖向的滚动条来查阅被遮掩部分:移动设备:另外建立移动网站,单独 ...
- 自适应布局,响应式布局以及rem,em区别
一.自适应和响应式 先说共同点: 两者都是因为越来越多的 移动设备( mobile, tablet device )加入到互联网中来而出现的为移动设备提供更好的体验的技术.用技术来使网页适应从小到大( ...
- Bootstrap页面布局5 - 响应式布局(格式)
旨在优化不同上网设备中页面显示的优化 响应式布局:就是根据浏览窗口的尺寸,改变页面的变化 原理:利用css的media-queries判断浏览窗口的尺寸,在CSS样式表中设置一些规则! 例如: 在&l ...
- [学习笔记]viewport定义,弹性布局,响应式布局
一,移动端宽度设置viewport视图窗口,<meta name="viewport" content="width=device-width,initial-sc ...
- viewport定义,弹性布局,响应式布局及LESS和SASS框架应用
一,移动端宽度设置 viewport视图窗口,<meta name="viewport" content="width=device-width,initial-s ...
- 静态布局、自适应布局、流式布局、响应式布局、弹性布局简析、BFC
静态布局:给页面元素设置固定的宽度和高度,单位用px,当窗口缩小,会出现滚动条,拉动滚动条显示被遮挡内容.针对不同分辨率的手机端,分别写不同的样式文件.例如:浏览器窗口是1000px,那么最小的宽度是 ...
- rem布局及响应式布局
流式布局(100%布局)(可能:做的页面不是很美观)效果与弹性布局一样 不设置宽高:表示宽 auto 最外层:保证100% 等比例缩放的算法: 320/10 已知的一个比例 = 已知的宽/x ...
- 移动 WEB 开发的布局方式 ---- 响应式布局
一.响应式简介 一个页面布局兼容了 PC端 ,iPad端 和 移动端 所谓的响应式就是页面中的布局会随着屏幕的大小变化发生了响应而做出不同的页面布局模型 特点: 响应式布局是不需要单独写移动端页面的 ...
随机推荐
- sql查看当前周数
select datepart(wk,cast(getdate() as datetime))
- Objective-C基本数据类型、表达式和语句
一.基本数据类型 1.一般的计算机语言在定义变量的时候,需要提供给两个内容:类型和名字. 比如:int myClassID; 2.在Xcode中,无论你使用的是GCC编译器还是LLVM编译器,如果我们 ...
- sender是什么意思C#
/// <summary> /// sender就是事件发起者,e存储事件发起者的一些参数 /// 例如: /// private void button1_Click(object se ...
- Java通过Executors提供四种线程池
http://cuisuqiang.iteye.com/blog/2019372 Java通过Executors提供四种线程池,分别为:newCachedThreadPool创建一个可缓存线程池,如果 ...
- 写一个函数,尽可能高效的,从一个标准 url 里取出文件的扩展名
例如: http://www.sina.com.cn/abc/de/fg.php?id=1 需要取出 php 或 .php function getExt($url){ $arr=parse_url( ...
- 2.html5的基本格式
分享完html语言的核心之后,是时候开始写了.理论上,只要符合格式要求,就算是用记事本也可以写.但是,这种蛋疼且生产力低下的行为还是少做的好,选一个适合自己的IDE才是上上之选,至于哪个合适自己,那就 ...
- [转]Openwrt的Inittab
转来一篇关于启动的文章,特意收藏.http://see.sl088.com/wiki/Inittab 文件位于/etc/inittab编辑方法vi /etc/inittab初始内容::sysinit: ...
- LINUX开启允许对外访问的网络端口
LINUX开启允许对外访问的网络端口 LINUX通过下面的命令可以开启允许对外访问的网络端口: /sbin/iptables -I INPUT -p tcp --dport 8000 -j ACCE ...
- 转 在SQL Server中创建用户角色及授权(使用SQL语句)
目录 要想成功访问 SQL Server 数据库中的数据 我们需要两个方面的授权 完整的代码示例 使用存储过程来完成用户创建 实例 要想成功访问 SQL Server 数据库中的数据, 我们需要两个 ...
- gravity、layout_gravity、ayout_weight 区别及用法
layout_gravity 表示组件自身在父组件中的位置. gravity 表示组件的子组件在组件中的位置. weight 意思是权重.比重,即当前控件在画布中所占的空间 ...