面试官:画一个同心圆叭。

424 阅读1分钟

注意点:
1.父子元素要使用"子绝父相"定位,
2.子元素水平垂直居中,
3.border-radius画圆角。

代码

     <style>
        .circleContainer {
            position: relative;
            width: 200px;
            height: 200px;
            background-color: green;
            margin: auto;
            border-radius: 50%;
        }

        .circleIn {
            position: absolute;
            width: 100px;
            height: 100px;
            background-color: blue;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: auto;
            border-radius: 50%;
        }
    </style>
    
    <div class="circleContainer">
        <div class="circleIn"></div>
    </div>

效果

image.png


记录记录!