Reputation: 1260
How do you float a div to the top right hand corner of a page using css? I want to float the topcorner
div which is below:
<p><a href="login.php">Log in</a></p>
<div class="topcorner"><a href="home.php">Back to Home</a></div>
"Log in" goes in the left hand corner which it does at moment, but I want "Back to Home" to be placed in the other corner.
Upvotes: 79
Views: 271423
Reputation: 35
<style type="text/css">
.topcorner{
position:absolute;
top:10;
right:15;
}
</style>
You ca also use this in CSS external file.
Upvotes: 1
Reputation: 3156
the style is:
<style type="text/css">
.topcorner{
position:absolute;
top:0;
right:0;
}
</style>
hope it will work. Thanks
Upvotes: 156
Reputation: 5818
You can use css float
<div style='float: left;'><a href="login.php">Log in</a></div>
<div style='float: right;'><a href="home.php">Back to Home</a></div>
Have a look at this CSS Positioning
Upvotes: 6
Reputation: 1376
Try css:
.topcorner{
position:absolute;
top:10px;
right: 10px;
}
you can play with the top
and right
properties.
If you want to float the div
even when you scroll down, just change position:absolute;
to position:fixed;
.
Hope it helps.
Upvotes: 30