03_CSS3

新版伸缩布局

这里我们需要引入一些新的概念:
主轴:Flex容器的主轴主要用来配置Flex项目。
侧轴:与主轴垂直的轴称作侧轴,是侧轴方向的延伸。
主轴和侧轴并不是固定不变的,通过flex-direction可以调整。


1、指定一个盒子为伸缩盒子 display: flex
2、设置属性来调整此盒的子元素的布局方式 例如 flex-direction
3、明确主侧轴的方向
4、可互换主侧轴,也可改变方向
  其相关属性可参照源代码里的解释如flex-direction、flex-wrap、flex-flow、align-items、align-content、justify-content、align-self、flex、order等
  另个两个版本伸缩布局其实现思路与新版基本一致,区别在于其属性及属性值不同,熟练掌握新版伸缩布局后,要参照对比另外两个版本的不同。

单位:em和rem

  • em取的是当前容器的font-size
  • 而rem是相对于根容器font-size来确定的,rem应该就是root em简写(不确定),如果整个网页都是通过rem的单位设置尺寸,只要在跟容器(body)设置一个具体的font-size为像素单位,而且当这个像素值变化整个页面所有用到rem的地方都会等比例变化,便于维护。
  • 也就是说rem取的是htmlfont-size
  • 相关链接:http://www.w3cplus.com/css3/define-font-size-with-css3-rem

字体图标

@font-face {
  font-family: 'itcast';
  src: url('../font/MiFie-Web-Font.eot') format('embedded-opentype'), url('../font/MiFie-Web-Font.svg') format('svg'), url('../font/MiFie-Web-Font.ttf') format('truetype'), url('../font/MiFie-Web-Font.woff') format('woff');
}

[class^="icon-"],
[class*=" icon-"] {
  font-family: itcast;
}

格式

  • eot : embedded-opentype
  • svg : svg
  • ttf : truetype
  • woff : woff

渐变应用

例:动感的按钮、球体、进度条

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        .box{
            width: 200px;
            height: 200px;
            float: left;
            margin: 0 20px;
        }
        .box .linear-gradient{
            width: 180px;
            height: 65px;
            margin: 70px auto;
            background-color: green;
            border-radius: 8px;
            background-image: linear-gradient(0deg, rgba(0,0,0,.5) , rgba(0,0,0,.0));
            text-align: center;
            line-height: 65px;
            font-size: 20px;
            color: #FFF;
            cursor: pointer;
        }
        .box .boll{
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background-color: blue;
            background-image: radial-gradient(120px at 50px 50px,rgba(0,0,0,0) ,rgba(0,0,0,0.5));
        }
        .box .progress{
            width: 180px;
            height: 40px;
            margin: 80px auto;
            background-color: yellow;
            background-image: linear-gradient(
                    135deg,
                    green 25%,
                    transparent 25%,
                    transparent 50%,
                    green 50%,
                    green 75%,
                    transparent 75%,
                    transparent 100%
            );
            background-size: 40px 40px;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="linear-gradient">保存</div>
    </div>

    <div class="box">
        <div class="boll"></div>
    </div>

    <div class="box">
        <div class="progress"></div>
    </div>
</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,687评论 1 92
  • H5移动端知识点总结 阅读目录 移动开发基本知识点 calc基本用法 box-sizing的理解及使用 理解dis...
    Mx勇阅读 10,128评论 0 26
  • 移动开发基本知识点 一.使用rem作为单位 html { font-size: 100px; } @media(m...
    横冲直撞666阅读 8,898评论 0 6
  • 阅读目录移动开发基本知识点 calc基本用法box-sizing的理解及使用理解display:box的布局理解f...
    张宪宇阅读 5,481评论 0 1
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    wzhiq896阅读 5,855评论 0 2