zoukankan      html  css  js  c++  java
  • css 居中布局

    水平居中

    <style>
    .parent{
    	 100%;
    	height: 50px;
    	background: red;
    	text-align: center;
    }
    .child{
    	display: inline-block;
    	background: #ccc;
    }
    </style>
    <div class="parent">
    	<div class="child">我相信这么优秀的你,一定会成功的</div>
    </div>
    



    table margin

    <style>
    .parent{
    	 100%;
    	height: 50px;
    	background: red;
    }
    .child{
    	display: table;
    	margin: 0 auto;
    	background: #ccc;
    }
    </style>
    <div class="parent">
    	<div class="child">我相信这么优秀的你,一定会成功的</div>
    </div>
    


    ### absolute transform ```
    我相信这么优秀的你,一定会成功的
    ``` ![](https://images2018.cnblogs.com/blog/1321525/201806/1321525-20180601121839752-451299955.png)

    flex margin

    <style>
    .parent{
    	 100%;
    	height: 50px;
    	background: red;
    	display: flex;
    }
    .child{
    	background: #ccc;
    	margin: 0 auto;
    }
    </style>
    <div class="parent">
    	<div class="child">我相信这么优秀的你,一定会成功的</div>
    </div>
    



    flex justify-content

    <style>
    .parent{
    	 100%;
    	height: 50px;
    	background: red;
    	display: flex;
    	justify-content: center;
    }
    .child{
    	background: #ccc;
    }
    </style>
    <div class="parent">
    	<div class="child">我相信这么优秀的你,一定会成功的</div>
    </div>
    



    垂直居中

    table-cell vertical-align

    <style>
    .parent{
    	 100px;
    	height: 100px;
    	background: red;
    	display: table-cell;
    	vertical-align: middle;
    }
    .child{
    	background: #ccc;
    }
    </style>
    <div class="parent">
    	<div class="child">学无止境</div>
    </div>
    



    absolute transform

    <style>
    .parent{
    	 100px;
    	height: 100px;
    	background: red;
    	position: relative;
    }
    .child{
    	background: #ccc;
    	position: absolute;
    	top: 50%;
    	transform: translateY(-50%);
    }
    </style>
    <div class="parent">
    	<div class="child">学无止境</div>
    </div>
    


    ### flex align-items ```
    学无止境
    ``` ![](https://images2018.cnblogs.com/blog/1321525/201806/1321525-20180601122905921-1276317420.png)

    水平垂直居中

    absolute transform

    <style>
    .parent{
    	 400px;
    	height: 100px;
    	background: red;
    	position: relative;
    }
    .child{
    	background: #ccc;
    	position: absolute;
    	top: 50%;
    	left: 50%;
    	transform: translate(-50%, -50%);
    }
    </style>
    <div class="parent">
    	<div class="child">学无止境</div>
    </div>
    



    line-block text-align table-cell vertical-align

    <style>
    .parent{
    	 400px;
    	height: 100px;
    	background: red;
    	display: table-cell;
    	vertical-align: middle;
    	text-align: center;
    }
    .child{
    	background: #ccc;
    	display: inline-block;
    }
    </style>
    <div class="parent">
    	<div class="child">学无止境</div>
    </div>
    



    flex justify-content align-items

    <style>
    .parent{
    	 400px;
    	height: 100px;
    	background: red;
    	display: flex;
    	justify-content: center;
    	align-items: center;
    }
    .child{
    	background: #ccc;
    }
    </style>
    <div class="parent">
    	<div class="child">学无止境</div>
    </div>
    



  • 相关阅读:
    原生js ajax与jquery ajax的区别
    ajax的五大步骤
    js中setTimeout()时间参数设置为0的探讨
    js数组与字符串的相互转换方法
    javascript的三个组成部分
    linq 获取不重复数据,重复数据 var unique = arr.GroupBy(o => o).Where(g => g.Count() == 1) .Select(g => g.ElementAt(0));
    C# 随机 抽奖 50个随机码 不重复
    聚集索引和非聚集索引 聚集索引的叶节点就是最终的数据节点,而非聚集索引的叶节仍然是索引节点,但它有一个指向最终数据的指针。
    WPF ControlTemplate,DataTemplate
    C# 实现 奇数偶数排序,奇数在前,偶数在后
  • 原文地址:https://www.cnblogs.com/xiaobaiv/p/9116027.html
Copyright © 2011-2022 走看看