Jump to content

Recommended Posts

When I add two colours to the circle, it no longer stays as a circle, it becomes much taller. attachment shows how the two coloured circle is no longer a circle (it's stretched), whereas the single colour circles are fine. Any ideas how to keep it circular?

Css for single colour is 

    color: #5fc75d;
    font-size: 1.2em;

Css for two coloured circle is

    color: transparent;
    background: linear-gradient(to right, #5fc75d 0%, #5fc75d 50%, #f19e2d 50%, #f19e2d 100%);
    border-radius: 50%;
    font-size: 1.2em;

circles.jpg.508caf70927c5b3f2cf8f2ff6683c738.jpg

Edited by alxne

You could roll your own.

function twoColorCircle($a, $b, $sz) {
    $out = "<svg width='$sz' height='$sz' viewBox='0 0 1000 1000'>
            <linearGradient id='grad2'  x1='0' y1='0' x2='1' y2='0'>
            <stop offset='0%' style='stop-color:$a'/>
            <stop offset='50%' style='stop-color:$a'/>
            <stop offset='50%' style='stop-color:$b'/>
            <stop offset='100%' style='stop-color:$b'/>
            </linearGradient>
           ";
    $c = 500;
    $r = 499;
    $out .= "<circle cx='$c' cy='$c' r='$r' fill='url(#grad2)' stroke='#000' />
             </svg>";
    return $out;
} 


foreach ([16,32,64,128,256] as $sz)
    echo twoColorCircle('#5fc75d' , '#f19e2d' , $sz);

echo '<br>';
    
foreach (['16em','8em','4em','2em','1em'] as $sz)
    echo twoColorCircle('#5fc75d' , '#f19e2d' , $sz);

image.png.a2555b02851125393326be0973faf0b6.png

  • Like 2

Or you could be really tricky with it:

<style>
.circle-2-colors{
  height: 0;
  width: 0;
  border-top: 15px solid red;
  border-right: 15px solid red;
  border-bottom: 15px solid blue;
  border-left: 15px solid blue;
  border-radius: 50%;
  transform: rotate(45deg);
}
</style>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.