Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fixing one div to second div top right corner with css

Tags:

html

css

I have the following divs

<div id="outer"><img src="myimgpath"><div id="name">Username</div></div>

How do I fix the inner div to the outer div's top right corner?

like image 343
Web Worm Avatar asked Dec 08 '22 03:12

Web Worm


2 Answers

Try something like this:

#outer {
  position: relative;
  overflow: hidden;
  height: 100px;
}

#name {
  position: absolute;
  right: 0;
}
like image 134
edl Avatar answered Jan 06 '23 15:01

edl


<div id="outer" style="position:relative">
  <img src="myimgpath">
  <div id="name" style="position:absolute; top:0px; right:0px;">Username</div>
</div> 
like image 29
John Hartsock Avatar answered Jan 06 '23 15:01

John Hartsock