Home > Web Front-end > CSS Tutorial > How Do I Create a Circular Menu with Icons Using Pure CSS?

How Do I Create a Circular Menu with Icons Using Pure CSS?

Barbara Streisand
Release: 2024-11-10 17:54:02
Original
1008 people have browsed it

How Do I Create a Circular Menu with Icons Using Pure CSS?

How to Create a Radial Menu in CSS

Overview

This article will provide a step-by-step guide on creating a circular menu with icons using pure CSS. The goal is to avoid using images or JavaScript for improved performance and accessibility.

HTML Structure

The HTML structure for the radial menu is relatively simple. It consists of an input checkbox to toggle the visibility of the menu, a label for the checkbox, and an unordered list containing the menu items as list elements:

<input type='checkbox'>
Copy after login

CSS Styles

The CSS styles are crucial for positioning, styling, and animating the menu. The most important properties and their values are:

  • Transform: Used to rotate, scale, and skew elements to create the radial layout.
  • Transition: Sets the duration and timing function for the smooth appearance and disappearance of the menu.
  • Border-radius: Creates the rounded corners for the menu items.
  • Box-shadow: Adds depth and dimension to the menu elements.
  • Position: Ensures the menu is centered on the screen.

Code Snippet

input {
  transform: translate(-100vw);
  visibility: hidden;
}

input:checked ~ ul {
  transform: scale(1);
  opacity: 0.999;
  transition: 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

label, ul, li {
  position: absolute;
  left: 50%;
  bottom: 50%;
}

label {
  transform: translate(-50%, -50%);
  margin: -1em;
  width: 2em;
  height: 2em;
  border-radius: 50%;
  box-shadow: 0 0 1px 1px white, 0 0.125em 0.25em #876366,  0 0.125em 0.5em #876366;
  background: #d3d3d3;
  background: radial-gradient(#d4c7c5, #e5e1dd);
  cursor: pointer;
}

ul {
  transform: translate(-50%, -50%) scale(0.001);
  transform-origin: 50% 0%;
  will-change: transform;
  opacity: 0.001;
  transition: 0.5s cubic-bezier(0.6, -0.28, 0.735, 0.045);
}

li {
  overflow: hidden;
  width: 16em;
  height: 16em;
  transform-origin: 0 100%;
}

a {
  display: block;
  transform: rotate(7.5deg)  scaleX(3.8637) skewY(75deg);
  line-height: 3em;
  text-align: center;
  text-decoration: none;
}
Copy after login

Conclusion

This CSS-based radial menu offers a visually appealing and user-friendly way to organize and access options. By carefully crafting the CSS, the menu can be tailored to match the overall design and functionality of the website or application.

The above is the detailed content of How Do I Create a Circular Menu with Icons Using Pure CSS?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template