1

I've this code

.parent {
    width:100px;
    height:100%;
    background: green;
}

.parent a {
    display:block;
    width:100%;
    height:100%;
}
<div class="parent">
    <h3>test</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic asperiores expedita rerum quos ullam qui saepe. Quas quasi dolorum quibusdam deserunt voluptas dolorem tenetur! Quam explicabo laboriosam quaerat iure ipsum.</p>
    <a href="#"></a>
</div>

I want my link to display fully into its container (which is .parent)

Have the div clickable with this link.

Corentin Branquet
  • 1,556
  • 3
  • 17
  • 29

3 Answers3

3

I'm not sure I understand, but is this what you want?

.parent {
  width:100px;
  height:100%;
  background: green;
}

.parent a {
  display:block;
  position:absolute;
  top:0;
  left:0;
  width:inherit;
  height:inherit;
}
<div class="parent">
    <h3>test</h3>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Hic asperiores expedita rerum quos ullam qui saepe. Quas quasi dolorum quibusdam deserunt voluptas dolorem tenetur! Quam explicabo laboriosam quaerat iure ipsum.</p>
    <a href="#"></a>
</div>
jaunt
  • 4,978
  • 4
  • 33
  • 54
2

Try this:

.parent {
  width: 100px;
  height: 100%;
  background: green;
  position: relative;
}

.parent a {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  left: 0;
}

It should do the trick quite nicely if you don't want to wrap your div in an anchor tag. Here's an example.

David Mann
  • 2,074
  • 1
  • 17
  • 17
-1

have to write a div inside the a tag.

    <a href="#"><div class="parent"> <h3>test</h3> <p>Lorem ipsum dolor sit   amet, consectetur adipisicing elit. Hic asperiores expedita rerum quos ullam qui saepe. Quas quasi dolorum quibusdam deserunt voluptas dolorem tenetur! Quam explicabo laboriosam quaerat iure ipsum.</p> <a href="#"></a> </div> </a>
ItzMe_Ezhil
  • 1,276
  • 2
  • 11
  • 22
  • slight correction - you can't have nested anchor elements - but prefectly valid. Obviously the person who downvoted this doesn't know correct HTML syntax. –  Jun 24 '15 at 12:52