前端之移动页面布局

更新日期: 2019-06-02阅读: 1.8k标签: 布局

移动端app分类

1、Native App 原生app手机应用程序
使用原生的语言开发的手机应用,Android系统用的是java,iOS系统用的是object-C
2、Hybrid App 混合型app手机应用程序
混合使用原生的程序和html5页面开发的手机应用
3、Web App 基于Web的app手机应用程序
完全使用html5页面加前端js框架开发的手机应用


Viewport 视口

视口是移动设备上用来显示网页的区域,一般会比移动设备可视区域大,宽度可能是980px或者1024px,目的是为了显示下整个为PC端设计的网页,这样带来的后果是移动端会出现横向滚动条,为了避免这种情况,移动端会将视口缩放到移动端窗口的大小。这样会让网页不容易观看,可以用 meta 标签,name=“viewport ” 来设置视口的大小,将视口的大小设置为和移动设备可视区一样的大小。

设置方法如下:
meta:vp+tab键

<head>
......
<meta name="viewport" content="width=device-width, user-scalable=no,initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
......
</head>

移动端视口示例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    
    <title>Document</title>
    <style type="text/css">
        .box{
            width:300px;
            height:300px;
            background-color:gold;
        }
    </style>
</head>
<body>
    <div class="box">div里面的文字</div>
</body>
</html>

 

视网膜屏幕(retina屏幕)清晰度解决方案

视网膜屏幕指的是屏幕的物理像素密度更高的屏幕,物理像素可以理解为屏幕上的一个发光点,无数发光的点组成的屏幕,视网膜屏幕比一般屏幕的物理像素点更小,常见有2倍的视网膜屏幕和3倍的视网膜屏幕,2倍的视网膜屏幕,它的物理像素点大小是一般屏幕的1/4,3倍的视网膜屏幕,它的物理像素点大小是一般屏幕的1/9。

图像在视网膜屏幕上显示的大小和在一般屏幕上显示的大小一样,但是由于视网膜屏幕的物理像素点比一般的屏幕小,图像在上面好像是被放大了,图像会变得模糊,为了解决这个问题,可以使用比原来大一倍的图像,然后用css样式强制把图像的尺寸设为原来图像尺寸的大小,就可以解决模糊的问题。

背景图强制改变大小,可以使用background新属性

清晰度解决示例:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>Document</title>
    <style type="text/css">

       /* retina屏幕适配:通过样式将它的尺寸设为原来的一半     */
        
        .shipei{
            width:300px;
            height:215px;
        }
    </style>
</head>
<body>
    <img src="images/pic1x.jpg" alt="1倍图">
    <img src="images/pic2x.jpg" alt="2倍图" class="shipei">
</body>
</html>

移动端背景图尺寸设置

background新属性 
background-size:

length:用长度值指定背景图像大小。不允许负值。
percentage:用百分比指定背景图像大小。不允许负值。
auto:背景图像的真实大小。
cover:将背景图像等比缩放到完全覆盖容器,背景图像有可能超出容器。
contain:将背景图像等比缩放到宽度或高度与容器的宽度或高度相等,背景图像始终被包含在容器内。

背景图尺寸适配示例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .box{
            width:200px;
            height:300px;
            border:2px solid #000;
            margin:50px auto 0;

            background:url(images/apple.png) no-repeat;

            /* background-size:200px 200px; */

            /* background-size:100% 100%; */

            /* 
                缩放图像,让图片的大小足够盖住容器
                background-size:cover; 

            */
            
            /* 缩放图像,让容器可以包含整个图像     */
            background-size:contain;
        }

    </style>
</head>
<body>
    <div class="box">asdfsdfsdfasdfdsf</div>
</body>
</html>

PC及移动端页面适配方法

PC及移动端页面适配方法
设备屏幕有多种不同的分辨率,页面适配方案有如下几种:
1、全适配:流体布局+响应式布局
2、移动端适配:
流体布局+少量响应式
基于rem的布局
弹性盒模型


流体布局

流体布局,就是使用百分比来设置元素的宽度,元素的高度按实际高度写固定值,流体布局中,元素的边线无法用百分比,可以使用样式中的计算函数 calc() 来设置宽度,或者使用 box-sizing 属性将盒子设置为从边线计算盒子尺寸。

calc() 可以通过计算的方式给元素加尺寸,比如: width:calc(25% - 4px);

box-sizing 
1、content-box 默认的盒子尺寸计算方式
2、border-box 置盒子的尺寸计算方式为从边框开始,盒子的尺寸,边框和内填充算在盒子尺寸内

流体布局示例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        body{
            margin:0;
        }
        .con a{
            display:block;
            width:25%;
            /* 
            width:calc(25% - 4px);
            */
            height:100px;
            background-color:gold;
            text-align: center;
            line-height:100px;
            float:left;
            text-decoration:none;
            color:#333;
            font-size:14px;
            border:2px solid #000;

            /* 将盒子真实尺寸的计算方式设置为包含边框和padding */
            box-sizing:border-box;
        }
    </style>
</head>
<body>
    <div class="con">
        <a href="#">菜单文字</a>
        <a href="#">菜单文字</a>
        <a href="#">菜单文字</a>
        <a href="#">菜单文字</a>
    </div>
</body>
</html>

响应式布局

响应式布局就是使用媒体查询的方式,通过查询浏览器宽度,不同的宽度应用不同的样式块,每个样式块对应的是该宽度下的布局方式,从而实现响应式布局。响应式布局的页面可以适配多种终端屏幕(pc、平板、手机)。

相应布局的伪代码如下:

@media (max-width:960px){
    .left_con{width:58%;}
    .right_con{width:38%;}
}
@media (max-width:768px){
    .left_con{width:100%;}
    .right_con{width:100%;}
}

响应式布局示例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>Document</title>
    <style type="text/css">        
        body{
            margin:0
        }
        .con div{
            width:23%;
            border:2px solid #000;
            background-color:gold;
            height:200px;
            margin:1%;
            float:left;
            box-sizing:border-box;
        }
        @media (max-width:800px){
            .con div{
                width:46%;
                margin:2%;
            }
        }
        @media (max-width:400px){
            
            .con div{
                width:94%;
                margin:3%;
            }
        }
    </style>
</head>
<body>
    <div class="con">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
    </div>
</body>
</html>

流体布局是将一行的内容按照比例进行压缩;
响应式布局是,当宽度小于一定比例时,将一行的内容分两行放置;

 

移动端布局实例

基于rem的布局

首先了解em单位,em单位是参照元素自身的文字大小来设置尺寸,rem指的是参照根节点的文字大小,根节点指的是html标签,设置html标签的文字大小,其他的元素相关尺寸设置用rem,这样,所有元素都有了统一的参照标准,改变html文字的大小,就会改变所有元素用rem设置的尺寸大小。

em单位示例

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        
        .box01{
            font-size:12px;
            width:20em;
            height:10em;
            background-color:gold;
        }

        .box02{
            font-size:20px;
            width:20em;
            height:10em;
            background-color:green;
        }

        p{
            font-size:20px;
            text-indent:2em;
        }

    </style>
</head>
<body>
    <div class="box01"></div>
    <br />
    <br />
    <div class="box02"></div>


    <p>首先了解em单位,em单位是参照元素自身的文字大小来设置尺寸,rem指的是参照根节点的文字大小,根节点指的是html标签,设置html标签的文字大小,其他的元素相关尺寸设置用rem,这样,所有元素都有了统一的参照标准,改变html文字的大小,就会改变所有元素用rem设置的尺寸大小。首先了解em单位,em单位是参照元素自身的文字大小来设置尺寸,rem指的是参照根节点的文字大小,根节点指的是html标签,设置html标签的文字大小,其他的元素相关尺寸设置用rem,这样,所有元素都有了统一的参照标准,改变html文字的大小,就会改变所有元素用rem设置的尺寸大小。</p>
</body>
</html>

最小的文字单位是12px,小于12px的文字大小都会默认改为12px;

rem单位示例

<!DOCTYPE html>
<html lang="en" style="font-size:30px;">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .box01{
            font-size:12px;
            width:20rem;
            height:10rem;
            background-color:gold;
            margin:1rem;
        }

        .box02{
            font-size:20px;
            width:20rem;
            height:10rem;
            background-color:green;
            margin:1rem;
            
        }
    </style>
</head>
<body>
    
    <div class="box01"></div>

    <div class="box02"></div>

</body>
</html>

rem是在移动页面将内容进行等比例缩小;

rem示例-通过js控制rem来动态控制内容宽度

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <!--<script type="text/javascript" src="js/set_root.js"></script>-->
    <title>Document</title>
    <style type="text/css">
        body{
            margin:0;
        }
        .header{
            height:2.5rem;
            background-color:gold;
            text-align:center;
            line-height:2.5rem;
            font-size:20px;
        }

    </style>
</head>
<body>
    <div class="header">头部文字</div>
</body>
<script>
    (function(){
    var calc = function(){
        var docElement = document.documentElement;
        var clientWidthValue = docElement.clientWidth > 750 ? 750 : docElement.clientWidth;
        docElement.style.fontSize = 20*(clientWidthValue/375) + 'px';
    };
    calc();
    window.addEventListener('resize',calc);
})();
</script>
</html>

cssrem安装

cssrem插件可以动态地将px尺寸换算成rem尺寸

下载本项目,比如:git clone https://github.com/flashlizi/cssrem 
进入packages目录:Sublime Text -> Preferences -> Browse Packages... 
复制下载的cssrem目录到刚才的packges目录里。 重启Sublime Text。

配置参数 参数配置文件:Sublime Text -> Preferences -> Package Settings -> cssrem px_to_rem - px转rem的单位比例,默认为40。 max_rem_fraction_length - px转rem的小数部分的最大长度。默认为6。 available_file_types - 启用此插件的文件类型。默认为:[".css", ".less", ".sass"]。

 

流体布局制作首页

将ui设计师给的图片按缩小一半来制作页面

index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="css/reset.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <title>天天生鲜-首页</title>
</head>
<body>
    <div class="header clearfix">
        <a href="#" class="logo"><img src="images/logo.png" alt="天天生鲜logo"></a>
        <a href="#" class="search"></a>
    </div>
</body>
</html>

set_root.js
(function(){
    var calc = function(){
        var docElement = document.documentElement;
        var clientWidthValue = docElement.clientWidth > 750 ? 750 : docElement.clientWidth;
        docElement.style.fontSize = 20*(clientWidthValue/375) + 'px';
    }
    calc();
    window.addEventListener('resize',calc);
})();

main.css
.header{
    height:50px;
    background-color:#37ab40;
    position:relative;
}

.logo{
    display:block;
    width:89px;
    height:36px;
    margin:7px auto 0;
}

.logo img{
    width:100%;
}

.search{
    width:27px;
    height:27px;
    position:absolute;
    right:15px;
    top:12px;
    background:url(../images/icons.png) left top no-repeat;
    background-size:60px 840px;
}

 

移动端轮播图和菜单页的制作

如果软件是在微信中,固定定位的按钮可能无效,因此移动端软件的三层式结构不应该用固定定位;解决方式是在最外面套一个大盒子,然后给里面的设置absolute绝对定位;最外层left:0;right:0;top:0;bottom:0;这样可以让最外层达到手机屏幕最大化;
将上下两层使用left:0;right:0;top:2.5rem;bottom:2.5rem;固定住;中间层再设置left:0;right:0;top:2.5rem;bottom:2.5rem;固定和overflow:auto可以进行滚动条;为了避免出现横线滚动条,拆开写overflow-y:auto;overflow-x:hidden;

雪碧图的使用除了给除第一个以外的其他元素添加类属性之外,还可以使用新增选择器的nth-child()来设置position;
移动端文字应该直接使用像素,不需要rem,因为太小了不易观看;
选择器层级越少越好,因为它找标签或属性等是从层级选择器的右边开始找的;

 

弹性盒模型布局

1、容器属性
display : flex
声明使用弹性盒布局

flex-direction : row | row-reverse | column | column-reverse
确定子元素排列的方向

flex-wrap : nowrap | wrap | wrap-reverse
元素超过父容器尺寸时是否换行

flex-flow : flex-direction | flex-wrap
同时设置flex-direction 和 flex-wrap

justify-content : flex-start | flex-end | center | space-between | space-around
子元素的尺寸确定之后,用此属性来设置flex-direction定义方向上的分布方式

align-items : flex-start | flex-end | center | baseline | stretch
子元素的尺寸确定之后,用此属性来设置flex-direction定义方向上的垂直方向的分布方式

align-content : flex-start | flex-end | center | space-between | space-around | stretch
设置多行子元素在行方向上的对齐方式

2、条目属性
flex : none | <' flex-grow '> <' flex-shrink >'? || <' flex-basis '>
同时设置flex-grow 和 flex-shrink 以及 flex-basis

flex-grow : number
表示的是当父元素有多余的空间时,这些空间在不同子元素之间的分配比例

flex-shrink: number
当父元素的空间不足时,各个子元素的尺寸缩小的比例

flex-basis :length | percentage | auto | content
用来确定弹性条目的初始主轴尺寸。

align-self :auto | flex-start | flex-end | center | baseline | stretch
覆写父元素指定的对齐方式

order : integer
改变条目在容器中的出现顺序

 

移动首页布局代码

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="css/reset.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <script type="text/javascript" src="js/set_root.js"></script>
    <title>天天生鲜-首页</title>
</head>
<body>
<div class="main_wrap">

    <div class="header clearfix">
        <a href="#" class="logo"><img src="images/logo.png" alt="天天生鲜logo"></a>
        <a href="#" class="search"></a>
    </div>
    <div class="center_con">

        <div class="slide"><img src="images/slide.jpg" alt="幻灯片"></div>

        <!-- ul.menu>(li>a+h2{水果})*8 -->
        <div class="menu_con clearfix">
            <ul class="menu">
                <li>
                    <a href="#"></a>
                    <h2>水果</h2>
                </li>
                <li>
                    <a href="#"></a>
                    <h2>水果</h2>
                </li>
                <li>
                    <a href="#"></a>
                    <h2>水果</h2>
                </li>
                <li>
                    <a href="#"></a>
                    <h2>水果</h2>
                </li>
                <li>
                    <a href="#"></a>
                    <h2>水果</h2>
                </li>
                <li>
                    <a href="#"></a>
                    <h2>水果</h2>
                </li>
                <li>
                    <a href="#"></a>
                    <h2>水果</h2>
                </li>
                <li>
                    <a href="#"></a>
                    <h2>水果</h2>
                </li>
            </ul>
        </div>
        
        <div class="common_model clearfix">
            <div class="common_title">
                <h3>新鲜水果</h3>
                <a href="#">更多 &gt;</a>
            </div>

            <a href="#" class="banner"><img src="images/banner.jpg" alt="banner"></a>

            <ul class="goods_list">
                <li>
                    <a href="#" class="goods_link"><img src="images/goods.jpg" alt="商品图片"></a>
                    <h4>新西兰皇家大红苹果</h4>
                    <p class="unit">12/提</p>
                    <p class="price">¥68.00</p>
                    <a href="#" class="add_chart"></a>
                </li>
                <li>
                    <a href="#" class="goods_link"><img src="images/goods.jpg" alt="商品图片"></a>
                    <h4>新西兰皇家大红苹果</h4>
                    <p class="unit">12/提</p>
                    <p class="price">¥68.00</p>
                    <a href="#" class="add_chart"></a>
                </li>
                <li>
                    <a href="#" class="goods_link"><img src="images/goods.jpg" alt="商品图片"></a>
                    <h4>新西兰皇家大红苹果</h4>
                    <p class="unit">12/提</p>
                    <p class="price">¥68.00</p>
                    <a href="#" class="add_chart"></a>
                </li>
            </ul>
        </div>

        <div class="common_model clearfix">
            <div class="common_title">
                <h3>新鲜水果</h3>
                <a href="#">更多 &gt;</a>
            </div>

            <a href="#" class="banner"><img src="images/banner.jpg" alt="banner"></a>

            <ul class="goods_list">
                <li>
                    <a href="#" class="goods_link"><img src="images/goods.jpg" alt="商品图片"></a>
                    <h4>新西兰皇家大红苹果</h4>
                    <p class="unit">12/提</p>
                    <p class="price">¥68.00</p>
                    <a href="#" class="add_chart"></a>
                </li>
                <li>
                    <a href="#" class="goods_link"><img src="images/goods.jpg" alt="商品图片"></a>
                    <h4>新西兰皇家大红苹果</h4>
                    <p class="unit">12/提</p>
                    <p class="price">¥68.00</p>
                    <a href="#" class="add_chart"></a>
                </li>
                <li>
                    <a href="#" class="goods_link"><img src="images/goods.jpg" alt="商品图片"></a>
                    <h4>新西兰皇家大红苹果</h4>
                    <p class="unit">12/提</p>
                    <p class="price">¥68.00</p>
                    <a href="#" class="add_chart"></a>
                </li>
            </ul>
        </div>
    </div>
    
    <ul class="footer">
        <li>
            <a href=""></a>
            <h2>首页</h2>
        </li>
        <li>
            <a href=""></a>
            <h2>首页</h2>
        </li>
        <li>
            <a href=""></a>
            <h2>首页</h2>
        </li>
        <li>
            <a href=""></a>
            <h2>首页</h2>
        </li>
    </ul>
</div>
</body>
</html>

set_root.js

(function(){
    var calc = function(){
        var docElement = document.documentElement;
        var clientWidthValue = docElement.clientWidth > 750 ? 750 : docElement.clientWidth;
        docElement.style.fontSize = 20*(clientWidthValue/375) + 'px';
    };
    calc();
    window.addEventListener('resize',calc);
})();

reset.css

/*  去掉标签默认的间距   */
body,ul,ol,p,h1,h2,h3,h4,h4,h6,dl,dd,select,input,form{
    margin:0;
    padding:0;
}
/*  去掉小圆点以及数字   */
ul,ol{
    list-style:none;
}
/* 去掉下划线 */
a{text-decoration:none;}

/* 去掉斜体 */
em{
    font-style:normal;
}
/* 让h标签继承body的文字设置 */
h1,h2,h3,h4,h4,h6{
    font-size:100%;
    font-weight:normal;
}
/* 在IE下去掉图片做链接时生成的框线 */
img{
    border:0px;
}

/* 清除浮动以及清除margin-top塌陷 */

.clearfix:before,.clearfix:after{
    content:'';
    display:table;
}
.clearfix:after{
    clear:both;
}
.clearfix{
    zoom:1;
}


.fl{
    float:left;
}

.fr{
    float:right;
}

main.css

.main_wrap {
    position: absolute;
    background-color: gold;
    left: 0px;
    right: 0px;
    top: 0px;
    bottom: 0px;
}

/* 顶部样式   */
.header {
    height: 2.5rem;
    background-color: #37ab40;
    position: relative;
}

.logo {
    display: block;
    width: 4.45rem;
    height: 1.8rem;
    margin: 0.35rem auto 0;
}

.logo img {
    width: 100%;
}

.search {
    width: 1.35rem;
    height: 1.35rem;
    position: absolute;
    right: 0.75rem;
    top: 0.6rem;
    background: url(../images/icons.png) left top no-repeat;
    background-size: 3.0rem 42.0rem;
}

/* 中间滚动区域的样式   */
.center_con {
    position: absolute;
    left: 0px;
    right: 0px;
    top: 2.5rem;
    bottom: 2.5rem;
    background-color: #efefef;

    /* 只自动出现竖向滚动条,不出现横向滚动条  */
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 0.5rem;
}

.slide {
    height: 7.0rem;
}

.slide img {
    width: 100%;
}

.menu_con {
    height: 9.25rem;
    background-color: #fff;
    margin-top: 0.5rem;
    overflow: hidden;
}

.menu_con ul {
    width: 18rem;
    height: 8.375rem;
    margin: 0.6rem 0 0 1.375rem;
}

.menu_con li {
    width: 2.8rem;
    height: 4.05rem;
    float: left;
    margin-right: 1.625rem;
}

.menu_con li a {
    display: block;
    height: 2.8rem;
    background: url(../images/icons.png) left -3.025rem no-repeat;
    background-size: 3.0rem 42.0rem;
}

.menu_con li:nth-child(2) a {
    background-position: left -6rem;
}

.menu_con li:nth-child(3) a {
    background-position: left -9rem;
}

.menu_con li:nth-child(4) a {
    background-position: left -12rem;
}

.menu_con li:nth-child(5) a {
    background-position: left -15rem;
}

.menu_con li:nth-child(6) a {
    background-position: left -18rem;
}

.menu_con li:nth-child(7) a {
    background-position: left -21rem;
}

.menu_con li:nth-child(8) a {
    background-position: left -24rem;
}

.menu_con li h2 {
    font: bold 13px/1.25rem 'Microsoft Yahei';
    text-align: center;
    color: #666;
}

.common_model {
    height: 17.25rem;
    background-color: #fff;
    margin-top: 0.5rem;
}

.common_title {
    width: 17.75rem;
    height: 0.9rem;
    margin: 0.8rem auto 0;
}

.common_title h3 {
    float: left;
    font: bold 15px/0.9rem 'Microsoft Yahei';
    color: #fbc83d;
    border-left: 0.25rem solid #fbc83d;
    text-indent: 0.4rem;
}

.common_title a {
    float: right;
    font: normal 12px/0.9rem 'Microsoft Yahei';
    color: #7f7f7f;
}

.banner {
    display: block;
    width: 17.75rem;
    height: 4.5rem;
    margin: 0.5rem auto 0;
}

.banner img {width: 100%;}

.goods_list {
    width: 17.75rem;
    height: 9.325rem;
    margin: 0.5rem auto 0;
}

.goods_list li {
    width: 5.9rem;
    height: 9.325rem;
    border-right: 1px solid #e7e7e7;
    float: left;
    box-sizing: border-box;
    position: relative;
}

.goods_list li:last-child {border-right: 0px;}

.goods_link {
    display: block;
    width: 4.5rem;
    height: 4.5rem;
    margin: 0.375rem auto 0;
}

.goods_link img {
    width: 100%;
}

.goods_list h4 {
    font: normal 15px/15px 'Microsoft Yahei';
    width: 5.0rem;
    margin: 0.925rem auto 0;

    overflow: hidden;
    /* 强制文字不换行 */
    white-space: nowrap;
    /* 超出部分显示省略号   */
    text-overflow: ellipsis;
}

.unit {
    width: 5.0rem;
    font: normal 12px/12px 'Microsoft Yahei';
    color: #bbb;
    margin: 0.8rem auto 0;
}

.price {
    width: 5.0rem;
    font: normal 12px/12px 'Microsoft Yahei';
    color: #ff4400;
    margin: 0.5rem auto 0;
}

.add_chart {
    position: absolute;
    width: 1.7rem;
    height: 1.7rem;
    right: 0.675rem;
    bottom: 0;
    background: url(../images/icons.png) left -27.0rem no-repeat;
    background-size: 3.0rem 42.0rem;
}

.footer {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 2.5rem;
    background-color: #fff;

}

.footer li {
    width: 25%;
    height: 2.5rem;
    float: left;
}

.footer li a {
    display: block;
    width: 1.3rem;
    height: 1.3rem;
    margin: 0.35rem auto 0;
    background: url(../images/icons.png) left -30.0rem no-repeat;
    background-size: 3.0rem 42.0rem;
}

.footer li:nth-child(2) a {
    background-position: left -33rem;
}

.footer li:nth-child(3) a {
    background-position: left -36rem;
}

.footer li:nth-child(4) a {
    background-position: left -39rem;
}

.footer li h2 {
    font: normal 12px/0.8rem 'Microsoft Yahei';
    color: #949392;
    text-align: center;
}

 来自:https://www.cnblogs.com/yifchan/p/html-1-6.html


链接: https://www.fly63.com/article/detial/3515

css两端对齐——div+css布局实现2端对齐的4种方法总结

css两端对齐,通过margin负值、justify、space-between、column-count等多种方式来实现css的两端对齐。

flex布局,学习flex弹性布局总结

flex布局(Flexible Box)是对界面css盒模型的一个优化,适应不同尺寸的屏幕,被定义flex的容器可以控制子元素的排列方向和大小,能够用更简单清晰的代码来完成复杂的布局。

html通过css,js实现div悬浮效果总汇,如原生JS实现滚动到一定位置实现div悬浮

在我们的实际开发中,经常会遇到页面中需要悬浮效果,本文将介绍通过fixed的实现,以及通过原生Js实现滚动到一定位置,实现div的悬浮

理解css中Grid布局,在项目中如何实现grid页面布局

CSS中Grid是一种二维网格式布局方式,Grid是为了解决二维布局问题而创建的CSS模块。使用Gird的好处,Gird在浏览器的兼容性,Grid布局的示例源码...

使用flex实现5种常用布局

flex常用布局:经典的上-中-下布局。在上-中-下布局的基础上,加了左侧定宽 sidebar。左边是定宽 sidebar,右边是上-中-下布局。还是上-中-下布局,区别是 header 固定在顶部,不会随着页面滚动。左侧 sidebar 固定在左侧且与视窗同高,当内容超出视窗高度时,在 sidebar 内部出现滚动条。

你以为 CSS 只是个简单的布局?

本文中,所有的图形都是在单个标签内实现的,大量使用了 CSS3 中的 ::before 、::after 伪元素,transparent 、border,多重线性与径向渐变,多重内外阴影,如果你的效果不尽人意,请尝试在 Chrome 浏览器下预览。

html实现时间轴_纯css实现响应式竖着/垂直时间抽布局效果

html实现用时间点来展示事件发生点来代替用table展示一条条数据,能够给人清晰、一目了然能够看清事情发生的过程,UI页面也显示的那么清晰。如何用css+html做出时间轴展示事件点的?

基于jquery 横向/纵向 时间轴插件推荐

这篇文章主要整理一些关于基于jquery,实现横向/纵向时间轴的插件推荐:jquery.jqtimeline插件、timeline.js插件、Timeglider.js插件、Melon HTML5 、jQuery Timelinr、Timeline Porfolio

CSS position 属性_css中常用position定位属性介绍

css可以通过为元素设置一个position属性值,position定位是指定位置的定位,以下为常用的几种:static(静态定位)、relative定位(相对定位)、absolute定位(绝对定位)、fixed(固定定位)、inherit定位

css圣杯布局的实现方式

css圣杯布局思路:外面一个大div,里面三个小div(都是浮动)。实现左右两栏宽度固定,中间宽度自适应。中间栏优先渲染。

点击更多...

内容以共享、参考、研究为目的,不存在任何商业目的。其版权属原作者所有,如有侵权或违规,请与小编联系!情况属实本人将予以删除!