属于行内替换元素,可设置width
height
margin
padding
。一行可放置多张图片。
只设置设置width
,height
会根据比例进行缩放。在移动App开发中常常会用到。html
zepto
中的offset()
方法用于获取元素在页面的位置,使用时最好放在load
方法中。由于页面中还没加载彻底的元素(好比未定高的图片)会影响offset()
对位置的计算。.net
有时候可使用vertical-align
,使用像素值做为值进行微调,如vertical-align: 2px
3d
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