0

I need to make that white thing over grey stripe. I got confused as I haven't made anything like that before. Which approach would you apply for creation of such thing?

enter image description here

JSFiddle

<div class="stripe"></div>

.stripe {
  background-color: #B7B7B7;
  height: 13vh;
}

Thank you in advance!

Paulie_D
  • 107,962
  • 13
  • 142
  • 161
Billy Logan
  • 2,470
  • 6
  • 27
  • 45

7 Answers7

3

I hope you'll find this answer to be both simple and pixel-perfect.

.stripe {
    background-color: #B7B7B7;
    height: 13vh;
}
.whiteThing {
    background-color: white;
    height: 13vh;
    width: 13vh;
    border-radius:0 50% 50% 0;
}
<div class="stripe">
    <div class="whiteThing"></div>
</div>
ericgilchrist
  • 262
  • 4
  • 10
2

You might want to use border-radius property.

HTML:

<div class="stripe">
<div class="circle">
</div>
</div>

CSS:

    .stripe {
  background-color: #B7B7B7;
  height: 13vh;
}

.circle{
  background:white;
  width:10%;
  height:100%;
  border-radius:00px 50px 50px 0px;
}

https://jsfiddle.net/4uk5eyuq/

rass
  • 97
  • 1
  • 1
  • 11
2

W3Schools on border-radius property

.stripe {
    background-color: #B7B7B7;
    height: 13vh;
}
.thatwhitethingovergreystripe {
    background-color: white;
    height: 13vh; /* or 100% */
    width: 80px; /* or 6.5vh for semicircle or 13vh for rectangle with r width and semicircle */
    border-top-right-radius: 6.5vh; /* this does the trick; make it any number you like or just make it full height of your div */
    border-bottom-right-radius: 6.5vh; /* and this */
}
<div class="stripe">
    <div class="thatwhitethingovergreystripe"></div>
</div>
Aki
  • 2,818
  • 1
  • 15
  • 23
  • While this is a great solution, the height and width are different value types, so it will not preserve aspect-ratio at varying viewport heights. Additionally, why not handle the border-radius with just a single line? border-radius: 0 50% 50% 0; See my answer below. – ericgilchrist Apr 21 '16 at 00:33
2
<div class="stripe"><span class="circle"></span></div>

.circle {
  border-radius:50%; //makes the square into circle regardless of size
  background: white;
  height:13vh;
  width:13vh;
  display:block;
  overflow:hidden;
 }
1

You can do it like this, see fiddle: https://jsfiddle.net/5wwg1q5j/3/

html

<div class="stripe">
<div class="rec">
</div>
<div class="circle">
</div>
</div>

css

body{margin: 0;}
.stripe {
  background-color: #B7B7B7;
  height: 100px;
}
.rec{
  width: 100px;
  height: 100px;
  background-color: white;
}
.circle {
    border-radius: 50%;
    width: 100px;
    height: 100px;
  background-color: white;
  position: absolute;
  left: 50px;
  top: 0;
    /* width and height can be anything, as long as they're equal */
}
Adam Buchanan Smith
  • 9,422
  • 5
  • 19
  • 39
1

I did by this way

.s2{
  background-color:white;
  float:left;
  width: 70px;
  height: 13vh;
  border-top-right-radius: 50%;
  border-bottom-right-radius: 50%;
}
.stripe {
  background-color: #B7B7B7;
  height: 13vh;
}
<div class="s2"></div><div class="stripe"></div>
1

a single tag + pseudo does too:

h1 {
  overflow:hidden;/* to hold shadow of pseudo */
  padding-left:1.5em; /* leave room for the shape */
  line-height:2em;
  }
h1:before { /* the shape */
  content:'';
  float:left;/* or inline-block or absolute position, works too in flex context*/
  height:2em;/* here height of tag if one line */
  width:2em;/* from a square you can draw a circle */
  margin-left:-2.5em;/* hide half of it or  any amount */
  border-radius:50%;/* draw that circle */
  box-shadow:0 0 500px 500px gray, 0 0  1000px 1000px yellow;;/* paint a hudge shadow to use as background for parent tag */
  }
  /* add borders ? */
h1 + h1 {
  border:solid;
  border-left:none;
  border-radius: 0 1em 1em  0;
  }
h1 + h1:before {
 box-shadow:0 0 0 3px,0 0 500px 500px gray, 0 0  1000px 1000px yellow;;/* paint a hudge shadow to use as background for parent tag */
  }

body {
  background:url(http://lorempixel.com/600/400/nature/2);
  }
<h1> reverse rounded </h1>
<h1> reverse rounded borders </h1>

some more examples and different shapes or use -http://codepen.io/gcyrillus/pen/yJfjl -http://codepen.io/gcyrillus/pen/Kpvuf -http://codepen.io/gcyrillus/pen/HEFtk -http://dabblet.com/gist/5690173 -http://dabblet.com/gist/5309926

G-Cyrillus
  • 101,410
  • 14
  • 105
  • 129