【问题标题】:How do I create a menu which looks like this如何创建一个看起来像这样的菜单
【发布时间】:2017-01-20 15:46:39
【问题描述】:

Like This

我不想使用 PSD 图片。我更喜欢使用 FontAwesome 等包中的图标,并在 CSS 中生成背景/css。

【问题讨论】:

  • 我正在使用这个代码是给这个链接codepen.io/suez/pen/vAais我没有得到结果
  • 您应该考虑发布一个有人可以回答的实际问题。期望有人猜测你尝试了什么以及它是如何失败的不会给你一个解决方案
  • 我是 HTML 新手,为什么要问这样的问题,我无法在此处发布代码
  • 那么这不是编程问题。 “我该怎么做”或“我该怎么做”不是要修复的错误
  • 没有故障。没有编程问题,您是在要求某人对其他人所做的现有工作示例进行更改。这个网站不是为他们做其他人的工作stackoverflow.com/tour

标签: jquery html css


【解决方案1】:

您可以在此处查看现场演示 http://jsfiddle.net/XqqtN/6148/

<style>
                @import "http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css";

                body {
                  background: #39D;
                }

                .circular-menu {
                  width: 250px;
                  height: 250px;
                  margin: 0 auto;
                  position: relative;
                }

                .circle {
                  width: 250px;
                  height: 250px;
                  opacity: 0;

                  -webkit-transform: scale(0);
                  -moz-transform: scale(0);
                  transform: scale(0);

                  -webkit-transition: all 0.4s ease-out;
                  -moz-transition: all 0.4s ease-out;
                  transition: all 0.4s ease-out;
                }

                .open.circle {
                  opacity: 1;

                  -webkit-transform: scale(1);
                  -moz-transform: scale(1);
                  transform: scale(1);
                }

                .circle a {
                  text-decoration: none;
                  color: white;
                  display: block;
                  height: 40px;
                  width: 40px;
                  line-height: 40px;
                  margin-left: -20px;
                  margin-top: -20px;
                  position: absolute;
                  text-align: center;

                }

                .circle a:hover {
                  color: #eef;
                }

                .menu-button {
                  position: absolute;
                  top: calc(50% - 30px);
                  left: calc(50% - 30px);
                  text-decoration: none;
                  text-align: center;
                  color: #444;
                  border-radius: 50%;
                  display: block;
                  height: 40px;
                  width: 40px;
                  line-height: 40px;
                  padding: 10px;
                  background: #dde;
                }

                .menu-button:hover {
                  background-color: #eef;
                }

                /* Author stuff */
                h1.author {
                  text-align:center;
                  color: white;
                  font-family: Helvetica, Arial, sans-serif;
                  font-weight: 300;
                }

                h1.author a {
                  color: #348;
                  text-decoration:none;
                }

                h1.author a:hover {
                  color: #ddd;
                } 
                </style>

            <---HTML--->
            <nav class="circular-menu">

              <div class="circle">
                <a href="" class="fa fa-home fa-2x"></a>
                <a href="" class="fa fa-facebook fa-2x"></a>
                <a href="" class="fa fa-twitter fa-2x"></a>
                <a href="" class="fa fa-linkedin fa-2x"></a>
                <a href="" class="fa fa-github fa-2x"></a>
                <a href="" class="fa fa-rss fa-2x"></a>
                <a href="" class="fa fa-pinterest fa-2x"></a>
                <a href="" class="fa fa-asterisk fa-2x"></a>
              </div>

              <a href="" class="menu-button fa fa-bars fa-2x"></a>

            </nav>
            <---HTML--->


        <---js--->
        <script>
    var items = document.querySelectorAll('.circle a');

        for(var i = 0, l = items.length; i < l; i++) {
          items[i].style.left = (50 - 35*Math.cos(-0.5 * Math.PI - 2*(1/l)*i*Math.PI)).toFixed(4) + "%";

          items[i].style.top = (50 + 35*Math.sin(-0.5 * Math.PI - 2*(1/l)*i*Math.PI)).toFixed(4) + "%";
        }

        document.querySelector('.menu-button').onclick = function(e) {
           e.preventDefault(); document.querySelector('.circle').classList.toggle('open');
        }
    </script>
        <---js--->

【讨论】:

  • 令人印象深刻的代码!但我不敢相信你为这个问题写了整个 JS/HTML/CSS。用户至少应该自己先尝试一下,并在遇到困难时使用 SO。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-21
相关资源
最近更新 更多