Search code examples
htmlcssdropdown

Dropdown menu is to big


Hello so im trying to do dropdown menu by clicking on button but its elements are way to big , what im I doing wrong? I realy im like going insane, can you please help me in this art that is coding ? It doesnt have any problem just that its ugly edit: i have updated and posted full css code to see if u guys can help me

         html {
        background: #e6e9e9;
        background-image: linear-gradient(270deg, rgb(230, 233, 233) 0%, rgb(216, 221, 221) 100%);
        -webkit-font-smoothing: antialiased;
    }

    body {
        background: #fff;
        box-shadow: 0 0 2px rgba(0, 0, 0, 0.06);
        color: #545454;
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        font-size: 16px;
        line-height: 7.5;
        margin: 0 auto;
        padding: 2em 2em 4em;
    }

    .button {
      background-color: #4a7bb5;
      border: none;
      color: white;
      padding: 5px 32px;
      text-align: center;
      text-decoration: none;
      display: inline-block;
      font-family: cute;
      font-size: 32px;
    }
    .button:hover{
     box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
     background-color: #4a7bb5;
      border: none;
      color: white;
      padding: 5px 32px;
      text-align: center;
      text-decoration: none;
      display: inline-block;
      font-family: cute;
      font-size: 32px;
    }
    .dropdown {
      position: relative;
      display: inline-block;
    }

    .dropdown-content {
      display: none;
      position: absolute;
      background-color: #f1f1f1;
      min-width: 160px;
      box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
      z-index: 1;
    }

    .dropdown-content a {
      color: black;
      padding: 12px 16px;
      text-decoration: none;
      display: block;
    }

    .dropdown-content a:hover {background-color: #ddd;}

    .dropdown:hover .dropdown-content {display: block;}

    .dropdown:hover .dropbtn {background-color: #3e8e41;}






    p {
        font-size: 20px;
        font-weight: 500;
        color: #52d6ff;
    }

    h1, h2, h3, h4, h5, h6 {
        color: #237543;
        font-weight: 600;
        line-height: 0;
        font-size: 50px;

    }
    hr { display: block; height: 1px;
        border: 1; border-top: 1px solid #ccc;
        margin: 1em 0; padding: 0; }

    h2 {
        margin-top: 1.3em;
    }

    a {
        color: #0083e8;
    }

    b, strong {
        font-weight: 600;
    }

    samp {
        display: none;
    }

    img {

        background: transparent;

    }

    @keyframes colorize {
        0% {
            -webkit-filter: grayscale(100%);
            filter: grayscale(100%);
        }
        100% {
            -webkit-filter: grayscale(0%);
            filter: grayscale(0%);
        }
    }
    @font-face {
      font-family:cute;
      src: url(cute.ttf);
    }
    @font-face {
      font-family:opensans;
      src: url(opensans.ttf);
    }
 <HR size=2 style="color: aqua"></HR>
    <button class="button" onclick="mainpage();">Main Page</button>
    <div class="dropdown">
    <button class="button">Art</button>
    <div class="dropdown-content">
    <a href="#">Acrilic</a>
    <a href="#">Carvão</a>
    <a href="#">Paint</a>
    </div>
    </div>


Solution

  • Your <body> has a line-height: 7.5 style which is getting inherited by your dropdown's anchor tags.

    Either remove this style, or otherwise reset it at some point between your <body> and .dropdown-content a elements. For example:

    .dropdown {
        ...
        line-height: normal;
    }
    

    html {
            background: #e6e9e9;
            background-image: linear-gradient(270deg, rgb(230, 233, 233) 0%, rgb(216, 221, 221) 100%);
            -webkit-font-smoothing: antialiased;
        }
    
        body {
            background: #fff;
            box-shadow: 0 0 2px rgba(0, 0, 0, 0.06);
            color: #545454;
            font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
            font-size: 16px;
            line-height: 7.5;
            margin: 0 auto;
            padding: 2em 2em 4em;
        }
    
        .button {
          background-color: #4a7bb5;
          border: none;
          color: white;
          padding: 5px 32px;
          text-align: center;
          text-decoration: none;
          display: inline-block;
          font-family: cute;
          font-size: 32px;
        }
        .button:hover{
         box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24), 0 17px 50px 0 rgba(0,0,0,0.19);
         background-color: #4a7bb5;
          border: none;
          color: white;
          padding: 5px 32px;
          text-align: center;
          text-decoration: none;
          display: inline-block;
          font-family: cute;
          font-size: 32px;
        }
        .dropdown {
          position: relative;
          display: inline-block;
          line-height: normal;
        }
    
        .dropdown-content {
          display: none;
          position: absolute;
          background-color: #f1f1f1;
          min-width: 160px;
          box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
          z-index: 1;
        }
    
        .dropdown-content a {
          color: black;
          padding: 12px 16px;
          text-decoration: none;
          display: block;
        }
    
        .dropdown-content a:hover {background-color: #ddd;}
    
        .dropdown:hover .dropdown-content {display: block;}
    
        .dropdown:hover .dropbtn {background-color: #3e8e41;}
    
    
    
    
    
    
        p {
            font-size: 20px;
            font-weight: 500;
            color: #52d6ff;
        }
    
        h1, h2, h3, h4, h5, h6 {
            color: #237543;
            font-weight: 600;
            line-height: 0;
            font-size: 50px;
    
        }
        hr { display: block; height: 1px;
            border: 1; border-top: 1px solid #ccc;
            margin: 1em 0; padding: 0; }
    
        h2 {
            margin-top: 1.3em;
        }
    
        a {
            color: #0083e8;
        }
    
        b, strong {
            font-weight: 600;
        }
    
        samp {
            display: none;
        }
    
        img {
    
            background: transparent;
    
        }
    
        @keyframes colorize {
            0% {
                -webkit-filter: grayscale(100%);
                filter: grayscale(100%);
            }
            100% {
                -webkit-filter: grayscale(0%);
                filter: grayscale(0%);
            }
        }
        @font-face {
          font-family:cute;
          src: url(cute.ttf);
        }
        @font-face {
          font-family:opensans;
          src: url(opensans.ttf);
        }
    <HR size=2 style="color: aqua"></HR>
        <button class="button" onclick="mainpage();">Main Page</button>
        <div class="dropdown">
        <button class="button">Art</button>
        <div class="dropdown-content">
        <a href="#">Acrilic</a>
        <a href="#">Carvão</a>
        <a href="#">Paint</a>
        </div>
        </div>