CSS左上角的CSS绝对位置位于父级的右上角

Ash*_*win 5 html css

我想绝对定位div,使得div的左上角附加到父div的右上角(相对定位).

你有什么解决方法吗?

这是一个小提琴开始

mad*_*eye 17

我想你想要这样的东西

http://jsfiddle.net/kdcmq/

<div id = "parent">
     <div id = "child"></div>
</div>


#parent {
    position: relative;
    width: 500px;
    height: 500px;
    background: red;
    display: block; /* fix for opera and ff */
}

#child {
    position: absolute;
    width: 100px;
    height: 100px;
    background: blue;
    top: 0;
    left: 100%; /* this line of code will sort things out for you :) */
}
Run Code Online (Sandbox Code Playgroud)