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

Add text in the middle of another div container

I have two div containers. One is for Text and another is for loader.
Right now both div containers are placed vertically one after another. But I would like to place the text in the center, that is overlying on top of "loader" container. So that the "loading" text comes in the middle of my preloader.

How do I do this?

Loading

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

#loader {
  margin: auto;
  border: 10px solid #f3f3f3;
  border-radius: 50%;
  border-top: 10px solid #003750;
  width: 100px;
  height: 100px;
  -webkit-animation: spin 2s linear infinite;
  /* Safari */
  animation: spin 2s linear infinite;
}


/* Safari */

@-webkit-keyframes spin {
  0% {
    -webkit-transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

#Text {
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
}
<div id="loader"></div>
<div id="Text">

  <p>
    <b>Loading</b>
  </p>

</div>

>Solution :

Just position absolute or wrap both in a container and flex that

#loader {
  margin: auto;
  border: 10px solid #f3f3f3;
  border-radius: 50%;
  border-top: 10px solid #003750;
  width: 100px;
  height: 100px;
  -webkit-animation: spin 2s linear infinite;
  /* Safari */
  animation: spin 2s linear infinite;
}


/* Safari */

@-webkit-keyframes spin {
  0% {
    -webkit-transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

#Text {
  position: absolute;
  top:40px;
  margin-left: 280px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
}
<div id="loader"></div>
<div id="Text">

  <p>
    <b>Loading</b>
  </p>

</div>
</div>
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