我看到你已经有了解释如何使用相对和绝对定位的答案,但同时我创建了一个 JS 小提琴 :)
HTML:
<div id="box">
<div id="icon">
|>
</div>
Contents of the box
</div>
CSS:
#box {
position: relative;
width: 200px;
height: 200px;
padding: 10px;
margin: 100px;
background-color: white;
}
#icon {
background-color: green;
color: white;
padding: 10px;
width: 20px;
height: 20px;
position: absolute;
right: -20px;
top: -20px;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句