zoukankan      html  css  js  c++  java
  • CSS代码片段

    居中问题

    复制代码
    定位:
        将元素居中
        将元素水平居中
        将元素垂直居中
    样式:
        文字毛玻璃效果
        
        
        
        
        
        
    -------------------------------------------代码------------------------------------------------------
        
    将元素居中:
        1.使用绝对定位实现1
        {
             50px;
            height: 50px;    /*设置元素宽高*/
            position: absolute;    /*修改为绝对定位*/
            top: 50%;
            left: 50%;        /*设置与上、左的距离*/
            margin-top: -25px;
            margin-left: -25px;    /*外边距分别为宽高的一半*/
        }
        2.使用绝对定位实现2
        {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: tranplate(-50%, -50%);
        }
        3.使用父元素文本流水平居中,单元格显示垂直居中
        #parent{
            text-align: center;    /*设置子元素水平居中*/
            display: table-cell;    /*设置为表格单元格显示*/
            vertical-align: middle;    /*设置垂直对齐方式为居中*/
        }
        #child{
            display: inline-block;
        }
        
    将元素水平居中
        1.使用外边距自动实现(相对父元素居中)
        {
            margin: 0 auto;
        }
        2.将父元素文本流水平居中,配合子元素变成行内快(child里的文字也会水平居中,可以在.child添加text-align:left;还原)
        #parent{
            text-align: center;
        }
        #child{
            display: inline-block;
        }
        
    将元素垂直居中
        1.将父元素设置为表格单元格显示,使内容垂直居中(子元素垂直居中)
        #parent{
            display: table-cell;    /*设置为表格单元格显示*/
            vertical-align:middle;    /*设置垂直对齐方式为居中*/
        }
        
    文字毛玻璃效果
        1.将文字设置成黑色透明,然后加上投影
        {        
          color:rgba(0,0,0,0);
          text-shadow: 0 0 10px black;
        }
    复制代码
  • 相关阅读:
    Reflector 插件
    Tips for ILMerge
    WaitAll for multiple handles on a STA thread is not supported 解决方案
    MSI: UAC return 0x800704C7
    SET与SETX的区别
    年在Copyright中的含义
    gacutil : 添加.NET 4.0 assembly 到GAC失败
    LicenseContext.GetSavedLicenseKey 需要 FileIOPermission
    Linq学习之linq基础知识
    SQL Server 2008如何导出带数据的脚本文件
  • 原文地址:https://www.cnblogs.com/onesea/p/13112266.html
Copyright © 2011-2022 走看看