Anonoymous Anonoymous - 4 months ago 15
HTML Question

CSS display block not working with anchor links

I am trying to make a dropdown-menu. So for this purpose, I've created a div and some anchor links inside, but the

display: block;
is not working. The cursor is default & the anchor does not seem to be a link.

Here is my HTML:

<div id="custom-wrapper">
<ul>
<li><a href="#">View full profile</a></li>
<li><a href="#">Logout</a></li>
</ul>
</div>


The CSS:

div#custom-wrapper
{
width: 200px;
height: auto;
position: fixed;
right: 15px;
top: 38px;
border-radius: 6px;
background: #fff;
border: 1px solid lightgrey;
}
div#custom-wrapper ul
{
list-style-type: none;
}
div#custom-wrapper ul li
{
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
}
div#custom-wrapper ul li a
{
text-decoration: none;
display: block;
color: grey;
font-family: sans-serif;
border-bottom: 1px solid lightgrey;
}


What's wrong with my code?

Answer

Display block element works perfect, Just you need to remove padding and margin for ul element.

 /*** Default CSS Attributes ***/
 #custom-wrapper ul {
    margin: 0;
    padding: 0;
 }

 /*** Overwrite CSS Attributes ***/
 #custom-wrapper ul {
    margin: 0 !important;
    padding: 0 !important;
 }

div#custom-wrapper {
    width: 200px;
    height: auto;
    position: fixed;
    right: 15px;
    top: 38px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid lightgrey;
}
div#custom-wrapper ul {
    list-style-type: none;
    margin: 0;
    padding: 0;
}
div#custom-wrapper ul li {
    width: 100%;
    height: 50px;
    line-height: 50px;
    text-align: center;
   }
div#custom-wrapper ul li a {
    text-decoration: none;
    display: block;
    color: grey;
    font-family: sans-serif;
    border-bottom: 1px solid lightgrey;
}
<div id="custom-wrapper">
    <ul>
        <li><a href="#">View full profile</a></li>
        <li><a href="#">Logout</a></li>
    </ul>
</div> 

Comments