常用CSS代码(一)

1、一行文本居中,多行文本左对齐

实现思路:内容区域设置display:inline-block;text-align:left;父元素设置text-align:center

代码:

<div class="box">
    <div class="content">这是内容区域</div>
</div>

<!-- start:css -->
<style>
    .box{
        text-align: center;width: 100px;
    }
    .content{
        display: inline-block;text-align: left;
    }
</style>    
<!-- end:css -->    

2、实现三角形(使用透明色)

<div></div>


div {
    width: 0;
    height: 0;
    border: 30px solid;
    border-color: transparent transparent red;
}

3、垂直居中

  • 使用flex布局
  • 使用absolute

  

猜你喜欢

转载自www.cnblogs.com/zhaojingj/p/12924028.html
今日推荐