简体   繁体   English

如何使用HTML,CSS和JQuery在圆形设计中创建交互式导航

[英]How to create an interactive navigation, in a circular design, using HTML, CSS, and JQuery

 // JavaScript Document $('.page').hide(); $(".btns").click(function(e){ e.preventDefault(); //this method stops the default action of an element from happening. var $me = $(this); //$(this) references .btns, the object in local scope. var $myContent = $($me.attr('href')); //pulls href of page 01, 02, or 03. $('.page').hide(); //hides all pages $myContent.fadeIn();//fades in clicked href connected to btn $(".btns").removeClass('selected');// $me.addClass('selected'); }); 
 *{ border-spacing: 0px; } body{ margin: 0px; padding: 0px; } .circle-container { position: relative; width: 24em; height: 24em; padding: 2.8em; /*2.8em = 2em*1.4 (2em = half the width of a link with img, 1.4 = sqrt(2))*/ border: dashed 1px; border-radius: 50%; margin: 1.75em auto 0; } .circle-container a { display: block; position: absolute; top: 50%; left: 50%; width: 4em; height: 4em; margin: -2em; } .circle-container img { display: block; width: 100%; } .deg0 { transform: translate(12em); } 
  <div class="body_content"> <div class="page" id="page_01"> <h2>1. Category 1</h2> </div> </div> <div class="circle-container"> <nav class="navigation"> <a href="#page_01" class="btns deg0" > <img id="one" src="imgs/button.png" alt="page01"/> </a> </nav> </div> 

I have a unique situation that I would like to discuss with you all. 我有一个独特的情况,想与大家讨论。 I am trying to create a web page that has a circular navigation, as shown here enter image description here 我正在尝试创建一个具有圆形导航的网页,如下图所示在此处输入图片描述

Each one of these buttons would display content when clicked, like an in-page link. 单击这些按钮中的每个按钮都会显示内容,例如页面内链接。 The JQuery is as shown enter image description here jQuery如图所示, 在此处输入图像描述

The concept seems simple enough, force all content to hide, when a user clicks a button, the page content linked to that button shows. 该概念似乎很简单,可以强制隐藏所有内容,当用户单击按钮时,将显示链接到该按钮的页面内容。 It works when the links are inline or block display, but when in a circle, the links don't work, the button content doesn't show. 当链接以内联或块显示时,它起作用,但是当圆圈时,链接不起作用,则按钮内容不显示。 Has anyone worked with a similar issue? 有没有人处理过类似的问题? Or would anyone have a potential solution? 还是会有人有潜在的解决方案? I apologize for the vagueness of the questions but the issue seems multi-faceted. 对于问题的模糊性,我深表歉意,但问题似乎是多方面的。 Any advice or ideas would be greatly appreciated. 任何建议或想法将不胜感激。

Are you sure your jQuery reference is working? 您确定您的jQuery参考有效吗? I don't see any issue with the code, the click event should fire when you click on the links. 我看不到代码有任何问题,单击链接时应触发click事件。 Check the console for any errors, I strongly believe jQuery might not get loaded. 检查控制台是否有任何错误,我坚信jQuery可能不会加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM