Support » Everything else WordPress » Gradient color circle – Ideas and thoughts for css learning tool

  • Hey all

    I am building a learning tool for color psychology and theory in art, that sort of will work as a filter to (links):

    • Color Harmonies – as Woo Attributes
    • Dominant color in a given artwork

    I have built my gradient color circle like so:

    .fancy-color-circle {
    	  position: relative;
          text-align: center;
          padding: 2em;
          border: none;
    	  background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
          color: #00838f;
          width: 14rem;
          height: 14rem;
          font-size: 2em;
          border-radius: 100%;
          display: flex;
          margin: 2rem auto auto auto;
        }

    I understand this is fairly new code for browsers, but looks cool on my screens. You can see it on page link, scroling down to curations section.

    Now the idea is to create overlay pizza slices that:

    • overlay the circle. fx red slice, that on mouse over reveal the meaning of red as described on red card, and so on for all colours (The half red heart should become a slice and fit over red. It already link to test page, but will link to artwork in dominant color red)
    • Also I am considering to throw in similar function for color harmonies, such as Analogous, Triadic, Achromatic etc.

    Now jumping into red pizza slice I have:

    #pizza-slice-red {
          position: relative;
          width: 100px;
          height: 90px;
    }
    
    #pizza-slice-red:before {
          position: absolute;
          content: "";
          left: 7rem;
          top: 1rem;
          width: 50px;
          height: 80px;
          background: red;
          border-radius: 50px 50px 0 0;
          transform: rotate(-45deg);
          transform-origin: 0 100%;
    }
    		
    #pizza-slice-red:after {
          left: 0;
          transform: rotate(45deg);
          transform-origin: 100% 100%;
    }

    I am stuck with

    1) shaping the red thing into a pizza slice, that match the size of my color circle and also position the slice exactly ontop of the red part of circle….

    2) Getting the remaining colors active as red in #1

    3) Mouse over display the meaning of red etc. This could happen in the center of the color wheel on fx. a fade in black gradient circle and white txt on top. However, I also consider the color harmonies to display here with graphic figures that point to the color combinations in their respective harmonies.

    Thx

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    Hi hebhansen,

    I’ve no idea on how to get a HTML container to be shaped like a pizza slice. I’m not a complete CSS expert, I’m not sure it’s even possible. I would suggest you instead define a SVG image shaped as you want. If you cannot find a suitable existing SVG for this, it’s not horribly difficult to create your own. It can be done manually, or you could use a basic SVG editor such as Boxy.

    Like other HTML elements, a SVG image can be colored, positioned, and transformed with CSS. If you absolute position elements within a relative positioned overall container, their relationship will always remain the same so positioning should remain accurate regardless of different viewport sizes.

    Similarly, if you want the “pizza” to appear to have a slice missing, I’m not sure it’s possible with CSS. I again suggest a SVG approach. Position a slice image that matches the white background over the gradient circle pizza. Even though it’s an extra thing over the circle, it’ll appear like a slice was taken out due to its background coloring.

    Thread Starter hebhansen

    (@hebhansen)

    SVG never works for me. I can’t color fill them, it’s just a mess and I prefer going the css route.

    So center align everything within it’s container. How do I do that. This is what I have at time of writing, and I want the circle to center right left anda also up and down….

    html structure where the color circles with txt are not yet part of the game:

    <div id="color-circle-container">
      <div class="fancy-color-circle"></div>
      <div id="pizza-slice-red" class="hold"><div class="pie"></div></div>
    </div> 

    and css for container and gradient circle

    .color-circle-container {
    height: 16rem;
    border: 1px red solid;
    }
    
    .fancy-color-circle {
    position: absolute;
    text-align: center;
    padding: 2em;
    border: none;
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red);
    color: #00838f;
    width: 14rem;
    height: 14rem;
    font-size: 2em;
    border-radius: 100%;
    display: flex;
    margin: auto auto auto auto;
    -moz-border-radius: 100%;
    -webkit-border-radius: 100%;
    -o-border-radius: 100%;
    -moz-box-shadow: -1px 1px 3px #000;
    -webkit-box-shadow: -1px 1px 3px #000;
    -o-box-shadow: -1px 1px 3px #000;
    box-shadow: -1px 1px 3px #000;
    }

    Note: red border around container does not show…. Why is that? What is the best container size definition for responsive? em, rem or %. I guess I somehow need a fixed value to define something for it not to collapse entirely?

    • This reply was modified 1 day, 2 hours ago by hebhansen.
    Thread Starter hebhansen

    (@hebhansen)

    Red pizza slice is misleadingly blue here 🙂 It will go transparent, once overlaying red section, so no worries.

    css goes like so, but somehow the slice does not align to center and it does not keep it’s slice shape as it should. I have changed radius 50px from the original source code to redius 100% in my example. Is that an issue? I just want it to fill up the 14rem I define.

    .pie {
      position: absolute;
      width: 14rem;
      height: 14rem;
      -moz-border-radius: 100%;
      -webkit-border-radius: 100%;
      -o-border-radius: 100%;
      border-radius: 100%;
      clip: rect(0px, 50px, 100px, 0px);
    }
    .hold {
      position: absolute;
      width: 14rem;
      height: 14rem;
      -moz-border-radius: 100%;
      -webkit-border-radius: 100%;
      -o-border-radius: 100%;
      border-radius: 100%;
      clip: rect(0px, 100px, 100px, 50px);
    }
    #pizza-slice-red .pie {
    	border: 1px red solid;
    	background-color: #1b458b;
    	-webkit-transform:rotate(50deg);
    	-moz-transform:rotate(50deg);
    	-o-transform:rotate(50deg);
    	transform:rotate(50deg);
    }

    The small circles with txt are cover blocks. Is there any chance in life I could simply css these blocks into slices? I can add classes to them, I know, but how would I add a div to a cover block?

    Thread Starter hebhansen

    (@hebhansen)

    html structure – link

    How can I make this structure a link to somewhere? The link is the pizza-slice-red

    <div id="pizza-slice-red" class="hold">
       <div class="pie">
       </div>
    </div>

    Moderator bcworkz

    (@bcworkz)

    I had a nice in-depth reply all ready to post but it got lost because my auth cookie expired while I was typing. Grrrrr! I’m too frustrated right now to attempt to redo it but I will point out that “color-circle-container” (for red border) is an ID attribute, so the selector should be #color-circle-container.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.