首页htmlchildren_parentCSS Layout - 如何位置元素在其父的右上角

CSS Layout - 如何位置元素在其父的右上角

我们想知道如何位置元素在其父的右上角。

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#myDiv {
  height: 50px;
  position: absolute;
  width: 300px;
  background-color: #DDD;
}

#myButton {
  cursor: pointer;
  margin-right: 10px;
  position: absolute;
  top: 0;
  right: 0;
}
</style>
</head>
<body>
  <div id="myDiv">
    <p>text</p>
    <span id="myButton">B</span>
  </div>
</body>
</html>