CSS进阶之content制作爱心

<style>
  .heart {
    position: absolute;
    margin: auto;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    pink;
    height: 50px;
    width: 50px;
    /*使用rotate函数 设置角度为 -45度 */
    transform: rotate(-45deg);
  }
  .heart::after {
    /* 属性值为空字符串 */
    content: '';
    /* 颜色为粉色 */
    background-color: pink;
    /* 设置圆角边框为50度 */
    border-radius: 50%;
    position: absolute;
    /* 设置定位 */
    width: 50px;
    height: 50px;
    top: 0px;
    left: 25px;
  }
  .heart::before {
    content: '';
    background-color: pink;
    border-radius: 50%;
    position: absolute;
    width: 50px;
    height: 50px;
    top: -25px;
    left: 0px;
  }
</style>
<div class="heart"></div>
 

 

演示:

 

posted @ 2021-08-05 08:33  丸筱  阅读(120)  评论(0)    收藏  举报