zhangyuxiang1226 / blogs Goto Github PK
View Code? Open in Web Editor NEWblogs
blogs
IE8下 checkbox 隐藏时,label的点击和js都无法改变 checked状态,
<script src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<style type="text/css">
#testCkb {
/*display: none;*/
}
</style>
</head>
<body>
<label for="testCkb" class="ckb-label">
<input type="checkbox" id="testCkb">点击勾选
</label>
<script>
console.log($("#testCkb").prop("checked"));
$(".ckb-label").click(function () {
console.log($("#testCkb").prop("checked"));
});
</script>
</body>
</html>
display:none;
隐藏 checkbox,点击label后,checked属性无法发生改变visibility:hidden;
隐藏checkbox,点击label,checked属性依然无法改变开发中对checkbox美化时,如果需要兼容IE8,那么不要采用 display:none 或者 visibility:hidden,这样会时checked属性不能正常切换;
可以采用绝对定位方式,用美化的图层设置z-index高于该checkbox
在项目中对同一拼图复用时,为简化代码,采用 background-position-y来重置不同元素的背景图
在最新版 FF(45.0)中依然不支持
.box1,.box2 {
background-image(img/bg.jpg);
background-repeat:no-repeat;
background-position: 0 -10;
}
.box2 {
background-position-y: -20px;
}
在FF下是不识别的
项目中一竖列表采用 dl:dd:a 的层级搭建,其中为使a元素填充dd,采用inline-block;
.help-menu dt, .help-menu dd {
width: 100%;
height: 36px;
line-height: 36px;
border-bottom: 1px solid #f3f3f5;
}
.help-menu dt {
background-color: #f3f3f3;
padding-left: 44px;
}
.help-menu dd a {
color: #2b2b2b;
font-size: 13px;
display: inline-block;
width: 100%;
height: 100%;
padding-left: 30px;
text-decoration: none;
}
以上省略hover效果,hover时背景变色并带有渐变
效果:
可见a元素与上边距有1px的间隔,且通过对a设置高度和行高都不能生效,且父元素没有任何padding或margin挤压位置
对a的display:inline-block改为使用 display:block;
在行内元素需要设置宽高占满父容器时,而且同块内没有其他元素时,可以考虑设置为 display:block;
inline-block在垂直居中等问题上也比较难把握。
更多关于inline-block的可以参考张鑫旭老师的 http://www.zhangxinxu.com/wordpress/tag/inline-block/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.