2017-10-31 16 views
0

メニューバーとソーシャルメディアアイコンの間のスペースを少し大きくするにはどうすればよいですか?私は左右に浮かびたくないことに注意してください。希望の結果を得られません。メニューとソーシャルメディアのアイコンの間隔を少し広げる方法

これは私のナビゲーションバーコードです。

<nav> 
    <label for="drop" class="toggle">Menu</label> 
    <input type="checkbox" id="drop" /> 
    <ul class="menu"> 
     <li><a href="#">Home</a></li> 
     <li><a href="#">About Us</a></li> 
     <li> 
      <!-- First Tier Drop Down --> 
      <label for="drop-1" class="toggle">Service +</label> 
      <a href="#">Service</a> 
      <input type="checkbox" id="drop-1"/> 
      <ul> 
       <li><a href="#">Methodology</a></li> 
      </ul> 
     </li> 
     <li> 
      <!-- First Tier Drop Down --> 
      <label for="drop-2" class="toggle">Web Design +</label> 
      <a href="#">Web Design</a> 
      <input type="checkbox" id="drop-2"/> 
      <ul> 
       <li><a href="#">Resources</a></li> 
       <li><a href="#">Links</a></li> 
       <li> 
        <!-- Second Tier Drop Down -->   
        <label for="drop-3" class="toggle">Tutorials +</label> 
        <a href="#">Tutorials</a>   
        <input type="checkbox" id="drop-3"/> 
        <ul> 
         <li><a href="#">HTML/CSS</a></li> 
         <li><a href="#">jQuery</a></li> 
         <li><a href="#">Other</a></li> 
        </ul> 
       </li> 
      </ul> 
     </li> 
     <li> 
      <!-- First Tier Drop Down --> 
      <label for="drop-2" class="toggle">Web Design +</label> 
      <a href="#">Web Design</a> 
      <input type="checkbox" id="drop-2"/> 
      <ul> 
       <li><a href="#">Resources</a></li> 
       <li><a href="#">Links</a></li> 
       <li> 
        <!-- Second Tier Drop Down -->   
        <label for="drop-3" class="toggle">Tutorials +</label> 
        <a href="#">Tutorials</a>   
        <input type="checkbox" id="drop-3"/> 
        <ul> 
         <li><a href="#">HTML/CSS</a></li> 
         <li><a href="#">jQuery</a></li> 
         <li><a href="#">Other</a></li> 
        </ul> 
       </li> 
      </ul> 
     </li> 
     <li> 
      <!-- First Tier Drop Down --> 
      <label for="drop-2" class="toggle">Courses +</label> 
      <a href="#">Courses</a> 
      <input type="checkbox" id="drop-2"/> 
      <ul> 
       <li><a href="#">Administration</a></li> 
       <li><a href="#">Agriculture</a></li> 
       <li><a href="#">Courses</a></li> 
      </ul> 
     </li> 
     <li><a href="#">Events</a></li> 
     <li><a href="#">Contact</a></li> 
     <li><a href="#"><img src="images/soc/facebook.png" height="32" width="15"></a></li> 
     <li><a href="#"><img src="images/soc/twitter.png" height="32" width="32"></a></li> 
     <li><a href="#"><img src="images/soc/instagram.png" height="32" width="34"></a></li> 
    </ul> 
</nav> 

これは、スタイリングシートのコードです:

/* Styling for navbar menu */ 

/* CSS Document */ 

.toggle, 
[id^=drop] { 
    display: none; 
} 

/* Giving a background-color to the nav container. */ 
nav { 
    margin:0; 
    padding: 0; 
    background-color: #000000; 
} 

/* Since we'll have the "ul li" "float:left" 
* we need to add a clear after the container. */ 

nav:after { 
    content:""; 
    display:table; 
    clear:both; 
} 

/* Removing padding, margin and "list-style" from the "ul", 
* and adding "position:reltive" */ 
nav ul { 
    display: flex; 
    justify-content: center; 
    padding:0; 
    margin:0; 
    list-style: none; 
    position: relative; 
} 

/* Positioning the navigation items inline */ 
nav ul li { 
    margin: 0px; 
    display:inline-block; 
    float: left; 
    background-color: #000000; 
} 

/* Styling the links */ 
nav a { 
    display:block; 
    padding:14px 20px; 
    color:#FFF; 
    font-size:17px; 
    text-decoration:none; 
    line-height: 32px; 
} 

nav ul li ul li:hover { background: #000000; } 

/* Background color change on Hover */ 
nav a:hover { 
    background-color: #FFC213; 
} 

/* Hide Dropdowns by Default 
* and giving it a position of absolute */ 
nav ul ul { 
    display: none; 
    position: absolute; 
    /* has to be the same number as the "line-height" of "nav a" */ 
    top: 60px; 
} 

/* Display Dropdowns on Hover */ 
nav ul li:hover > ul { 
    display:inherit; 
    z-index: 3; 
} 

/* Fisrt Tier Dropdown */ 
nav ul ul li { 
    width:170px; 
    float:none; 
    display:list-item; 
    position: relative; 
} 

/* Second, Third and more Tiers 
* We move the 2nd and 3rd etc tier dropdowns to the left 
* by the amount of the width of the first tier. 
*/ 
nav ul ul ul li { 
    position: relative; 
    top:-60px; 
    /* has to be the same number as the "width" of "nav ul ul li" */ 
    left:170px; 
} 

/* Change ' +' in order to change the Dropdown symbol */ 
li > a:after { content: ' +'; } 
li > a:only-child:after { content: ''; } 

/* Media Queries 
--------------------------------------------- */ 

@media all and (max-width : 768px) { 
    nav { 
     margin: 0; 
    } 

    /* Hide the navigation menu by default */ 
    /* Also hide the */ 
    .toggle + a, 
    .menu { 
     display: none; 
    } 

    /* Stylinf the toggle lable */ 
    .toggle { 
     display: block; 
     background-color: #000000; 
     padding:14px 20px; 
     color:#FFF; 
     font-size:17px; 
     text-decoration:none; 
     border:none; 
    } 

    .toggle:hover { 
     background-color: #FFC213; 
    } 

    /* Display Dropdown when clicked on Parent Lable */ 
    [id^=drop]:checked + ul { 
     display: block; 
    } 

    /* Change menu item's width to 100% */ 
    nav ul li { 
     display: block; 
     width: 100%; 
    } 

    nav ul ul .toggle, 
    nav ul ul a { 
     padding: 0 40px; 
    } 

    nav ul ul ul a { 
     padding: 0 80px; 
    } 

    nav a:hover, 
    nav ul ul ul a { 
     background-color: #FFC213; 
    } 

    nav ul li ul li .toggle, 
    nav ul ul a, 
    nav ul ul ul a{ 
     padding:14px 20px; 
     color:#FFF; 
     font-size:17px; 
    } 

    nav ul li ul li .toggle, 
    nav ul ul a { 
     background-color: #212121; 
    } 

    /* Hide Dropdowns by Default */ 
    nav ul ul { 
     float: none; 
     position:static; 
     color: #ffffff; 
     /* has to be the same number as the "line-height" of "nav a" */ 
    } 

    /* Hide menus on hover */ 
    nav ul ul li:hover > ul, 
    nav ul li:hover > ul { 
     display: none; 
    } 

    /* Fisrt Tier Dropdown */ 
    nav ul ul li { 
     display: block; 
     width: 100%; 
    } 

    nav ul ul ul li { 
     position: static; 
     /* has to be the same number as the "width" of "nav ul ul li" */ 
    } 
} 

@media all and (max-width : 150px) { 
    nav ul li { 
     display:block; 
     width: 94%; 
    } 
} 

答えて

0

あなたはnth-last-childセレクタを使用することができます。それは最初のソーシャルアイコンである最後の要素の前を選択します。そしてmarginまたはpaddingは、それらの間の距離とli

nav ul li { 
 
    float:left 
 
} 
 
nav ul { 
 
    list-style:none 
 
} 
 
nav ul li:nth-last-child(2) { 
 
    margin-left:50px 
 
}
<nav> 
 
    <ul> 
 
    <li>List Item</li> 
 
    <li>List Item</li> 
 
    <li>List Item</li> 
 
    <li>List Item</li> 
 
    <li>List Item</li> 
 
    <li>social</li> 
 
    <li>social</li> 
 
    </ul> 
 
</nav>

の残りの部分を作るために残されていること与えます
関連する問題