【发布时间】:2018-01-27 14:50:14
【问题描述】:
将相对 div 中的固定 div 向右对齐,同时仍保留继承的 max-width 的最佳方法是什么?
更新(2018 年 1 月 24 日):我已经用解决方案回答了这个问题。见here。
请参阅以下 sn-p 以获得更多参考:
body {
margin: 0;
padding: 0;
border: 0;
}
.container {
width: 100%;
}
.max-width {
margin: 0 auto;
max-width: 500px;
height: 1000px;
position: relative;
box-sizing: border-box;
background-color: lightgrey;
}
.box {
max-width: inherit;
width: 20%;
height: 20px;
position: fixed;
background: blue;
float: right;
color: white;
text-align: center;
right: 0;
}
<div class="container">
<div class="max-width">
<div class="box">fix to right?</div>
</div>
</div>
【问题讨论】:
标签: html css css-position positioning