chrome,也就是webkit内核下作的检测, chrome版本是40, -webkit-box这种布局在移动端用的比较多,主要是因为pc端的浏览器内核参差不齐。 因为在写HTML的时候看上了-webkit-box的自动根据浏览器窗口大小自动排列的智能布局, 所以我也入了坑, 坑是这样的:

<!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=utf-8" />
<title>无标题文档</title>
</head>
<body>
<style>
*{
margin:0;
paddign:0;
}
.webbox{
display: -webkit-box;
}
.webbox-vertical{
display: -webkit-box;
-webkit-box-orient:vertical;
}
.box-flex{
-webkit-box-flex:1;
}
body,html,#div{
width:100%;
height:100%;
}
.auto{
overflow:auto;
}
</style> <div id="div" class="webbox-vertical"> <div class="webbox">
............<br />
............<br />
</div>
<div class="webbox">
ddd<br />
ddd<br />
ddd<br />
ddd<br />
</div>
<div class="webbox box-flex">
<div class="webbox box-flex auto">
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<span>sfsdfsfsfsd</span>
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<span>sfsdfsfsfsd</span>
<a href="###">aaa</a><br />
<span>sfsdfsfsfsd</span>
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<span>sfsdfsfsfsd</span>
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br />
<a href="###">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="###">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="###">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="###">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="###">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="###">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br />
</div>
<div class="webbox">
111111111<br />
111111111<br />
111111111<br />
111111111<br />
</div>
</div> </div>
<script>
var aS = document.getElementsByTagName("span");
for(var i = 0; i < aS.length ; i++) {
aS[i].addEventListener("click",function(ev){
console.log(ev);
})
};
/*
chrome浏览器在webbox布局下的一个bug;
如果你的webbox布局下的元素里面存在a链接或者audio,checkbox这些元素,
当你点击这些元素, 滚动条会滚到最上面, 扯淡扯大了, 我勒个去;
*/
</script>
</body>
</html>

  在webkit-box的布局元素中,如果你点击了a链接,这个链接的href为###, 如果这个元素的父级有滚动条,滚动条居然会自动滚到最上面(正常情况下不会跳的);

太扯淡的说,

  解决方法就是:在webkit-box布局的元素中添加一个元素样式为width:100%;position:relative;overflow:auto;,

  然后在这个元素的子元素再添加一个元素为样式为left:0;top:0;bottom:0;position:absolute; 然后把需要的滚动的HTML代码放进去, 滚动条出现了。。

  这个是为什么我也搞不懂; 因为在mathon(遨游浏览器)测试没有这个问题, 归结为浏览器问题,上网也没找到资料, 记录下来, 防坑;

  实现的代码如下:

<!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=utf-8" />
<title>无标题文档</title>
</head>
<body>
<style>
*{
margin:0;
paddign:0;
}
.webbox{
display: -webkit-box;
}
.webbox-vertical{
display: -webkit-box;
-webkit-box-orient:vertical;
}
.box-flex{
-webkit-box-flex:1;
}
body,html,#div{
width:100%;
height:100%;
}
.auto{
overflow:auto;
}
</style> <div id="div" class="webbox-vertical"> <div class="webbox">
............<br />
............<br />
</div>
<div class="webbox">
ddd<br />
ddd<br />
ddd<br />
ddd<br />
</div>
<div class="webbox box-flex">
<div class="webbox box-flex">
<div style="width:100%;position:relative;overflow:auto;">
<div style="left:0;top:0;bottom:0;position:absolute;">
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<span>sfsdfsfsfsd</span>
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<span>sfsdfsfsfsd</span>
<a href="####">aaa</a><br />
<span>sfsdfsfsfsd</span>
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<span>sfsdfsfsfsd</span>
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br />
<a href="####">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="####">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="####">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="####">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="####">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> <a href="####">aaa</a><br /><input class="input-index ng-pristine ng-untouched ng-valid" ng-disabled="topic.checked" ng-model="topic.checked" data-topic-id="15Q2700664" type="checkbox"><br /> </div>
</div>
</div>
<div class="webbox">
111111111<br />
111111111<br />
111111111<br />
111111111<br />
</div>
</div> </div>
<script>
var aS = document.getElementsByTagName("span");
for(var i = 0; i < aS.length ; i++) {
aS[i].addEventListener("click",function(ev){
console.log(ev);
})
};
/*
chrome浏览器在webbox布局下的一个bug;
如果你的webbox布局下的元素里面存在a链接或者audio,checkbox这些元素,
当你点击这些元素, 滚动条会滚到最上面, 扯淡扯大了, 我勒个去;
*/
</script>
</body>
</html>

  平常布局上面要注意符合html标准,要么会死的很惨。

  张鑫旭的webkit相关资料,可以学习一下,打开;

  w3c的资料打开

  

  

在chrome下-webkit-box布局的一个bug的更多相关文章

  1. 记录Window系统下myeclipes连接linux下mysql所出现的一个bug

    记录myeclipes远程连接mysql所出现的一个bug 今天在玩框架hibernate时,出现一个非常费解的bug,话不多说,先看bug Access denied for user 'root' ...

  2. Chrome 下,重复使用 XMLHttpRequest进行Post数据时,遇到一个奇怪的问题

    var http_request; //在外面申明对象,主要为了在updatePage中使用     //无刷新更新内容 function post(url,parameter) {        i ...

  3. 当fixed元素相互嵌套时chrome下父元素会影响子元素的层叠关系

    问题:fixed元素被另一个fixed元素包含的时候在chrome下fixed子元素的定位会受到父元素的影响. demo(http://jsbin.com/qumah/1): <!DOCTYPE ...

  4. C-Flex 与 box布局教程

    http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html -阮一峰老师 http://www.w3cplus.com/css3/flexbox- ...

  5. flutter系列之:把box布局用出花来

    目录 简介 LimitedBox SizedBox FittedBox 总结 简介 flutter中的layout有很多,基本上看layout的名字就知道这个layout到底是做什么用的.比如说这些l ...

  6. Chrome出了个小bug:论如何在Chrome下劫持原生只读对象

    Chrome出了个小bug:论如何在Chrome下劫持原生只读对象 概述 众所周知,虽然JavaScript是个很灵活的语言,浏览器里很多原生的方法都可以随意覆盖或者重写,比如alert.但是为了保证 ...

  7. 分享在winform下实现左右布局多窗口界面-续篇

    之前的这篇文章<分享在winform下实现左右布局多窗口界面>已经实现了左右布局多窗口界面,今天本来是研究基于winform的插件编程,没想到顺便又找到了另一种实现方案,这种实现方案更简单 ...

  8. 如何在Chrome下Debug Mocha的测试

    简介 经过前两篇文章的介绍,相信读者对Mocha应该有一定的认知了,本文重点讲述如何在Chrome下Debug Mocha Test, 方便你在测试fail的时候troubleshooting. 关键 ...

  9. ie8下使用knockoutjs遇到的一个模板异常

    ViewModel中有一个数组,代码大概如下: function ReportViewModel(){ var self = this; self.extendedProperties = ko.ob ...

随机推荐

  1. NOIP2004合并果子

    题目描述 在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆.多多决定把所有的果子合成一堆. 每一次合并,多多可以把两堆果子合并到一起,消耗的体力等于两堆果子的重量之和.可 ...

  2. ATM模拟程序

    一个很简单的ATM模拟程序 #include <stdio.h> void chaxun(int a3){ int b; b=a3; printf("您的余额为:%d\n&quo ...

  3. 第10章 同步设备I/O和异步设备I/O(1)_常见设备及CreateFile函数

    10.1 打开和关闭设备 10.1.1 设备的定义——在Windows中可以与之进行通信的任何东西. (1)常见设备及用途 设备 用途 用来打开设备的函数 文件 永久存储任何数据 CreateFile ...

  4. Unity StartCoroutine 和 yield return 深入研究

    http://www.cnblogs.com/fly-100/p/3910515.html

  5. Unity3D中Update()与FixedUpdate()的区别

    Unity3D中Update()与FixedUpdate()的区别是什么呢?从字面上理解,它们都是在更新时会被调用,并且会循环的调用.但是Update会在每次渲染新的一帧时,被调用.而FixedUpd ...

  6. Windows系统Stunnel客户端的配置

    Stunnel官方就有Windows版本,到下面的地址下载: https://www.stunnel.org/downloads.html 选择”stunnel-X.XX-installer.exe“ ...

  7. BZOJ 2190: [SDOI2008]仪仗队

    2190: [SDOI2008]仪仗队 Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 2689  Solved: 1713[Submit][Statu ...

  8. Java 集合系列12之 TreeMap详细介绍(源码解析)和使用示例

    概要 这一章,我们对TreeMap进行学习.我们先对TreeMap有个整体认识,然后再学习它的源码,最后再通过实例来学会使用TreeMap.内容包括:第1部分 TreeMap介绍第2部分 TreeMa ...

  9. Visual Studio 2013编辑HTML文件无设计视图的解决方案

    在Visual Studio 2013中编辑HTML文件,会发现没有设计视图. 解决方法:点击Visual Studio 2013的”工具“菜单,再点击”选项“—>文本编辑器—>文件扩展名 ...

  10. IE8 HACK介绍

    1.‘\9’: eg:.test { color/*\**/: blue\9 }.header {width:300px;} /* 所有浏览器*/.header {width/*\**/:330px\ ...