jQuery 圆形导航是一种基于 jQuery 库实现的网页导航组件,通常用于创建一个圆形的菜单或按钮,点击后会展开多个选项或子菜单。这种导航方式不仅美观,还能节省页面空间,适用于各种网页设计。
以下是一个简单的 jQuery 圆形导航的示例代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>jQuery 圆形导航</title>
<style>
.circle-nav {
width: 100px;
height: 100px;
border-radius: 50%;
background-color: #f0f0f0;
position: relative;
cursor: pointer;
}
.circle-nav ul {
list-style: none;
padding: 0;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: none;
}
.circle-nav ul li {
width: 30px;
height: 30px;
border-radius: 50%;
background-color: #ccc;
text-align: center;
line-height: 30px;
margin: 5px;
}
</style>
</head>
<body>
<div class="circle-nav">
<ul>
<li>菜单1</li>
<li>菜单2</li>
<li>菜单3</li>
<li>菜单4</li>
</ul>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
$('.circle-nav').click(function() {
$(this).find('ul').toggle();
});
});
</script>
</body>
</html>
通过以上内容,你应该对 jQuery 圆形导航有了全面的了解,并能够解决一些常见问题。
领取专属 10元无门槛券
手把手带您无忧上云