Search code examples
htmlcsstwitter-bootstrapmaterialize

remove white space aside the dropdown menu


I just wanted to copy some dropdown menu to other site of mine. but it seems i did something wrong, so all of my dropdown items have some white space aside them. (like the picture) white space side the dropdown items

but in the first site i developed the code, this problem did not exist! (example) example of source code dropdown item

actually i mixed bootstrap and materialize to form the code (and i know this is a bad idea, but it worked last time for me). I just don't know what to do, to remove the gap! and this is part of my code: `

<head>
   <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet"
          integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
    <!--Import materialize.css-->
    <link type="text/css" rel="stylesheet" href="{% static 'petrobavar/css/materialize.min.css' %} "
          media="screen,projection"/>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<nav class="mb-3">
    <div class="nav-wrapper blue-grey darken-1 amber-text darken-text-5" style="font-family: IRANSansWeb">
        <a href="#" data-target="mobile-demo" class="right sidenav-trigger"><i class="material-icons">menu</i></a>
        <a href="{% url 'petrobavar:home' %}" class="left hide-on-large-only"><img
                src="{% static 'petrobavar/petrologo.png' %}" style="width: 5rem"></a>
        <ul id="nav-mobile" class="right hide-on-med-and-down">
            <li class="tab dropdown-trigger " data-target="dropdown6" style="text-shadow: 0 2px 5px rgba(0,0,0,.5);"><a href="#">ارتباط با
                ما</a></li>
</ul>
<ul id="dropdown6" class="dropdown-content center-align" style="font-family: IRANSansWeb">
    <li><a href="{% url 'petrobavar:contact' %}" class="center-align">آدرس و تلفن های تماس</a></li>
</ul>
<style>
/* Dropdown list color */
.dropdown-content li > a, .dropdown-content li > span {
    background-color: #546e7a;
    margin: 0;
    border: 0;
    width: 100% !important;

}</style>

`


Solution

  • Can you please just add

    padding: 0;
    width: auto !important;


    in .dropdown-content class in CSS file as below:

    We have added padding and width in last line.

    .dropdown-content {
        background-color: #fff;
        margin: 0;
        display: none;
        min-width: 100px;
        overflow-y: auto;
        opacity: 0;
        position: absolute;
        left: 0;
        top: 0;
        z-index: 9999;
        -webkit-transform-origin: 0 0;
        transform-origin: 0 0;
        padding: 0;
        width: auto !important;
    }

    Please try and let me know.