• 技术文章 >web前端 >html教程

    常用CSS居中_html/css_WEB-ITnose

    2016-06-24 11:18:11原创532

    1.flex方法:

    .center_fix{ display:flex; align-items:center;justify-content: center;}

    具体flex方法教程:可以参见软老师的——》Flex 布局教程:实例篇

    2.position:absolute

    .center{position: absolute;top:50%; left:50%;width: 100px;height:100px;margin-top: -50px;margin-left:-50px;background: teal;}

    3.position: fixed;和上一个absolute方法差不多

    .center{position: absolute;top:50%;left:50%;width: 100px;height:100px;margin-top: -50px;margin-left:-50px;background: teal;} 

    4.

    .center{position: fixed;width: 100px;height: 100px;top: 0;right: 0;left: 0;bottom: 0;margin: auto;background: teal; }


    5.

    .center{position: absolute;width: 100px;height: 100px;top: 0;bottom: 0;left: 0;right: 0;margin: auto;background: teal;}  

    6.CSS3盒模型display:-webkit-box

    .center{display:-webkit-box;-webkit-box-pack:center;-webkit-box-align:center;width:100px;height:100px;background:teal;color:black;} 


    声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
    专题推荐:常用CSS居中
    上一篇:atitit.提升性能AppCache_html/css_WEB-ITnose 下一篇:自己动手写 PHP MVC 框架(40节精讲/巨细/新人进阶必看)

    相关文章推荐

    • clear:both 后按钮错位了_html/css_WEB-ITnose• ExtJs教程7(下)• 如何向当前的html文档输入一段字符_html/css_WEB-ITnose• 七个你可能不了解的CSS单位_html/css_WEB-ITnose• 开始的续写_html/css_WEB-ITnose
    1/1

    PHP中文网