HTML Academy
Round menu, step 3
2D Transforms31/32
Back to the list of tasks
  • 1. Moving objects horizontally
  • 2. Moving objects vertically
  • 3. Fireball training
  • 4. Increasing and decreasing the size
  • 5. Defending the city
  • 6. The beginning of the journey
  • 7. The maze
  • 8. The battle, part 1
  • 9. The battle, part 2
  • 10. Test: The mysterious card
  • 11. The battle, part 3
  • 12. Test: The shattered crystal
  • 13. The final battle
  • 14. Features of transform-origin, part 1
  • 15. Features of transform-origin, part 2
  • 16. Features of transform-origin, part 3
  • 17. Features of transform-origin, part 4
  • 18. Centering with transform: translate
  • 19. Rotating the text in blocks
  • 20. Rotating the text in the background
  • 21. Custom shadows
  • 22. On-hover effects: buttons, part 1
  • 23. On-hover effects: buttons, part 2
  • 24. On-hover effects: buttons, part 3
  • 25. On-hover effects: the gallery
  • 26. The “stack” of cards
  • 27. Preparing the round menu
  • 28. Round menu, step 1
  • 29. Round menu, step 2
  • 30. Round menu, step 3
  • 31. The round menu, final part
  • 32. Test: Arranging the cards
Test: Arranging the cards
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

The round menu, final part

That’s all there is to creating a round menu:

  1. Convert the axis of item rotation into an angle using transform-origin, and align this angle with the center of the menu.
  2. Skew and rotate the menu items using the following formulas:

    [sector angle] = 360° / [number of menu items]
    [rotation of item n] = (n - 1) * [sector angle]
    [skew angle] = 90° - [sector angle]
  3. Let’s “unskew” and expand the contents of the menu items:

    [skew angle of contents] = -1 * [skew angle of item]
    [rotation angle] = -1 * (90° – ([sector angle] / 2))
  4. Shift the contents of the items to the center of the circle.
  5. Round out the menu container using border-radius, and trim away anything unnecessary using overflow: hidden.

And after you have completed these steps, you can apply additional decorative elements. For example, set different backgrounds for items, a frame for the menu container, and so on.

Let’s add a third menu item last, so that we get a semicircle. The angle of rotation of the third menu item will be 120°:

A series of tasks inspired by the article Building a Circular Navigation with CSS Transforms. These examples have been adapted and simplified for the course.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <title>The round menu, final part</title> <meta charset="utf-8"> <link rel="stylesheet" href="style.css"> </head> <body> <nav class="circle-menu"> <div class="center"></div> <ul> <li><a href="#">monitor</a></li> <li><a href="#">aperture</a></li> </ul> </nav> </body> </html>
CSS
body { margin: 0; padding: 0; background-color: #f5f5f5; } .circle-menu { position: relative; width: 400px; height: 400px; margin: 50px auto; background-color: white; box-shadow: 0 0 3px #cccccc; } .circle-menu ul { position: absolute; width: 300px; height: 300px; margin: 50px; padding: 0; list-style: none; border-radius: 50%; overflow: hidden; } .circle-menu .center { position: absolute; top: 195px; left: 195px; z-index: 1000; border: 5px solid #34495e; border-radius: 50%; box-shadow: 0 0 3px #cccccc; } .circle-menu li { position: absolute; top: -10px; left: -10px; width: 160px; height: 160px; transform-origin: 100% 100%; overflow: hidden; } .circle-menu li:nth-child(1) { transform: rotate(0deg) skew(30deg); } .circle-menu li:nth-child(2) { transform: rotate(60deg) skew(30deg); } .circle-menu li a { display: block; width: 160px; height: 160px; margin-top: 40px; margin-left: 40px; font-size: 0; background: rgba(241, 196, 15, 0.5) url("icons/monitor-4x.png") no-repeat 50% 40%; transition: background-color 0.5s; transform: skew(-30deg) rotate(-60deg); } .circle-menu li:nth-child(even) a { background-color: rgba(241, 196, 15, 0.75); } .circle-menu li a:hover { background-color: rgba(241, 196, 15, 1); } /* Icons */ .circle-menu li:nth-child(2) a { background-image: url("icons/aperture-4x.png"); } .circle-menu li:nth-child(3) a { background-image: url("icons/audio-4x.png"); } .circle-menu li:nth-child(4) a { background-image: url("icons/battery-empty-4x.png"); } .circle-menu li:nth-child(5) a { background-image: url("icons/bluetooth-4x.png"); } .circle-menu li:nth-child(6) a { background-image: url("icons/browser-4x.png"); }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Add a third list item to the menu with a link inside.
    2. Rotate the third list item 120°.
    3. And then skew it 30°.
    1. Complete the menu so that it has six items.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.