2

I need some CSS help. It’s hard to explain, but looking at the snippet I need the black part without the red.

I used two elements, but it should be possible with one...

.q-rounder {
  background: #222;
  width: 15px;
  height: 15px;
}

.quarter-circle {
  width: 15px;
  height: 15px;
  background: red;
  border-radius: 100px 0 0 0;
  -moz-border-radius: 100px 0 0 0;
  -webkit-border-radius: 100px 0 0 0;
}
<div class="q-rounder">
  <div class="quarter-circle"></div>
</div>

(fiddle)

0

2 Answers 2

4

Use a radial gradient as background

.q-rounder {
  background: 
    radial-gradient(farthest-side at bottom right,transparent 94%, #222);
  width: 15px;
  height: 15px;
}
<div class="q-rounder">
</div>

Another syntax with the at to have better support (safari doesn't support the at)

.q-rounder {
  background: 
    radial-gradient(farthest-side,transparent 94%, #222) top left/200% 200%;
  width: 15px;
  height: 15px;
}
<div class="q-rounder">
</div>

Sign up to request clarification or add additional context in comments.

Comments

1

If you can use a solid background color, maybe this fits for you?

basicaly the before elements lays behind an rectangle which has border-radius an a solid background-color.

Supported in every browser and version.

.q-rounder {
  position: relative;
  background: white;
  width: 15px;
  height: 15px;
  border-radius: 100px 0 0 0;
}

.q-rounder:before {
  position: absolute;
  left: 0;
  top: 0;
  width: 15px;
  height: 15px;
  background: black;
  content: "";
  z-index: -1;
}
<div class="q-rounder">

</div>

4 Comments

it's almost the same as he already did, you simply changed the red with white. I think the idea is to have transparency
if transparency not needed, my approach has more browser support :D
more browser support than what? and if transparency is not need then the OP already have his code, no?
he asked for a solution with just one element

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.