Negative Border Radius in CSS?

前端 未结 3 1669

I\'m trying to do CSS to make a div that looks like this:

I\'m pretty much started with this:

.player {
    width: 480px;
    height: 80px;
    bord         


        
相关标签:
3条回答
  • 2020-12-09 13:42

    Here's yet another way of doing it, this time using a radial background image. This lets it be transparent and works in both Firefox and Chrome.

    .player {
      width: 480px;
      height: 80px;
      border-radius: 40px;
      background-image: radial-gradient(circle at 38px 40px, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 40px, blue 40px);
      color: #FFF;
    }
    <div class="player"></div>

    0 讨论(0)
  • 2020-12-09 13:49

    .wrapper {
        width: 500px;
        height: 103px;
        background-color: red;
        padding-top: 15px;
    }
    
    .player {
        width: 480px;
        height: 83px;
        margin-left: 10px;
        border-top-right-radius: 40px;
        border-bottom-right-radius: 40px;
        border: 1px solid black;
        border-left: none;
        background-color: blue;
        -webkit-mask-image: radial-gradient(circle at left, transparent 0, transparent 40px, black 41px);
    }
    <div class="wrapper"><div class="player"></div></div>

    0 讨论(0)
  • 2020-12-09 13:56

    You can use the before pseudo element to provide the "cut out"

    .player {
        width: 480px;
        height: 80px;
        border-radius:0 40px 40px 0;
        background-color:#0000FF;
        position:relative;    
        color:#FFF;
    }
    
    .player:before
    {
        width: 80px;
        height: 80px;
        border-radius:0 40px 40px 0;
        background-color:#FFF;    
        display:inline-block;
        vertical-align: middle;
        margin-right: 10px;
        content: '';
    }
    <div class="player">Some Content</div>

    0 讨论(0)
提交回复
热议问题