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

How to stop any overlay(::before in this example) to cover the content of parent

I am using :: before as an overlay, but I face a problem here:
the Pseudo-Element("::before") cover all card including the content(texts)
but I just want to cover the background of card(parent) not the text
also,

/* left-to-right effect box */
.ltr-effect {
    position: relative;
}
.ltr-effect::before {
    content: "";
    display: block;
    position: absolute;
    top: 0px;
    left: 0px;
    width: 0%;
    height: 100%;
    background-color:rgba(215, 227, 250, 0.53);
    transition: width 0.5s;
}
.ltr-effect:hover::before {
    width: 100%;
}

/* card */
.service-content-box {
    text-align: center;
    border: 2px solid rgb(208, 228, 228);
    background-color: #22beff;
    border-radius: 10px;
    padding: 30px;
    font-size: 1.3em;
    width: calc(90%/3);
    margin-right: 5%;
    position: relative;
}
/* content of services */
.service-content-box .service-title {
    text-transform: capitalize;
    margin-bottom: 10px;
    font-size: 2em;
}
.service-content-box .service-desribtion {
    line-height: 30px;
}
.service-content-box a {
    margin: 7px 0px;
    text-decoration: none;
    text-transform: capitalize;
}
 <section class="services">
  <div class="services-content">
    <div class="service-content-box ltr-effect">
      <i class="fa fa-solid fa-book-open"></i>
      <h4 class="service-title mg-b-10">fast reading</h4>
      <p class="service-desribtion">
          Lorem ipsum dolor sit amet, consectetur adipisicing elit. A fugiat, ea et iure similique nesciunt Et accusantium                              magni
      </p>
      <a href="#" class="read-more">learn more</a>
    </div>
    <div class="clear"></div>
  </div><!-- /.services-content -->
    </section><!-- /.services -->

I can’t select any text because of this problem.

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 :

You coud set a position:relative; z-index:1; to elements in the card that you don’t wanna cover with the overlay.

You need z-index to make them came up front, and as you may already know, z-indexworks only with relative, fixed, and sticky position. That’s why I’m using that relative position.

/* left-to-right effect box */
.ltr-effect {
  position: relative;
}
.ltr-effect::before {
  content: "";
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  width: 0%;
  height: 100%;
  background-color: rgba(215, 227, 250, 0.53);
  transition: width 0.5s;
}
.ltr-effect:hover::before {
  width: 100%;
}

/* card */
.service-content-box {
  text-align: center;
  border: 2px solid rgb(208, 228, 228);
  background-color: #22beff;
  border-radius: 10px;
  padding: 30px;
  font-size: 1.3em;
  width: calc(90% / 3);
  margin-right: 5%;
  position: relative;
}
/* content of services */
.service-content-box .service-title {
  text-transform: capitalize;
  margin-bottom: 10px;
  font-size: 2em;
  position:relative;
  z-index:1;
}
.service-content-box .service-desribtion {
  line-height: 30px;
  position:relative;
  z-index:1;
}
.service-content-box a {
  margin: 7px 0px;
  text-decoration: none;
  text-transform: capitalize;
  position:relative;
  z-index:1;
}
<section class="services">
  <div class="services-content">
    <div class="service-content-box ltr-effect">
      <i class="fa fa-solid fa-book-open"></i>
      <h4 class="service-title mg-b-10">fast reading</h4>
      <p class="service-desribtion">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. A fugiat, ea et iure similique nesciunt Et accusantium magni
      </p>
      <a href="#" class="read-more">learn more</a>
    </div>
    <div class="clear"></div>
  </div>
</section>
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