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

Why my link is jammed up against top border in browser?

Why my link is jammed up against top border in browser?

box-sizing: border-box; don’t change anything

a {
  background-color: #405cf5;
  color: white;
  border-radius: 6px;
  font-size: 1.2em;
  padding: 15px 25px;
  text-decoration: none;
  margin-top: 20px;
}
<a href="/posts">Back</a>

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 :

Margins don’t apply to inline elements, and with padding only the left and right property will push other elements. Change your link (inline by default) to have a display of inline-block and it will move according to the margin and padding you gave it:

a {
  background-color: #405cf5;
  color: white;
  border-radius: 6px;
  font-size: 1.2em;
  padding: 15px 25px;
  text-decoration: none;
  margin-top: 20px;
  display:inline-block;
}
<a href="/posts">Back</a>
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