Home > OS >  Is it possible to add padding to an anchor tag on line break?
Is it possible to add padding to an anchor tag on line break?

Time:11-07

I have the following link with a padding. On mobile screen, it has a line break. Would it be possible to add a padding on the end of the first and the start of the second line as well?

div {
  max-width: 30rem;
  margin: 5rem auto;
}
a {
  padding: 10px 20px;
  background: red;
  line-height: 200%;
}
<div>
  <a href="#">Read More: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt</a>
</div>

CodePudding user response:

Use box-decoration-break:

div {
  max-width: 30rem;
  margin: 5rem auto;
}

a {
  padding: 10px 20px;
  background: red;
  line-height: 200%;
  -webkit-box-decoration-break: clone;
          box-decoration-break: clone;
}
<div>
  <a href="#">Read More: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt</a>
</div>

  • Related