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

Margin-top doesnt change position

i wanted to move a element up, i tried with margin-top, but it seems it doesnt work.

#nextquestion {
  margin-left: 80%;
  width: 15%;
  background-color: #333333;
  height: 40%;
  color: white;
  font-size: 20px;
  border: none;
  margin-top: 0.01%;
  display: inline-block;
}

#question1 {
  color: white;
  margin-left: 2.5%;
  font-size: 31px;
  margin-top: 5%;
}
<div style="background-color: #161624; width: 100%; height: 20%; vertical-align: bottom ; " d>
  <a id="question1" style="display: inline-block;">Question 1/X</a>
  <button id="nextquestion">Next Question</button>
</div>

I have added display: inline-block, but it didnt change anything.

enter image description here
Margin-top: -…, doesnt change a lot

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

>Solution :

That’s not the right way to do it in my opinion. Using negative margins is not a good practice. I would instead use flex to achieve it:

#question-container {
  background-color: #161624;
  display: flex;
  flex-direction: row;
  height: 20%;
  justify-content: space-between;
  padding: 3rem;
}

#nextquestion {
  width: 15%;
  min-width: 120px;
  background-color: #333333;
  color: white;
  font-size: 20px;
  border: none;
}

#question1 {
  color: white;
  font-size: 31px;
}
<div id="question-container">
  <a id="question1" style="display: inline-block;">Question 1/X</a>
  <button id="nextquestion">Next Question</button>
</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