Home > Back-end >  how to get the same line through different <p> Tags
how to get the same line through different <p> Tags

Time:08-09

am trying to use this css property "text-decoration: line-through;" on two different

Tags and without breaking the line

.pricereview {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.price {
  display: flex;
  align-items: end;
  text-decoration: line-through;
}

.prixunit {
  color: lightgrey;
  font-size: 20px;
  line-height: 20px;
}

.tnd {
  color: lightgrey;
  font-size: 13px;
  line-height: 26px;
  padding-left: 5px;
}
<div >
  <div >
    <p >560</p>
    <p >TND</p>
  </div>
</div>

This is the result that I want: Screenshot here

CodePudding user response:

I'd suggest using <span> tags and wrapping them in another element. Use a pseudo-element on the wrapper to make your "linebreak" span multiple elements of different font sizes and line heights without breaking.

.price {
  position: relative;
  display: inline-block;
}

.price::after {
  content: '';
  position: absolute;
  top: 45%;
  left: 0;
  width: 100%;
  border-bottom: solid 1px #000;
}

.prixunit {
  font-size: 20px;
  line-height: 20px;
}

.tnd {
  font-size: 13px;
  line-height: 26px;
  padding-left: 5px;
}
<p >
  <span >560</span>
  <span >TND</span>
</p>

CodePudding user response:

You cant do that with a p tag, cause its a block-level element https://developer.mozilla.org/en-US/docs/Web/HTML/Element/p

And it seems that in your case you want to make a line that is not cutting exactly in the middle of the word. If its your case, text-decoration: line-through dont will help you.

  • Related