如何在边框侧创建带有链接的圆圈

时间:2015-01-14 12:32:54

标签: html css css3 svg css-shapes

我想创建一个像this这样的圈子。我能够在小提琴中做到这一点,但问题是我需要每个橙色的一面都是一个链接,我不能用边框做。如果有人能帮助我,我将非常感激。



#circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: green;
}
#incircle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 50px dotted orange;
}

<div id="circle">
  <div id="incircle"></div>
</div>
&#13;
&#13;
&#13;

8 个答案:

答案 0 :(得分:19)

您可以使用svg的{​​{1}}来创建链接的部分和arc的锚点(相当于HTML锚标记)标记。

enter image description here

&#13;
&#13;
svg
&#13;
.frag {
  fill: #FFA500;
  stroke: #FFFFFF;
  transition: fill 0.3s ;
}
.center {
  fill: #008000;
}
a:hover .frag {
  fill: #FFC722;
}
text {
  font-size: 17px;
  fill: #FFFFFF;
}
&#13;
&#13;
&#13;


您还可以拉伸或调整<svg width="200" height="200" viewBox="-2 -2 202 203" shape-rendering="geometricPrecision"> <a xlink:href="#"><path class="frag" d="M100,100 v-100 a100,100 1 0,1 86.6025,50" /><text x="135" y="42.5" text-anchor="middle">1</text></a> <a xlink:href="#"><path class="frag" d="M100,100 l86.6025,-50 a100,100 1 0,1 0,100" /><text x="170" y="105" text-anchor="middle">2</text></a> <a xlink:href="#"><path class="frag" d="M100,100 l86.6025,50 a100,100 1 0,1 -86.6025,50" /><text x="135" y="170" text-anchor="middle">3</text></a> <a xlink:href="#"><path class="frag" d="M100,100 v100 a100,100 1 0,1 -86.6025,-50" /><text x="65" y="170" text-anchor="middle">4</text></a> <a xlink:href="#"><path class="frag" d="M100,100 l-86.6025,50 a100,100 1 0,1 0,-100" /><text x="27.5" y="105" text-anchor="middle">5</text></a> <a xlink:href="#"><path class="frag" d="M100,100 l-86.6025,-50 a100,100 1 0,1 86.0025,-50" /><text x="65" y="42.5" text-anchor="middle">6</text></a> <a xlink:href="#"><path class="center" d="M100,100 v-50 a50,50 1 0,1 0,100 a50,50 1 0,1 0,-100" /></a> </svg>

enter image description here

&#13;
&#13;
svg
&#13;
.frag {
  fill: #FFA500;
  stroke: #FFFFFF;
  transition: fill 0.3s ;
}
.center {
  fill: #008000;
}
a:hover .frag {
  fill: #FFC722;
}
text {
  font-size: 17px;
  fill: #FFFFFF;
}
&#13;
&#13;
&#13;

答案 1 :(得分:16)

创建带有线段的圆的关键是沿圆圈找到将在SVG path元素中用作坐标的点。如果我们知道角度,就可以使用三角方程式轻松找到圆上的点。

  

X点的坐标=圆的半径* Cos(弧度的角度)+ X中心点的坐标

     

Y坐标点=圆的半径* Sin(弧度角)+ Y坐标中心点

     

弧度角度=角度度数* Math.PI / 180

角度取决于否。我们必须创建的细分。通用公式是(360 /段数)。因此,要创建一个包含6个线段的圆,每个线段覆盖的角度将为60度。第一段将覆盖0至60度,第二段将覆盖60至120度,依此类推。

有6个细分的圈子演示:

下表显示了如何计算具有6个圆的圆(圆的半径为50,中心点为55,55)的点:

enter image description here

计算完点后,编码path本身很简单。路径应该从中心点开始和结束在中心点(50,50),我们应该首先画一条线到From Point,然后从那里画一条弧到To Point。以下是示例path的样子:

<path d='M55,55 L105,55 A50,50 0 0,1 80,98.30z' />

&#13;
&#13;
svg {
  height: 220px;
  width: 220px;
}
path {
  fill: transparent;
  stroke: black;
}
&#13;
<svg viewBox='0 0 110 110'>
  <path d='M55,55 L105,55 A50,50 0 0,1 80,98.30z' />
  <path d='M55,55 L80,98.30 A50,50 0 0,1 30,98.30z' />
  <path d='M55,55 L30,98.30 A50,50 0 0,1 5,55z' />
  <path d='M55,55 L5,55 A50,50 0 0,1 30,11.69z' />
  <path d='M55,55 L30,11.69 A50,50 0 0,1 80,11.69z' />
  <path d='M55,55 L80,11.69 A50,50 0 0,1 105,55z' />
</svg>
&#13;
&#13;
&#13;

有12个细分的圈子演示:

对于有12个段的圆,每个段将覆盖30度,因此点将按下表计算:

enter image description here

&#13;
&#13;
svg {
  height: 220px;
  width: 220px;
}
path {
  fill: transparent;
  stroke: black;
}
&#13;
<svg viewBox='0 0 110 110'>
  <path d='M55,55 L105,55 A50,50 0 0,1 98.30,80z' />
  <path d='M55,55 L98.30,80 A50,50 0 0,1 80,98.30z' />
  <path d='M55,55 L80,98.30 A50,50 0 0,1 55,105z' />
  <path d='M55,55 L55,105 A50,50 0 0,1 30,98.30z' />
  <path d='M55,55 L30,98.30 A50,50 0 0,1 11.69,80z' />
  <path d='M55,55 L11.69,80 A50,50 0 0,1 5,55z' />
  <path d='M55,55 L5,55 A50,50 0 0,1 11.69,30z' />
  <path d='M55,55 L11.69,30 A50,50 0 0,1 30,11.69z' />
  <path d='M55,55 L30,11.69 A50,50 0 0,1 55,5z' />
  <path d='M55,55 L55,5 A50,50 0 0,1 80,11.69z' />
  <path d='M55,55 L80,11.69 A50,50 0 0,1 98.30,30z' />
  <path d='M55,55 L98.30,30 A50,50 0 0,1 105,55z' />
</svg>
&#13;
&#13;
&#13;

带有未分段内部的圆圈:

如果看起来中心的圆的一部分(半径较小)看起来不分段,并且内部部分不需要透明,则只需在末尾添加一个额外的圆形元素在SVG内。

&#13;
&#13;
svg {
  height: 220px;
  width: 220px;
}
path {
  fill: transparent;
  stroke: black;
}
circle {
  fill: yellowgreen;
  stroke: black;
}
&#13;
<svg viewBox='0 0 110 110'>
  <path d='M55,55 L105,55 A50,50 0 0,1 80,98.30z' />
  <path d='M55,55 L80,98.30 A50,50 0 0,1 30,98.30z' />
  <path d='M55,55 L30,98.30 A50,50 0 0,1 5,55z' />
  <path d='M55,55 L5,55 A50,50 0 0,1 30,11.69z' />
  <path d='M55,55 L30,11.69 A50,50 0 0,1 80,11.69z' />
  <path d='M55,55 L80,11.69 A50,50 0 0,1 105,55z' />
  <circle cx='55' cy='55' r='25' />
</svg>
&#13;
&#13;
&#13;

每个细分受众群的背景不同:

如果每个细分受众群的背景不同,则只需将fill属性添加到每个path元素。

&#13;
&#13;
svg {
  height: 220px;
  width: 220px;
}
path {
  stroke: black;
}
circle {
  fill: yellowgreen;
  stroke: black;
}
&#13;
<svg viewBox='0 0 110 110'>
  <path d='M55,55 L105,55 A50,50 0 0,1 80,98.30z' fill='crimson' />
  <path d='M55,55 L80,98.30 A50,50 0 0,1 30,98.30z' fill='tomato' />
  <path d='M55,55 L30,98.30 A50,50 0 0,1 5,55z' fill='sandybrown' />
  <path d='M55,55 L5,55 A50,50 0 0,1 30,11.69z' fill='mediumseagreen' />
  <path d='M55,55 L30,11.69 A50,50 0 0,1 80,11.69z' fill='chocolate' />
  <path d='M55,55 L80,11.69 A50,50 0 0,1 105,55z' fill='teal' />
  <circle cx='55' cy='55' r='25' />
</svg>
&#13;
&#13;
&#13;

使用透明内部部分进行演示:

如果中心部分不能具有纯色,则整个事物变得更加复杂,因为我们无法再在中心点开始和结束路径。在这种情况下,我们必须在外圆和内圆上找到点,如下所示:

enter image description here

在这种情况下,path必须从&#34; From(内部)&#34;并且在同一点结束,从一开始一行应该被绘制到&#34;从(外)&#34;,然后一个弧到&#34;到(外)&#34;,一行到&# 34;向(内)&#34;和#34;从(内)&#34;。

&#13;
&#13;
svg {
  height: 220px;
  width: 220px;
}
path {
  fill: transparent;
  stroke: black;
}
&#13;
<svg viewBox='0 0 110 110'>
  <path d='M80,55 L105,55 A50,50 0 0,1 80,98.30 L67.5,76.65 A25,25 0 0,0 80,55z' />
  <path d='M67.5,76.65 L80,98.30 A50,50 0 0,1 30,98.30 L42.5,76.65 A25,25 0 0,0 67.5,76.65z' />
  <path d='M42.5,76.65 L30,98.30 A50,50 0 0,1 5,55 L30,55 A25,25 0 0,0 42.5,76.65z' />
  <path d='M30,55 L5,55 A50,50 0 0,1 30,11.69 L42.5,33.34 A25,25 0 0,0 30,55z' />
  <path d='M42.5,33.34 L30,11.69 A50,50 0 0,1 80,11.69 L67.5,33.34 A25,25 0 0,0 42.5,33.34z' />
  <path d='M67.5,33.34 L80,11.69 A50,50 0 0,1 105,55 L80,55 A25,25 0 0,0 67.5,33.4z' />
</svg>
&#13;
&#13;
&#13;

使每个细分受众群成为可点击链接:

一旦创建了形状本身,这很简单。就像在chipChocolate.py的答案中一样,只需将每个路径包装在SVG锚标记内(<a xlink:href="#">,其中#应该替换链接页面的URL)。

&#13;
&#13;
svg {
  height: 220px;
  width: 220px;
}
path {
  fill: transparent;
  stroke: black;
}
&#13;
<svg viewBox='0 0 110 110'>
  <a xlink:href="#"><path d='M55,55 L105,55 A50,50 0 0,1 80,98.30z' /></a>
  <a xlink:href="#"><path d='M55,55 L80,98.30 A50,50 0 0,1 30,98.30z' /></a>
  <a xlink:href="#"><path d='M55,55 L30,98.30 A50,50 0 0,1 5,55z' /></a>
  <a xlink:href="#"><path d='M55,55 L5,55 A50,50 0 0,1 30,11.69z' /></a>
  <a xlink:href="#"><path d='M55,55 L30,11.69 A50,50 0 0,1 80,11.69z' /></a>
  <a xlink:href="#"><path d='M55,55 L80,11.69 A50,50 0 0,1 105,55z' /></a>
</svg>
&#13;
&#13;
&#13;

在形状中添加文字

SVG中的文本添加稍微复杂一些,因为我们必须再次指定文本的放置点。如果文本相当小(比如几个字符),那么我们可以再次在圆上找到点,使得角度正好在段的中间并使用它。可以设定半径使得它是父圆的半径的一半(如果没有未分段的部分)或者它是在内圆和外圆之间的一半。通过CSS添加的text-anchordominant-baseline设置可确保文本的位置使文本的水平和垂直中心与指定点匹配。

如果文本很大(并且需要环绕),那么应该进行额外处理,因为SVG text标记内的内容不会自动包裹。

具有6个段且没有中心未分段区域的圆的点计算:

enter image description here

具有6个段和中央未分段区域的圆的点计算:

enter image description here

&#13;
&#13;
svg {
  height: 220px;
  width: 220px;
}
path {
  fill: transparent;
  stroke: black;
}
text {
  text-anchor: middle;
  dominant-baseline: middle; /* doesn't work in IE */
  font: 12px Calibri, Arial;
}
&#13;
<svg viewBox='0 0 110 110'>
  <path d='M55,55 L105,55 A50,50 0 0,1 80,98.30z' />
  <text x='76.65' y='67.5'>1</text>
  <path d='M55,55 L80,98.30 A50,50 0 0,1 30,98.30z' />
  <text x='55' y='80'>2</text>
  <path d='M55,55 L30,98.30 A50,50 0 0,1 5,55z' />
  <text x='33.4' y='67.5'>3</text>
  <path d='M55,55 L5,55 A50,50 0 0,1 30,11.69z' />
  <text x='33.4' y='42.5'>4</text>
  <path d='M55,55 L30,11.69 A50,50 0 0,1 80,11.69z' />
  <text x='55' y='30'>5</text>
  <path d='M55,55 L80,11.69 A50,50 0 0,1 105,55z' />
  <text x='76.65' y='42.5'>6</text>
</svg>
<svg viewBox='0 0 110 110'>
  <path d='M55,55 L105,55 A50,50 0 0,1 80,98.30z' />
  <text x='87.47' y='73.75'>1</text>
  <path d='M55,55 L80,98.30 A50,50 0 0,1 30,98.30z' />
  <text x='55' y='92.5'>2</text>
  <path d='M55,55 L30,98.30 A50,50 0 0,1 5,55z' />
  <text x='22.52' y='73.75'>3</text>
  <path d='M55,55 L5,55 A50,50 0 0,1 30,11.69z' />
  <text x='22.52' y='36.25'>4</text>
  <path d='M55,55 L30,11.69 A50,50 0 0,1 80,11.69z' />
  <text x='55' y='17.5'>5</text>
  <path d='M55,55 L80,11.69 A50,50 0 0,1 105,55z' />
  <text x='87.47' y='36.25'>6</text>
  <circle cx='55' cy='55' r='25' />
</svg>
&#13;
&#13;
&#13;

使用JavaScript动态创建

下面是一个粗略的基于JS的实现,以便动态创建段。该函数有四个参数 - 圆的中心的X坐标,中心的Y坐标,圆的半径和no。段/切片。

&#13;
&#13;
var fromAngle, toAngle, fromCoordX, fromCoordY, toCoordX, toCoordY, path, d;

function createPie(cx, cy, r, slices) {
  for (var i = 0; i < slices; i++) {
    path = document.createElementNS("http://www.w3.org/2000/svg", "path");
    fromAngle = i * 360 / slices;
    toAngle = (i + 1) * 360 / slices;
    fromCoordX = cx + (r * Math.cos(fromAngle * Math.PI / 180));
    fromCoordY = cy + (r * Math.sin(fromAngle * Math.PI / 180));
    toCoordX = cx + (r * Math.cos(toAngle * Math.PI / 180));
    toCoordY = cy + (r * Math.sin(toAngle * Math.PI / 180));
    d = 'M' + cx + ',' + cy + ' L' + fromCoordX + ',' + fromCoordY + ' A' + r + ',' + r + ' 0 0,1 ' + toCoordX + ',' + toCoordY + 'z';
    path.setAttributeNS(null, "d", d);
    document.getElementById('pie').appendChild(path);
  }
}

createPie(55, 55, 50, 6);
&#13;
svg {
  height: 220px;
  width: 220px;
}
path {
  fill: transparent;
  stroke: black;
}
&#13;
<svg viewBox="0 0 110 110" id="pie"></svg>
&#13;
&#13;
&#13;

JS示例并未涵盖带有未分段内圈的示例,但可以通过扩展它来实现。

答案 2 :(得分:9)

仅限CSS的方法

注意:使用我目前尚未使用的伪元素可以大大减少标记。

您可以使用 SVG ,但此 可以仅使用CSS和HTML制作。

我所做的是创建12半圆(通过将overflow: hidden;添加到父容器)。然后我创建了单独的6半圆组。

中心的角度应为30deg360/12)。为实现这一目标,我们必须从原来的圆心旋转半圆。我们可以使用transform-origin: 50% 100%;

执行此操作

现在您只需旋转/翻转第二组6半圆即可完成设计。

最后,添加一个中央绿色圆圈来完成设计。

&#13;
&#13;
.cont, #bag {
    height:200px;
    width:400px;
    overflow:hidden;
}
#one, #two, #three, #four, #five, #six {
    height:400px;
    width:400px;
    border-radius:200px;
}
#bag > div {
    position:relative;
    transform-origin:50% 100%;
}
#one, #three, #five {
    background-color:orange;
}
#one:hover, #three:hover, #five:hover {
    background-color:gold;
}
#two, #four, #six {
    background-color:forestgreen;
}
#bag > :nth-child(2) {
    top:-200px;
    -webkit-transform:rotate(30deg);
    transform:rotate(30deg);
}
#bag > :nth-child(3) {
    top:-400px;
    transform:rotate(60deg);
    transform:rotate(60deg);
}
#bag > div:nth-child(4) {
    top:-600px;
    -webkit-transform:rotate(90deg);
    transform:rotate(90deg);
}
#bag > :nth-child(5) {
    top:-800px;
    -webkit-transform:rotate(120deg);
    transform:rotate(120deg);
}
#bag > :nth-child(6) {
    top:-1000px;
    -webkit-transform:rotate(150deg);
    transform:rotate(150deg);
}
#bag:nth-of-type(2){
    transform:scale(-1);
    transform-origin:50% 50%;
}
#green-center {
    height:200px;
    width:200px;
    border-radius:50%;
    background-color:forestgreen;
    position: relative;
    top:-300px;
    left:100px;
}
&#13;
<div id="bag">
    <div class="cont">
        <a href="http://example.com/"><div id="one"></div></a>
    </div>
    <div class="cont">
        <div id="two">ABC</div>
    </div>
    <div class="cont">
        <a href="http://example.com/"><div id="three"></div></a>
    </div>
    <div class="cont">
        <div id="four"></div>
    </div>
    <div class="cont">
        <a href="http://example.com/"><div id="five"></div></a>
    </div>
    <div class="cont">
        <div id="six"></div>
    </div>
</div>
<div id="bag">
    <div class="cont">
        <a href="http://example.com/"><div id="one"></div></a>
    </div>
    <div class="cont">
        <div id="two"></div>
    </div>
    <div class="cont">
        <a href="http://example.com/"><div id="three"></div></a>
    </div>
    <div class="cont">
        <div id="four"></div>
    </div>
    <div class="cont">
        <a href="http://example.com/"><div id="five"></div></a>
    </div>
    <div class="cont">
        <div id="six"></div>
    </div>
</div>
<div id="green-center">
&#13;
&#13;
&#13;

输出 Firefox Google Chrome IE

enter image description here

答案 3 :(得分:3)

您可以使用地图,如下所示:

#circle{
    position:relative;
    width:200px;
    height:200px;
    border-radius:50%;
    background:green;
}

#mappinglink{
    position:absolute;
    top:0px;
    left:0px;
}

#incircle{
    width:100px;
    height:100px;
    border-radius:50%;
    border:50px dotted orange;
    border-spacing: 10px 50px;
}
<div id="circle">
    <div id="incircle"></div>
    <img id="mappinglink" width="200" height="200" usemap="#mymap" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"/>
    <map name="mymap">
        <area  alt="" title="" href="#" shape="poly" coords="29,28,71,3,84,50,64,64" style="outline:none;" target="_self"     />
        <area  alt="" title="" href="#" shape="poly" coords="148,12,122,55,142,73,184,46" style="outline:none;" target="_self"     />
        <area  alt="" title="" href="#" shape="poly" coords="149,96,199,93,192,142,146,121" style="outline:none;" target="_self"     />
        <area  alt="" title="" href="#" shape="poly" coords="105,149,128,141,159,180,112,200" style="outline:none;" target="_self"     />
        <area  alt="" title="" href="#" shape="poly" coords="59,133,79,147,65,193,23,164" style="outline:none;" target="_self"     />
        <area  alt="" title="" href="#" shape="poly" coords="48,87,50,108,3,120,4,71" style="outline:none;" target="_self"     />
    </map>
</div>

答案 4 :(得分:2)

试试这个纯粹的CSS:

*{box-sizing: border-box;padding: 0; margin: 0}
nav,nav:before{
    border-radius:50%;
    background:green
}
nav{
    width:200px;
    height:200px;
    margin: 40px auto;
    position: relative;
    overflow: hidden
}
nav:before{
    content: '';
    position:absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    z-index: 2;
    transform: translate3d(-50%,-50%,0)
}
#incircle{
    width:100px;
    height:100px;
    border-radius:50%;
    border:50px dotted orange;
}

nav a{
    position: absolute;
    z-index: 1;
    cursor: pointer;
    width: 0px;
    height: 0px;
    border-top: 30px solid transparent;
    border-bottom: 30px solid transparent
}
nav a:nth-child(3),nav a:nth-child(4){
    left: 70px;
    border-left: 30px solid transparent;
    border-right: 30px solid transparent
}

nav a:first-child{
    top: 70px;
    left: 0;
    border-left: 100px solid orange
}
nav a:nth-child(2){
    left: 20px;
    border-left: 100px solid orange;
    top: 20px;
    transform: rotateZ(60deg);
}
nav a:nth-child(3){
    transform: rotateZ(30deg);
    top: 0px;
    left: 86px;
    border-top: 100px solid orange;
}
nav a:nth-child(4){
    left: 46px;
    border-bottom: 100px solid orange;
    bottom: -4px;
    transform: rotateZ(28deg);
}
nav a:nth-child(5){
    right: 24px;
    border-right: 100px solid orange;
    bottom: 20px;
    transform: rotateZ(60deg);
}
nav a:last-child{
    top: 70px;
    right: 0;
    border-right: 100px solid orange
}
<nav> 
    <a></a>
    <a></a>
    <a></a>
    
    <a></a>
    <a></a>
    <a></a>
</nav>

答案 5 :(得分:1)

Here's a fiddle.

HTML

<div id="circle">
    <a id='left' href='left'></a>
    <a id='right' href='right'></a>
    <div id="mid"></div>
</div>

CSS

#circle{
    width: 200px;
    height: 200px;
    border-radius: 50%;
    position: relative;
    overflow: hidden;
}

a {
    height: 100%;
    width: 49%;
    background: orange;
    display: block;
}

#left {
    float: left;
}

#right {
    float: right;
}

#mid {
    border-radius: 50%;
    background: green;
    border: 4px solid white;
    position: absolute;
    display: block;
    height: 50%;
    width: 50%;
    left: 24%;
    top: 24%;
}

通过垂直分割a,可以将其简单地扩展为4个而不是2个。不过我建议您查看类似RaphaelJS的内容 。你甚至可以作弊并使用pie chart

答案 6 :(得分:1)

我试图使用纯css, 想出了这个:

.wrap {
  height: 200px;
  width: 200px;
  background: red;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
}
.wrap:after {
  position: absolute;
  height: 50%;
  width: 50%;
  content: "";
  border-radius: 50%;
  background: green;
  left: 25%;
  top: 25%;
}
.slice {
  height: 0;
  width: 0;
  border-left: 200px solid blue;
  border-top: 200px solid transparent;
  position: absolute;
  top: -100px;
  left: -100px;
}
.part2 {
  border-left: 200px solid red;
  border-top: 200px solid transparent;
  transform: rotate(180deg);
  top: -100px;
  left: -100px;
}
.part3 {
  border-left: 200px solid pink;
  border-top: 200px solid transparent;
  transform: rotate(90deg);
  top: -100px;
  left: 100px;
}
<div class="wrap">
  <a href="#" class="slice"></a>
  <div class="slice part2"></div>
  <a href="#" class="slice part3"></a>
</div>

然而,这是使用“边界技巧”来生成蓝色div,这将使其部分可点击。但是,我确实觉得这个在适应后, 可以 工作。

  • 或者,如果您对使用SCSS this
  • 感兴趣/愿意
  • 或者,您可以使用this作为设计的基础

这样的东西

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');
}
@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;
} 
<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>
  

答案 7 :(得分:0)

这听起来像SVG的工作。它有自己的<a> element类型,可以包含任意形状。