2017-05-17 8 views
0

メニュー間の間隔(ギャップ)を調整してナビバーに合うようにしようとしています。誰でもこれを修正する方法を知っていますか?それぞれのメニューを個別に再配置することは可能ですか?メニュー間の隙間を調整する

Here's the demo

#navbar { 
 
    width: 1200px; 
 
    height: 180px; 
 
    background: url(http://i67.tinypic.com/5cygax.png) no-repeat center center; 
 
    background-size: contain; 
 
    -webkit-background-size: contain; 
 
    -moz-background-size: contain; 
 
    -o-background-size: contain; 
 
    background-size: contain; 
 
    margin-left: 80px; 
 
    margin-top: 100px; 
 
} 
 

 
#menu { 
 
    display: inline-block; 
 
    margin: 65px 50px 0px 100px; 
 
    position: relative; 
 
    float: left; 
 
    width: 100px; 
 
    padding: 0 10px; 
 
    border-radius: 8px; 
 
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .15); 
 
    background: #8495F5; 
 
} 
 

 
#menu, 
 
#menu ul { 
 
    list-style: none; 
 
} 
 

 
#menu: li { 
 
    float: left; 
 
    position: relative; 
 
    border-right: 1px solid rgba(0, 0, 0, .1); 
 
    box-shadow: 1px 0 0 rgba(255, 255, 255, .25); 
 
    perspective: 1000px; 
 
} 
 

 
#menu: li:first-child { 
 
    border-left: 1px solid rgba(255, 255, 255, .25); 
 
    box-shadow: -1px 0 0 rgba(0, 0, 0, .1), 1px 0 0 rgba(255, 255, 255, .25); 
 
} 
 

 
#menu a { 
 
    display: block; 
 
    position: inherit; 
 
    z-index: 10; 
 
    padding: 15px 20px 15px 20px; 
 
    text-decoration: none; 
 
    color: rgba(75, 75, 75, 1); 
 
    line-height: 1; 
 
    font-family: sans-serif; 
 
    font-weight: 700; 
 
    font-size: 12px; 
 
    letter-spacing: 0.15em; 
 
    background: transparent; 
 
    text-shadow: 0 1px 1px rgba(255, 255, 255, .9); 
 
    transition: all .25s ease-in-out; 
 
    text-align: center; 
 
} 
 

 
#menu: li:hover>a { 
 
    background: #333; 
 
    color: rgba(0, 223, 252, 1); 
 
    text-shadow: none; 
 
} 
 

 
#menu li ul { 
 
    position: absolute; 
 
    left: 0; 
 
    z-index: 1; 
 
    width: 250px; 
 
    padding: 0; 
 
    opacity: 0; 
 
    visibility: hidden; 
 
    border-bottom-left-radius: 4px; 
 
    border-bottom-right-radius: 4px; 
 
    background: transparent; 
 
    overflow: hidden; 
 
    transform-origin: 50% 0%; 
 
} 
 

 
#menu li:hover ul { 
 
    padding: 5px 0; 
 
    background: #333; 
 
    opacity: 1; 
 
    visibility: visible; 
 
    box-shadow: 1px 1px 7px rgba(0, 0, 0, .5); 
 
    animation-name: swingdown; 
 
    animation-duration: 1s; 
 
    animation-timing-function: ease; 
 
} 
 

 
@keyframes swingdown { 
 
    0% { 
 
     opacity: .99999; 
 
     transform: rotateX(90deg); 
 
    } 
 
    30% { 
 
     transform: rotateX(-20deg) rotateY(5deg); 
 
     animation-timing-function: ease-in-out; 
 
    } 
 
    65% { 
 
     transform: rotateX(20deg) rotateY(-3deg); 
 
     animation-timing-function: ease-in-out; 
 
    } 
 
    100% { 
 
     transform: rotateX(0); 
 
     animation-timing-function: ease-in-out; 
 
    } 
 
} 
 

 
#menu li li a { 
 
    padding-left: 15px; 
 
    font-weight: 400; 
 
    color: #ddd; 
 
    text-shadow: none; 
 
    border-top: dotted 1px transparent; 
 
    border-bottom: dotted 1px transparent; 
 
    transition: all .15s linear; 
 
} 
 

 
#menu li li a:hover { 
 
    color: rgba(0, 223, 252, 1); 
 
    border-top: dotted 1px rgba(255, 255, 255, .15); 
 
    border-bottom: dotted 1px rgba(255, 255, 255, .15); 
 
    background: rgba(0, 223, 252, .02); 
 
}
<div id="container"> 
 
    <div id="navbar"> 
 

 
     <ul id="menu"> 
 
      <li><a class="home" href="#">Home</a></li> 
 
     </ul> 
 

 
     <ul id="menu"> 
 
      <li><a class="register" href="#">Register</a></li> 
 
     </ul> 
 

 
     <ul id="menu"> 
 
      <li><a class="guide" href="#">Guide</a> 
 
       <ul> 
 
        <li><a href="#">New Features</a></li> 
 
        <li><a href="#">Quest & Event Guide</a></li> 
 
        <li><a href="#">Brigand & T-map Guide</a></li> 
 
       </ul> 
 
     </ul> 
 

 
     <ul id="menu"> 
 
      <li><a class="download" href="#">Download</a> 
 
       <ul> 
 
        <li><a href="#">Patch Download</a></li> 
 
       </ul> 
 
     </ul> 
 
    </div> 
 
</div>

答えて

1

enter image description here私はこのようなものが欲しいと思いますか? CSSの最後の行が各LIの位置を制御します。

SOURCE:

#navbar{ 
 
\t width: 1200px; 
 
\t height: 180px; 
 
    background: url(http://i67.tinypic.com/5cygax.png) no-repeat center center; 
 
    background-size: contain; 
 
    -webkit-background-size: contain; 
 
    -moz-background-size: contain; 
 
    -o-background-size: contain; 
 
    background-size: contain; 
 
    margin-left: 80px; 
 
    margin-top: 100px; 
 
} 
 

 
ul#menu { 
 
\t \t display: inline-block; 
 
\t \t margin: 65px 0 0px 195px; 
 
\t \t position: relative; 
 
\t \t width: 800px; 
 
    list-style-type:none; 
 
\t } 
 

 
\t ul#menu, ul#menu-sub { 
 
\t \t list-style-type: none; 
 
\t } 
 

 
ul#menu > li { 
 
\t \t padding: 0 10px; 
 
\t \t box-shadow: inset 0 1px 1px rgba(255,255,255,.5), inset 0 -1px 0 rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.15); 
 
\t \t background: #8495F5; 
 
    width: 100px; 
 
    float: left; 
 
    position: relative; 
 
    display: inline-block; 
 
\t \t border-right: 1px solid rgba(0,0,0,.1); 
 
\t \t box-shadow: 1px 0 0 rgba(255,255,255,.25); 
 
    border-radius: 8px; 
 
\t } 
 

 
\t #menu li:first-child { 
 
\t \t border-left: 1px solid rgba(255,255,255,.25); 
 
\t \t box-shadow: -1px 0 0 rgba(0,0,0,.1), 1px 0 0 rgba(255,255,255,.25); 
 
\t } 
 

 
\t #menu a.menu-top { 
 
\t \t display: block; 
 
\t \t position: inherit; 
 
\t \t z-index: 10; 
 
\t \t padding: 15px 20px 15px 20px; 
 
\t \t text-decoration: none; 
 
\t \t color: rgba(75,75,75,1); 
 
\t \t line-height: 1; 
 
\t \t font-family: sans-serif; 
 
\t \t font-weight: 700; 
 
\t \t font-size: 12px; 
 
\t \t letter-spacing: 0.15em; 
 
\t \t background: transparent; \t \t 
 
\t \t text-shadow: 0 1px 1px rgba(255,255,255,.9); 
 
\t \t transition: all .25s ease-in-out; 
 
\t \t text-align: center; 
 
\t 
 
\t } 
 
\t #menu-sub { 
 
\t \t position: absolute; 
 
\t \t left: 0; 
 
\t \t z-index: 1; 
 
\t \t width: 250px; 
 
\t \t padding: 0; 
 
\t \t opacity: 0; 
 
\t \t visibility: hidden; 
 
\t \t border-bottom-left-radius: 4px; 
 
\t \t border-bottom-right-radius: 4px; 
 
\t \t background: transparent; 
 
\t \t overflow: hidden; 
 
\t \t transform-origin: 50% 0%; 
 
\t } 
 
\t #menu-sub a { 
 
\t \t padding-left: 15px; 
 
\t \t font-weight: 400; 
 
\t \t color: #ddd; 
 
\t \t text-shadow: none; 
 
\t \t border-top: dotted 1px transparent; 
 
\t \t border-bottom: dotted 1px transparent; 
 
\t \t transition: all .15s linear; 
 
    padding: 10px; 
 
    display:block; 
 
\t } 
 

 
\t #menu-sub a:hover { 
 
\t \t color: rgba(0,223,252,1); 
 
\t \t border-top: dotted 1px rgba(255,255,255,.15); 
 
\t \t border-bottom: dotted 1px rgba(255,255,255,.15); 
 
\t \t background: rgba(0,223,252,.02); 
 
\t } 
 
\t #menu-sub li:hover > a { 
 
\t \t background: #333; 
 
\t \t color: rgba(0,223,252,1); 
 
\t \t text-shadow: none; 
 
\t } 
 
\t #menu li:hover #menu-sub { 
 
\t \t 
 
\t \t padding: 5px 0; 
 
\t \t background: #333; 
 
\t \t opacity: 1; 
 
\t \t visibility: visible; 
 
\t \t box-shadow: 1px 1px 7px rgba(0,0,0,.5); 
 
\t \t animation-name: swingdown; 
 
\t \t animation-duration: 1s; 
 
\t \t animation-timing-function: ease; 
 

 
\t } 
 

 
\t @keyframes swingdown { 
 
\t \t 0% { 
 
\t \t \t opacity: .99999; 
 
\t \t \t transform: rotateX(90deg); 
 
\t \t } 
 

 
\t \t 30% { \t \t \t 
 
\t \t \t transform: rotateX(-20deg) rotateY(5deg); 
 
\t \t \t animation-timing-function: ease-in-out; 
 
\t \t } 
 

 
\t \t 65% { 
 
\t \t \t transform: rotateX(20deg) rotateY(-3deg); 
 
\t \t \t animation-timing-function: ease-in-out; 
 
\t \t } 
 

 
\t \t 100% { 
 
\t \t \t transform: rotateX(0); 
 
\t \t \t animation-timing-function: ease-in-out; 
 
\t \t } 
 
\t } 
 

 
/* controlling each li's position */ 
 
ul#menu li:nth-child(1) { /*first */ 
 
    margin-right: 3% 
 
} 
 
ul#menu li:nth-child(2) { /*first */ 
 
    margin-right: 200px; 
 
} 
 
ul#menu li:nth-child(3) { /*first */ 
 
    margin-right: 3% 
 
} 
 
ul#menu li:nth-child(4) { /*first */ 
 
    margin-right: 0; 
 
}
<div id="container"> 
 
\t \t <div id="navbar"> 
 
\t \t \t <ul id="menu"> 
 
    \t \t \t <li><a class="menu-top home" href="#">Home</a></li> 
 
      <li><a class="menu-top register" href="#">Register</a></li> 
 
\t \t \t  <li> 
 
       <a class="menu-top guide" href="#">Guide</a> 
 
     \t \t \t <ul id="menu-sub"> 
 
        <li><a href="#">New Features</a></li> 
 
        <li><a href="#">Quest & Event Guide</a></li> 
 
        <li><a href="#">Brigand & T-map Guide</a></li> 
 
       </ul> 
 
      </li> 
 
      <li> 
 
       <a class="menu-top download" href="#">Download</a> 
 
     \t \t \t <ul id="menu-sub"> 
 
\t \t \t   <li><a href="#">Patch Download</a></li> 
 
\t \t \t   </ul> 
 
      </li> 
 
     </ul> 
 
\t \t </div> 
 
\t </div>

ビューペン:Adjust gap between menu

+0

うれしいよ。 –

+0

ペン(最終行css)を更新したので、LI cssはそれと同じようにサブメニューに影響しません –

0

変更されたマージン#menu

#menu { 
    margin: 65px 0 0px 20px; 
} 

#navbar { 
 
    width: 1200px; 
 
    height: 180px; 
 
    background: url(http://i67.tinypic.com/5cygax.png) no-repeat center center; 
 
    background-size: contain; 
 
    -webkit-background-size: contain; 
 
    -moz-background-size: contain; 
 
    -o-background-size: contain; 
 
    background-size: contain; 
 
    margin-left: 80px; 
 
    margin-top: 100px; 
 
} 
 

 
#menu { 
 
    display: inline-block; 
 
    margin: 65px 0 0px 20px; 
 
    position: relative; 
 
    float: left; 
 
    width: 100px; 
 
    padding: 0 10px; 
 
    border-radius: 8px; 
 
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, .5), inset 0 -1px 0 rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .15); 
 
    background: #8495F5; 
 
} 
 

 
#menu, 
 
#menu ul { 
 
    list-style: none; 
 
} 
 

 
#menu: li { 
 
    float: left; 
 
    position: relative; 
 
    border-right: 1px solid rgba(0, 0, 0, .1); 
 
    box-shadow: 1px 0 0 rgba(255, 255, 255, .25); 
 
    perspective: 1000px; 
 
} 
 

 
#menu: li:first-child { 
 
    border-left: 1px solid rgba(255, 255, 255, .25); 
 
    box-shadow: -1px 0 0 rgba(0, 0, 0, .1), 1px 0 0 rgba(255, 255, 255, .25); 
 
} 
 

 
#menu a { 
 
    display: block; 
 
    position: inherit; 
 
    z-index: 10; 
 
    padding: 15px 20px 15px 20px; 
 
    text-decoration: none; 
 
    color: rgba(75, 75, 75, 1); 
 
    line-height: 1; 
 
    font-family: sans-serif; 
 
    font-weight: 700; 
 
    font-size: 12px; 
 
    letter-spacing: 0.15em; 
 
    background: transparent; 
 
    text-shadow: 0 1px 1px rgba(255, 255, 255, .9); 
 
    transition: all .25s ease-in-out; 
 
    text-align: center; 
 
} 
 

 
#menu: li:hover>a { 
 
    background: #333; 
 
    color: rgba(0, 223, 252, 1); 
 
    text-shadow: none; 
 
} 
 

 
#menu li ul { 
 
    position: absolute; 
 
    left: 0; 
 
    z-index: 1; 
 
    width: 250px; 
 
    padding: 0; 
 
    opacity: 0; 
 
    visibility: hidden; 
 
    border-bottom-left-radius: 4px; 
 
    border-bottom-right-radius: 4px; 
 
    background: transparent; 
 
    overflow: hidden; 
 
    transform-origin: 50% 0%; 
 
} 
 

 
#menu li:hover ul { 
 
    padding: 5px 0; 
 
    background: #333; 
 
    opacity: 1; 
 
    visibility: visible; 
 
    box-shadow: 1px 1px 7px rgba(0, 0, 0, .5); 
 
    animation-name: swingdown; 
 
    animation-duration: 1s; 
 
    animation-timing-function: ease; 
 
} 
 

 
@keyframes swingdown { 
 
    0% { 
 
    opacity: .99999; 
 
    transform: rotateX(90deg); 
 
    } 
 
    30% { 
 
    transform: rotateX(-20deg) rotateY(5deg); 
 
    animation-timing-function: ease-in-out; 
 
    } 
 
    65% { 
 
    transform: rotateX(20deg) rotateY(-3deg); 
 
    animation-timing-function: ease-in-out; 
 
    } 
 
    100% { 
 
    transform: rotateX(0); 
 
    animation-timing-function: ease-in-out; 
 
    } 
 
} 
 

 
#menu li li a { 
 
    padding-left: 15px; 
 
    font-weight: 400; 
 
    color: #ddd; 
 
    text-shadow: none; 
 
    border-top: dotted 1px transparent; 
 
    border-bottom: dotted 1px transparent; 
 
    transition: all .15s linear; 
 
} 
 

 
#menu li li a:hover { 
 
    color: rgba(0, 223, 252, 1); 
 
    border-top: dotted 1px rgba(255, 255, 255, .15); 
 
    border-bottom: dotted 1px rgba(255, 255, 255, .15); 
 
    background: rgba(0, 223, 252, .02); 
 
}
<div id="container"> 
 
    <div id="navbar"> 
 

 
    <ul id="menu"> 
 
     <li><a class="home" href="#">Home</a></li> 
 
    </ul> 
 

 
    <ul id="menu"> 
 
     <li><a class="register" href="#">Register</a></li> 
 
    </ul> 
 

 
    <ul id="menu"> 
 
     <li><a class="guide" href="#">Guide</a> 
 
     <ul> 
 
      <li><a href="#">New Features</a></li> 
 
      <li><a href="#">Quest & Event Guide</a></li> 
 
      <li><a href="#">Brigand & T-map Guide</a></li> 
 
     </ul> 
 
    </ul> 
 

 
    <ul id="menu"> 
 
     <li><a class="download" href="#">Download</a> 
 
     <ul> 
 
      <li><a href="#">Patch Download</a></li> 
 
     </ul> 
 
    </ul> 
 
    </div> 
 
</div>

用210
+0

私はそれがナビゲーションバーに収まるますので、メニュー間の間隔(ギャップ)を調整しようとしています。ダー、それはあなたによく見えますか? – StoopidNerd

関連する問題