2017-05-29 69 views
0

如何正确制作这样的导航栏,特别是这两条相交的线。我知道,我可以使用transform: skewX(10deg);旋转这个垂直线,但不知道我是OK与整个HTML & CSS特定的圆形导航

enter image description here

HTML:

<main> 
    <div class="rounded-rectangle"> 
     <ul class="top"> 
     <li> 
      <button>text</button> 
     </li> 
     <li> 
      <button>text</button> 
     </li> 
     </ul> 
     <ul class="bottom"> 
     <li> 
      <button>text</button> 
     </li> 
     <li> 
      <button>text</button> 
     </li> 
     </ul> 
    </div> 
</main> 

Fiddle

回答

1

您可以使用容器的伪元素来绘制相交的lin ES。

html, 
 
body { 
 
    height: 100%; 
 
} 
 

 
body { 
 
    display: flex; 
 
    flex-direction: row; 
 
    font-family: 'Raleway', sans-serif; 
 
    background-color: #e24d3d; 
 
} 
 

 
main { 
 
    flex-grow: 1; 
 
} 
 

 
ul li { 
 
    height: 100%; 
 
    display: flex; 
 
    flex-direction: column; 
 
    justify-content: center; 
 
    list-style: none; 
 
    text-transform: uppercase; 
 
    font-size: 30px; 
 
} 
 

 
button { 
 
    background-color: transparent; 
 
    border: none; 
 
    color: white; 
 
    padding: 32px; 
 
    text-align: center; 
 
    text-decoration: none; 
 
    display: inline-block; 
 
    font-size: 2.5em; 
 
    font-family: 'Raleway', sans-serif; 
 
    text-transform: uppercase; 
 
} 
 

 
button:focus { 
 
    outline: -webkit-focus-ring-color auto 0px; 
 
} 
 

 
ul.top { 
 
    display: flex; 
 
    justify-content: space-around; 
 
    height: 50%; 
 
} 
 

 
ul.top div:nth-last-child(1) { 
 
    border-right: 1px solid #FFF; 
 
} 
 

 
ul.bottom { 
 
    display: flex; 
 
    justify-content: space-around; 
 
    height: 50%; 
 
} 
 

 
.rounded-rectangle { 
 
    background-color: rgba(128, 213, 226, 0.4); 
 
    height: 320px; 
 
    max-width: 520px; 
 
    border-radius: 10px; 
 
    margin: auto; 
 
    position: relative; 
 
} 
 

 
.rounded-rectangle:before, .rounded-rectangle:after { 
 
    content: ''; 
 
    position: absolute; 
 
    background: #fff; 
 
} 
 

 
.rounded-rectangle:before { 
 
    top: 50%; 
 
    height: 1px; 
 
    left: 0; right: 0; 
 
} 
 

 
.rounded-rectangle:after { 
 
    left: 50%; 
 
    width: 1px; 
 
    top: 0; bottom: 0; 
 
    transform: rotate(10deg); 
 
} 
 

 
ul { 
 
    padding: 0; 
 
    margin: 0; 
 
}
<main> 
 
    <div class="rounded-rectangle"> 
 
    <ul class="top"> 
 
     <li> 
 
     <button>text</button> 
 
     </li> 
 
     <li> 
 
     <button>text</button> 
 
     </li> 
 
    </ul> 
 
    <ul class="bottom"> 
 
     <li> 
 
     <button>text</button> 
 
     </li> 
 
     <li> 
 
     <button>text</button> 
 
     </li> 
 
    </ul> 
 
    </div> 
 
</main>

+0

谢谢,仅此而已。我有一个小问题。当我正在降低高度,例如min-height:110px时,内部文字不响应 – cygnus

+0

@cygnus听起来像是超出了你的OP范围,不是?如果你无法弄清楚,你应该写一篇新文章,但你需要更具体。更改'最小高度'是什么?你是什​​么意思,它不响应 - 因为它重叠?听起来就像你只需要使用一些@media查询来处理不同的高度和调整字体大小,或者使用'vw'或'vh'单位来控制文本大小。无论如何,我认为这个帖子的评论有点复杂。 –

+0

只知道我已经打破了'li'里面的高度,反正再次谢谢! – cygnus