Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make a div to locate at top corner of another div?

Tags:

html

css

Hi i am planning to make a div to place at the top right corner of another div

.another
{
   position:fixed;
   padding:09px;
   margin:auto;
   left:25%;
   width:auto;
   height:auto;
   background:#ffffff;
   z-index:999999;
}
.topcorner
{
   float:right;
   position:fixed;
   left:25%;
   z-index:99999999;
}

this is my html

<div class="another">
    <div class="topcorner">
        i am at top right corner
    </div>
    here is some other content
</div>

How to make topcorner div to place it in top right cornerenter image description here

like image 724
sun Avatar asked Jan 21 '26 18:01

sun


2 Answers

Use position:relative to parent div and absolute to child div

.another{
    position:relative;
    border:blue solid 1px;
    height:200px;
    background:#ffffff;
}
.topcorner{
    background:red;
    width:30px;
    height:30px;
    position:absolute;
    top:0;
    right:0;;
}

DEMO

like image 178
Sowmya Avatar answered Jan 23 '26 06:01

Sowmya


try this,

.another
{
    position:relative;
    padding:09px;
    margin:auto;
    width:auto;
    height:200px;
    background:#eee;
    z-index:999999;
}
.topcorner
{
    position:absolute;
    top:0;
    right:0;
    z-index:99999999;
    width:100px;
    height:auto;
    background:yellow;
}

jsFiddle File

like image 33
Roy Sonasish Avatar answered Jan 23 '26 08:01

Roy Sonasish



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!