一些琐碎点

img标签的特殊之处

属于行内替换元素,可设置width height margin padding。一行可放置多张图片。
只设置设置widthheight会根据比例进行缩放。在移动App开发中常常会用到。html

使用offset注意点

zepto中的offset()方法用于获取元素在页面的位置,使用时最好放在load方法中。由于页面中还没加载彻底的元素(好比未定高的图片)会影响offset()对位置的计算。.net

图标、文字对不齐

有时候可使用vertical-align,使用像素值做为值进行微调,如vertical-align: 2px3d

使用translate居中

demo: http://jsfiddle.net/c3dgsrbr/code

<div class="wrap">
   <div class="center"></div>
</div>
.wrap{
     width: 400px;
     height: 400px;
     background-color: #add8e6;
     position: relative;
 }
.center{
    width: 100px;
    height: 100px;
    position: absolute;
    background-color: #FFF;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
}

欢迎讨论交流!若是文章对你有帮助,点下面的推荐鼓励下呗(๑>؂<๑)orm

相关文章
相关标签/搜索