How to create div with curve in css and html5?

后端 未结 3 1831
悲哀的现实
悲哀的现实 2021-01-27 17:23

I am newbie in css world and I am trying to make responsive design like this using bootstrap,css and html5.

but ended up like this.

how to create same

相关标签:
3条回答
  • 2021-01-27 17:38

    To get curved edges use border-radius, the background can be achieved with linear-gradient

    jsfiddle: https://jsfiddle.net/ojhcbepz/

    html, body {
      height: 100%;
    }
    div.outer {
      width: 600px;
      height: 250px;
      background: linear-gradient(to bottom,blue 50%,red 0px);
      padding: 20px 0;
      overflow: hidden;
    }
    div.inner {
      height: 100%;
      border-radius: 50%;
      background: white;
      margin: 0 -50px;
    }
    <div class="outer">
      <div class="inner">
      </div>
    </div>

    0 讨论(0)
  • 2021-01-27 17:49

    well a simple solution maybe... use a small red dot image and repeat it in outer div and inner div has border-radius: 50%

    <div style="background-image: red url("http://i.imgur.com/dXis68u.png") repeat;"> 
    
        <div style="background-color: white; border-radius: 50%; text-align:center;" >
             ABCDEFGH
        </div>
    </div>
    

    (You can add two

    's of height as you want to get those top and bottom borders)

    0 讨论(0)
  • 2021-01-27 17:54

    You should use percentage to define the border-radius, in this way the curve will look like the one you want.

    border-radius: 100%
    

    http://codepen.io/FezVrasta/pen/XKvkJX?editors=1100

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