CSS每日一题

时间:2019-01-23
本文章向大家介绍CSS每日一题,主要包括CSS每日一题使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

如何实现左边两栏一定比例,左栏高度随右栏高度自适应?

<div class="container">
    <div class="left">
        left
    </div>
    <div class="right">
        right
    </div>
</div>
第一种 利用margin和padding
<style>
            .container {
                overflow: hidden;
                width: 400px;
            }
            .container .left,
            .container .right {
                float: left;
                margin-bottom: -10000px;
                padding-bottom: 10000px;
            }
            .container .left {
                width: 20%;
                background: pink;
            }
            .container .right {
                width: 80%;
                background: deeppink;
            }
</style>
第二种利用flex,兼容性IE10下面不能使用,手机端也有些兼容
<style>
           .container {
                display: flex;
                width: 400px;
                overflow: hidden;
            }
             
            .container .left {
                width: 20%;
                background: pink;
            }
             
            .container .right {
                width: 80%;
                background: deeppink;
            }
</style>

css实现水平居中的几种方式
https://blog.csdn.net/dengdongxia/article/details/80297116