Home > OS >  How can I make a tag with an overall div selectable (parent div)
How can I make a tag with an overall div selectable (parent div)

Time:04-05

I have a some listing with some child a tag. But the a tag only working the particular element. I want to make overall div will selectable. Here is the sample code

So I want to make the below a tag with select all parents using css. I can't change the HTML structure

<div >
   <div >
      <a href="https://www.google.com/">element</a>
   </div>
</div>

CodePudding user response:

If I understand your question. You can use the before method on CSS. Please check the below CSS. So it will cover the parent div

.parent-2 > a:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
}

.parent-1 {
    position: relative;
}
  • Related