css实现 顶部弧形, 椭圆,平行四边形,菱形,任意多边形

  • 顶部弧形
----html----
 <div class="box"> 
     <div class="a"></div>
 </div>
----css-----
 .box{
        width: 200px;
        height: 400px;
        border:1px solid #333;
        overflow: hidden;
        position: relative;
    }
    .a{
        width: 800px;
        height: 800px;
        border-radius: 50%;
        background: pink;
        position: absolute ;
        top:-685px;
        left: -300px;
        z-index: -1;
    }

在这里插入图片描述

  • 椭圆
----html----
 <div class="box"> </div>
 ----css----
 .box{
        width: 200px;
        height: 100px;
        border-radius: 200px/100px;   //下面的可以随意变形,此例用本行
        background: pink;
        
        border-radius:10px 20px 30px 40px / 50px 60px 70px 80px;
         /* 斜杠(/)前代表水平半径,后代表垂直半径,顺序分别为左上角开始,顺时针走向,所以这段代码表示左上角(10px/50px) 右上角(20px/60px)右下角(30px/70px)左下角(40px/80px) */
    }

在这里插入图片描述

  • 平行四边形
----html----
 <div class="box"> 
        我是平行四边形
  </div>
----css----
 .box{
        position: relative;
        margin:20px auto;
        max-width: 100px;
        height: 50px;
        line-height: 50px;
        text-align: center;
        font-size: 12px;
    }
    .box::before{		
    //虽然也可以使用demo把文字恢复回来,但是增加了tagName,用伪元素更好
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: pink;
        transform: skew(-45deg);
        z-index: -1;
    }

在这里插入图片描述

  • 菱形
----html----
  <div class="box">  </div>
----css----
.box{
  	background: grey;
        width: 100px;
        height: 50px;
        clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
      //此属性事从svg借鉴来的,可以实现任意多边形,polygon()函数是各个坐标
    }
  • 2
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值