Home Web Front-end CSS Tutorial CSS3 implementation of fan-shaped animated menu examples

CSS3 implementation of fan-shaped animated menu examples

Feb 25, 2017 pm 02:31 PM

A previous article introduced the implementation of this effect, but the implementation code is too cumbersome, so I share the following simplified version of the implementation method. If necessary, you can refer to it.

Please click here for the original article

Simplified version complete example

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>CSS3扇形动画菜单</title>
		<style>
			*{padding: 0; margin: 0;}
			body{background:#b1b1b1;margin:0px;padding:0px;font-size:14px;color:#000;}
			.menuHolder {width:100px; height:100px; margin:0 0 250px 0; position:relative;z-index:100;}
			.menuHolder ul {padding:0px; margin:0; list-style:none; position:absolute; left:0; top:0; width:0; height:0;}
			/*.menuHolder ul li {border-radius:0 0 300px 0; width:0; height:0;}*/
			.menuHolder ul li a {color:#000; text-decoration:none; font:bold 13px/30px arial, sans-serif; text-align:center; 
									box-shadow:-5px 5px 5px rgba(0,0,0,0.4);transform-origin:0 0;}
			.menuHolder ul.p1 li {position:absolute; left:0; top:0;}
			.menuHolder ul.p2 {z-index:-1;}
			.menuHolder ul.p3 {z-index:-1;}
			/*画第一个圆圈*/
			.menuHolder li.s1 > a {position:absolute; display:block; width:100px; height:100px; background:#c8c8c8; border-radius:0 0 100px 0;}
			/*画第二个圆圈*/
			.menuHolder li.s2 > a {position:absolute; display:block; width:100px; padding-left:100px; height:200px; background:#ddd; border-radius:0 0 200px 0;}
			/*画第三个圆圈*/
			.menuHolder ul.p3 li a {position:absolute; display:block; width:100px; padding-left:200px; height:300px; background:#999; border-radius:0 0 300px 0;}
			/*把第二第三个圆隐藏到角落里去,让视角看不到*/
			.menuHolder ul ul {transform-origin:0 0;transform:rotate(90deg);transition:1s;}
			/*绘制第二层的菜单*/
			.menuHolder li.s2:nth-of-type(6) > a {background:#888;
			transform:rotate(75deg);
			}
			.menuHolder li.s2:nth-of-type(5) > a {background:#999;
			transform:rotate(60deg);
			}
			.menuHolder li.s2:nth-of-type(4) > a {background:#aaa;
			transform:rotate(45deg);
			}
			.menuHolder li.s2:nth-of-type(3) > a {background:#bbb;
			transform:rotate(30deg);
			}
			.menuHolder li.s2:nth-of-type(2) > a {background:#ccc;
			transform:rotate(15deg);
			}
			/*绘制联系的子菜单*/
			.menuHolder .a6 li:nth-of-type(6) > a {background:#444;
			transform:rotate(75deg);
			}
			.menuHolder .a6 li:nth-of-type(5) > a {background:#555;
			transform:rotate(60deg);
			}
			.menuHolder .a6 li:nth-of-type(4) > a {background:#666;
			transform:rotate(45deg);
			}
			.menuHolder .a6 li:nth-of-type(3) > a {background:#777;
			transform:rotate(30deg);
			}
			.menuHolder .a6 li:nth-of-type(2) > a {background:#888;
			transform:rotate(15deg);
			}
			/*绘制销量的子菜单*/
			.menuHolder .a5 li:nth-of-type(5) > a {background:#555;
			transform:rotate(72deg);
			}
			.menuHolder .a5 li:nth-of-type(4) > a {background:#666;
			transform:rotate(54deg);
			}
			.menuHolder .a5 li:nth-of-type(3) > a {background:#777;
			transform:rotate(36deg);
			}
			.menuHolder .a5 li:nth-of-type(2) > a {background:#888;
			transform:rotate(18deg);
			}
			/*绘制服务、商店、联系我们的子菜单*/
			.menuHolder .a3 li:nth-of-type(3) > a {background:#777;
			transform:rotate(60deg);
			}
			.menuHolder .a3 li:nth-of-type(2) > a {background:#888;
			transform:rotate(30deg);
			}
			/*鼠标滑过第一层菜单展开第二层菜单*/
			.menuHolder li.s1:hover ul.p2 {
			transform:rotate(0deg);
			}
			/*鼠标滑过第二层菜单展开第三层菜单*/
			.menuHolder li.s2:hover ul.p3 {
			transform:rotate(0deg);
			}
			/*鼠标滑过改变背景颜色和文字颜色*/
			.menuHolder ul li:hover > a {background:#f00; color:#fff;}
			.menuHolder li.s2:hover > a {background:#d00; color:#fff;}
			.menuHolder .a6 li:hover > a {background:#b00; color:#fff;}
			.menuHolder .a5 li:hover > a {background:#b00; color:#fff;}
			.menuHolder .a3 li:hover > a {background:#b00; color:#fff;}
		</style>
	</head>
	<body>
		<p class="menuHolder">
			<p class="menuWindow">
				<ul class="p1">
					<li class="s1"><a href="#url">导航菜单</a>
						<ul class="p2">
							<li class="s2"><a href="#"><span>首页</span></a></li>
							<li class="s2"><a href="#url"><span>服务</span></a>
								<ul class="p3 a3">
									<li><a href="#">打印</a></li>
									<li><a href="#">编辑</a></li>
									<li><a href="#">保管</a></li>
								</ul>
							</li>
							<li class="s2"><a href="#url"><span>联系</span></a>
								<ul class="p3 a6">
									<li><a href="#">支持</a></li>
									<li><a href="#">销售</a></li>
									<li><a href="#">购买</a></li>
									<li><a href="#">摄影师</a></li>
									<li><a href="#">零售商</a></li>
									<li><a href="#">常规</a></li>
								</ul>
							</li>
							<li class="s2"><a href="#url"><span>商店</span></a>
								<ul class="p3 a3">
									<li><a href="#">南区</a></li>
									<li><a href="#">北区</a></li>
									<li><a href="#">中心区</a></li>
								</ul>
							</li>
							<li class="s2"><a href="#url"><span>联系我们</span></a>
								<ul class="p3 a3">
									<li><a href="#">邮箱</a></li>
									<li><a href="#">邮递</a></li>
									<li><a href="#">电话</a></li>
								</ul>
							</li>
							<li class="s2 b6"><a href="#url"><span>销量</span></a>
								<ul class="p3 a5">
									<li><a href="#">数码单反机身</a></li>
									<li><a href="#">镜头</a></li>
									<li><a href="#">闪光枪</a></li>
									<li><a href="#">三角架</a></li>
									<li><a href="#">过滤器</a></li>
								</ul>
							</li>
						</ul>
					</li>
				</ul>
			</p>
		</p>
	</body>
</html>
Copy after login

Effect The picture is as follows:

CSS3 implementation of fan-shaped animated menu examples

CSS3 implementation of fan-shaped animated menu examples

Summary

The above is the entire content of this article, I hope it will be helpful to everyone in learning or using CSS3. If you have any questions, you can leave a message to communicate.

For more articles related to CSS3 implementation of fan-shaped animated menu examples, please pay attention to the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Vue 3 Vue 3 Apr 02, 2025 pm 06:32 PM

It&#039;s out! Congrats to the Vue team for getting it done, I know it was a massive effort and a long time coming. All new docs, as well.

Can you get valid CSS property values from the browser? Can you get valid CSS property values from the browser? Apr 02, 2025 pm 06:17 PM

I had someone write in with this very legit question. Lea just blogged about how you can get valid CSS properties themselves from the browser. That&#039;s like this.

A bit on ci/cd A bit on ci/cd Apr 02, 2025 pm 06:21 PM

I&#039;d say "website" fits better than "mobile app" but I like this framing from Max Lynch:

Stacked Cards with Sticky Positioning and a Dash of Sass Stacked Cards with Sticky Positioning and a Dash of Sass Apr 03, 2025 am 10:30 AM

The other day, I spotted this particularly lovely bit from Corey Ginnivan’s website where a collection of cards stack on top of one another as you scroll.

Using Markdown and Localization in the WordPress Block Editor Using Markdown and Localization in the WordPress Block Editor Apr 02, 2025 am 04:27 AM

If we need to show documentation to the user directly in the WordPress editor, what is the best way to do it?

Comparing Browsers for Responsive Design Comparing Browsers for Responsive Design Apr 02, 2025 pm 06:25 PM

There are a number of these desktop apps where the goal is showing your site at different dimensions all at the same time. So you can, for example, be writing

How to Use CSS Grid for Sticky Headers and Footers How to Use CSS Grid for Sticky Headers and Footers Apr 02, 2025 pm 06:29 PM

CSS Grid is a collection of properties designed to make layout easier than it’s ever been. Like anything, there&#039;s a bit of a learning curve, but Grid is

Google Fonts   Variable Fonts Google Fonts Variable Fonts Apr 09, 2025 am 10:42 AM

I see Google Fonts rolled out a new design (Tweet). Compared to the last big redesign, this feels much more iterative. I can barely tell the difference

See all articles