【问题标题】:How to make curve style menu in css3?如何在css3中制作曲线样式菜单?
【发布时间】:2013-03-10 23:36:26
【问题描述】:

是否可以用 css3 制作曲线/弧形菜单?

我可以在 HTML5 中实现这个使用画布或其他东西吗?

提前致谢,洛根

【问题讨论】:

标签: html css canvas


【解决方案1】:

不幸的是,我不知道任何优雅的解决方案,尤其是在涉及菜单项时,但弧线本身应该可以在纯 css 和几个 html 元素中使用。

也许这可以让你开始。

html

<div class="container">
    <div class="gray"></div>
    <div class="white"></div>
</div>

css

.container {
    height: 200px;
    overflow: hidden;
    position: relative;
}
.gray,
.white {
    position: absolute;
    left: -25%;
    right: -25%;
    border-radius: 100%;
}
.gray { /* use a gray border with border radius to emulate an arc */
    top: -50%;
    border:100px solid gray;
    border-top: none;
    height: 200px;
}
.white { /* put a white oval on top for the top edge of the banner */
    top: -80%;
    background-color: white;
    height: 300px;
}

http://jsfiddle.net/rNLsr/

现在的挑战是定位所有菜单项和rotate them accordingly... 我真的不认为这是一个可行的解决方案,但我还是发帖希望你会发现它有用。

SVG 允许您使用curve text 并且可能是更适合此任务的工具。

编辑

这是我用 SVG 做的一个版本,它是一个概念验证,需要调整以使其看起来不错(由于某种原因,在 chrome 中呈现可怕而在 IE 中呈现微小),但它为您提供了基本概念:

svg

<svg viewBox="0 0 500 300" version="1.1">
    <defs>
        <!-- Start at (10,40) end at (490,40) use control point (250 ,85) -->
        <path id="curvetext" d="M 10,40 Q 250,85 490,40" />
    </defs>
    <use x="0" y="0" xlink:href="#curvetext" fill="none" stroke="gray" stroke-width="50"/>
    <text font-size="12" fill="white">
        <textPath xlink:href="#curvetext">
            <a xlink:href="http://example.com">Menu 1</a> Menu 2 Menu 3 Menu 4 Menu 5 Menu 6 Menu 7 Menu 8 Menu 9
        </textPath>
    </text>
</svg>

SVG 演示地址:http://jsfiddle.net/rNLsr/2/

【讨论】:

  • 太棒了!.. 你节省了我的时间。
  • @AlexL 谢谢你,现在看起来好多了:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-03-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多