The width spreads across the whole page, i only want it to be as long as the content in the div. How can i solve this?

<style type="text/css">
.three {
display:block;
width:auto;
height:100px;
position:relative;
border:1px solid black;
}

.three a {
width:100%;
height:100%;
position:absolute;

}

</style>
echo "<div class='three'><a href='two'></a>test</div>";

Recommended Answers

Remove position:absolute

Jump to Post

All 3 Replies

Remove position:absolute

tried that and it doesn't work.

.three a {
width:100%;
height:100%;
position:absolute;
 
}

The question to ask here is: 100% of what? The answer: The browser window. Give .three a set width.

Regards
Arkinder

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.