Home  >  Article  >  Web Front-end  >  css布局小技巧 2016.03.06_html/css_WEB-ITnose

css布局小技巧 2016.03.06_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:17:08816browse

偶遇一个可爱的css布局学习网站,立刻学起来哟~

  1. max-width:
    当页面左右宽度缩小时,为了避免出现左右滚动条的糟糕体验,就可以用到max-width啦!页面比宽度小时,会自动缩小哦~

    max-width : 500px;margin: 0 auto;}
  2. box-sizing:
    对元素设置box-sizing:border-box后,确定宽度后再设置padding和border,不会改变宽度。可以对全局设置,解决浏览器兼容问题的写法如下:

    -webkit-box-sizing : border-box;-moz-box-sizing:border-box;box-sizing:border-box; }
  3. overflow:auto
    边框自适应内容的大小,不会出现overflow的情况。
    IE兼容方案:

    .example{overflow:auto;zoom:1; }
  4. 响应式设计-媒体查询
    运用媒体查询后,可以根据不同的页面宽度设置不同的布局,方法如下:

    //页面宽度大于600px时,nav模块浮动于左侧@media screen and (min-width: 600px) {nav {    float: left;    width: 25%;}section {    margin-left: 25%;}}//页面宽度小于599时,nav模块打横,在上方@media screen and (max-width: 599px) {nav li {    display: inline;}}
  5. 文字多列布局:

    .three-column {padding :1em;-moz-column-count :3;-moz-column-gap: 1em;-webkit-column-count :3;-webkit-column-gap: 1em;column-count:3;column-gap:1em;}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn