2017-10-05 8 views
1

Je suis un ul dans un div (left-nav-bar). J'essaye d'obtenir le ul pour s'étendre à travers le div entier quand l'utilisateur le survole, mais il y a des espaces générés avant chaque li et je ne sais pas pourquoi.Liste non ordonnée ne couvre pas entière de div

enter image description here

J'ai essayé:

.nav-container ul{ 
    width: 100%; 
} 

qui permet ul d'étendre au-delà du texte, mais ne traite pas les espaces blancs.

Voici un violon: https://jsfiddle.net/ytynqhmj/

Répondre

1

Par défaut prennent élément ulpadding-left: 60px; actualisateurs avec 0px pour résoudre ce problème. Vérifiez extrait mis à jour ci-dessous ..

html, 
 
body { 
 
    height: 100%; 
 
    background-color: #333; 
 
} 
 

 
body { 
 
    background-color: #333; 
 
    text-align: center; 
 
    text-shadow: 0 .05rem .1rem rgba(0, 0, 0, .5); 
 
    margin: 0; 
 
    font-family: "Helvetica Neue", Arial, sans-serif; 
 
    font-size: 1rem; 
 
    font-weight: 400; 
 
    line-height: 1.5; 
 
    display: block; 
 
} 
 

 

 
/** CONTAINER DIVS **/ 
 

 
.site-wrapper { 
 
    display: table; 
 
    width: 100%; 
 
    height: 100%; 
 
    min-height: 100%; 
 
} 
 

 
.site-wrapper-inner { 
 
    display: table-cell; 
 
    vertical-align: top; 
 
    overflow: auto; 
 
} 
 

 
.logo-holder { 
 
    height: 150px; 
 
    text-align: center; 
 
    border: 1px solid black; 
 
} 
 

 
.logo-holder h3 { 
 
    line-height: 150px; 
 
} 
 

 
.nav-container { 
 
    width: 300px; 
 
    float: left; 
 
    background-color: #fff; 
 
    height: 100%; 
 
} 
 

 
.nav-container a { 
 
    text-align: left; 
 
    padding: 5px; 
 
    color: #333; 
 
} 
 

 
.nav-container ul { 
 
    width: 100%; 
 
    padding: 0px; 
 
} 
 

 
.nav-container ul li { 
 
    list-style-type: none; 
 
    width: 100%; 
 
} 
 

 
.nav-container li:hover { 
 
    background-color: #333; 
 
}
<div class="site-wrapper"> 
 
    <div class="site-wrapper-inner"> 
 
     <div class="nav-container"> 
 
      <div class="logo-holder"> 
 
       <h3>Logo</h3></div> 
 
      <nav class="nav left-nav-bar"> 
 
       <ul> 
 
        <li><a class="nav-link active" href="">Home</a></li> 
 
        <li><a class="nav-link" href="">Blog</a></li> 
 
        <li><a class="nav-link" href="">Store</a></li> 
 
        <li><a class="nav-link" href="">Contact</a></li> 
 
       </ul> 
 
      </nav> 
 
     </div> 
 
    </div> 
 
</div>

1

Il suffit de retirer le rembourrage gauche par défaut pour ul comme ceci:

.nav-container ul{ 
    padding-left:0;<----Added 
    //more code.... 
} 

Demo