其他分享
首页 > 其他分享> > css相对父元素 [爷爷级]

css相对父元素 [爷爷级]

作者:互联网

https://codepen.io/hellohy/pen/QMOyWR

 

<div class="l-container">
  <div class="container">    containercontainercontainercontainercontainercontainercontainercontainercontainercontainercontainercontainer
    <button>Hello!</button>
  </div>
</div>
<style>

.l-container {
position: relative;
border: 1px solid yellow;
width: 200px;
}
.container {
border: 1px solid red;
width: 200px;
height: 200px;
overflow: auto;
}
button {
border: 1px solid #ccc;
cursor: pointer;
display: block;
margin: auto;
position: absolute;
bottom: 20px;
right: 10px;
}

</style>

  效果:

 

containercontainercontainercontainercontainercontainercontainercontainercontainercontainercontainercontainer

标签:container,solid,元素,爷爷,width,1px,border,css,200px
来源: https://www.cnblogs.com/chinasoft/p/16347048.html