Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Cant vertically center text inside div

I just can’t vertically center this text inside my div (red background), I’ve tried everything but nothing is working, please help! I can’t even get my text inside the div whithout using margins/padding for some reason.
I’ve tried using div, span, p and h1 for the text but nothing worked =(

enter image description here

THIS IS MY CODE:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

        <div class="headerdiv">
            <div class="backtotop">
                <a class="material-symbols-outlined" href="#" >arrow_upward</a>
                <a class="backtotoptext" href="#">Voltar ao topo</a>
              </div>
        <div class="githubcontainer">
            <a href="https://github.com/maruan-achkar/javascript_exercicios" target="_blank" class="githublink" >//GITHUB LINK</a>
        </div>
        <div class="dropdown">
            <div class="dropdown-title-container">
            <p class="dropdown-title">MENU</p>
            </div>
            <div class="dropdown-content">
              <a class="dropdowna" href="#trocarvariaveis">// Trocar Variaveis<br></a>
              <a class="dropdowna" href="#celsiusparafarenheit">// Celsius para Farenheit<br></a>
              <a class="dropdowna" href="#farenheitparacelsius">// Farenheit para Celsius<br></a>
              <a class="dropdowna" href="#areacirculo">// Area Circulo<br></a>
              <a class="dropdowna" href="#parouimpar">// Par ou Impar<br></a>
              <a class="dropdowna" href="#intervalo">// Intervalo entre numeros<br></a>
              <a class="dropdowna" href="#intervalovetor">// Intervalo entre maior e menor de vetor<br></a>
              <a class="dropdowna" href="#maiormenor">// Maior e menor numero<br></a>
              <a class="dropdowna" href="#paisagemouretrato">// Paisagem ou retrato<br></a>  
              <a class="dropdowna" href="#fizzbuzz">// Fizz ou Buzz<br></a>
              <a class="dropdowna" href="#stringobject">// String do objeto<br></a>
              <a class="dropdowna" href="#parimparlimite">// Par ou impar ate limite<br></a>
            </div>
          </div>
        </div>
    </header>

--------------------------------------------CSS--------------------------------------------

.dropdown {
    float: left;
    background-color: #F6F7EB;
    height: 100%;
    width: 100px;
  }
  .dropdown-title-container{
    background-color: #DC3318;
    height: 100%;
    display: flex;
    justify-content: center;
  }
  .dropdown-title{
    font-family: Arial;
    font-weight: bolder;
    font-size: 1.75em;
    line-height: 100%;
  }
  .dropdown-content {
    display: none;
    position: absolute;
    top: 48px;
    background-color: #F6F7EB;
    padding-right: 15px;
    outline: solid black 3px;
    box-shadow: 0px 10px 15px black;
    border-radius: 0.1vw;
    font-size: 0.8em;
  }
  
  .dropdown:hover .dropdown-content {
    display: block;
  }
  .dropdowna{
    color: black;
    font-size: 1.75em;
    margin-left: 2vw;
    text-decoration: none;
  }```.sticky{
    position: fixed;
    top: 0;
    width: 100%;
    height: 45px;
    background-color: #DC3318;
    box-shadow: 0px 0px 5px rgb(0, 0, 0, 0.65);
}
.headerdiv{
    background-color: greenyellow;
    height: 100%;
    width: 100%;
}
.backtotop{
    font-weight: bolder;
    font-size: 0.75em;
    margin-right: 0;
    height: 100%;
    width: 160px;
    float: right;
    display: flex;
    align-items: center;
}
.backtotoptext{
    margin: auto;
    text-decoration: none;
    color: black;
    font-size: 1.55em;
    margin-right: 12px;
}
.material-symbols-outlined{
    text-decoration: none;
    margin-right: -30px;
    margin-bottom: 3px;
    color: black;
}
.backtotop:hover .backtotoptext{
    color: rgb(0, 132, 255);
}
.backtotop:hover .material-symbols-outlined{
    color: rgb(0, 132, 255);
}
.githubcontainer{
    width: 200px;
    height: 100%;
    float: right;
    margin-right: 40px;
    display: flex;
    align-items: center;
}
.githublink{
    color: black;
    margin: auto;
    font-size: 1.35em;
    text-decoration: none;
}
.githublink:hover{
    text-decoration: underline;
}

>Solution :

Just add align-items:center; to .dropdown-title-container, and the text will be aligned vertically.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading