开发者

fixing one div to second div top right corner with css

开发者 https://www.devze.com 2023-01-02 14:44 出处:网络
I have the following divs <div id=\"outer\"><img src=\"myimgpath\"><div id=\"name\">Username</div></div>

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 oute开发者_如何转开发r div's top right corner?


Try something like this:

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

#name {
  position: absolute;
  right: 0;
}


<div id="outer" style="position:relative">
  <img src="myimgpath">
  <div id="name" style="position:absolute; top:0px; right:0px;">Username</div>
</div> 


add float:right; to the inner div

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号