luchonacho
luchonacho

Reputation: 7167

Cannot remove space before and after <ul> list CSS

I have some text, and then this section:

<hr/>
<div class="older-posts">
<ul>
    <li><a href="/index2/">Older posts</a></li>
    <li><a href="/archive/">Archive</a></li>
</ul> 
</div>

This is my CSS:

.older-posts ul {
    list-style-type: none;    
    display: inline;
    text-align: center;
}

.older-posts li {
    justify-content: center;   
    width: 150px;
    height: 45px; 
    margin: auto;
    margin-top: 15px;
    border-style: solid;
    border-width: 1px;
    border-color: grey;
}

.older-posts li a {
    color: black;
    text-decoration: none;
}

.older-posts li:hover {
    color: lightcyan;
    background-color: darkslategray;
    -webkit-transition: all .2s ease-in-out;
    -moz-transition: all .2s ease-in-out;
    -o-transition: all .2s ease-in-out;
    transition: all .2s ease-in-out;      
}

Yet, after the line and after the boxes, I get a large space (see below), which cannot remove with margin, or padding, or line-height. I have run out of ideas. This must be trivial. Any idea?

enter image description here

Upvotes: 0

Views: 569

Answers (1)

Nimish
Nimish

Reputation: 1016

Try this. :)

.older-posts ul {
    list-style-type: none;    
    text-align: center;
}

.older-posts li {
    justify-content: center;   
    width: 150px;
    height: 45px; 
    margin: auto;
    margin-top: 15px;
    border-style: solid;
    border-width: 1px;
    border-color: grey;
}

.older-posts li a {
    color: black;
    text-decoration: none;
}

.older-posts li:hover {
    color: lightcyan;
    background-color: darkslategray;
    -webkit-transition: all .2s ease-in-out;
    -moz-transition: all .2s ease-in-out;
    -o-transition: all .2s ease-in-out;
    transition: all .2s ease-in-out;      
}
<hr/>
<div class="older-posts">
<ul>
    <li><a href="/index2/">Older posts</a></li>
    <li><a href="/archive/">Archive</a></li>
</ul> 
</div>

Upvotes: 1

Related Questions