我正在尝试在可折叠主体内添加一个固定 Action 按钮。但在 html 页面中,它总是出现在页面的右下角,而不是在可折叠的内部。如何让 btn 留在体内?
https://codepen.io/rils/pen/qpOoeJ
<div style="padding-left: 500px" id="rView">
<ul class="collapsible" data-collapsible="accordion" id="reg_view">
<li>
<div class="collapsible-header">IPC > PS xxxx </div>
<div class="collapsible-body">
<div class="row">
<div class="input-field col s1 tooltipped " data-position="bottom" data-delay="50"
data-tooltip="I am a tooltip">
<input id="first_name" type="text" value="00" class="validate">
<label for="first_name">31-21</label>
</div>
<div class="input-field col s1">
<input id="first_name" type="text" value="01" class="validate">
<label for="first_name">20-8</label>
</div>
<div class="input-field col s1">
<input id="first_name" type="text" value="10" class="validate">
<label for="first_name">7-0</label>
</div>
<div class="input-field col s4">
<input id="first_name" type="text" value="0x11002200" class="validate">
<label for="first_name">0x40023ff8</label>
</div>
<div class="fixed-action-btn horizontal click-to-toggle" style="position: absolute">
<a class="btn-floating btn-large red">
<i class="material-icons">menu</i>
</a>
<ul>
<li><a class="btn-floating red"><i class="material-icons">insert_chart</i></a></li>
<li><a class="btn-floating yellow darken-1"><i
class="material-icons">format_quote</i></a></li>
<li><a class="btn-floating green"><i class="material-icons">publish</i></a></li>
<li><a class="btn-floating blue"><i class="material-icons">attach_file</i></a></li>
</ul>
</div>
</div>
<div class="divider"></div>
<table>
<thead>
<tr>
<th>FIELD</th>
<th>DESC</th>
<th>RW</th>
<th>DEFAULT VALUE</th>
</tr>
</thead>
<tbody>
<tr>
<td>0-7</td>
<td>ID</td>
<td>RW</td>
<td>1 INTERFACE</td>
</tr>
<tr>
<td>8-21</td>
<td>ID</td>
<td>RW</td>
<td>2 INTERFACE</td>
</tr>
<tr>
<td>22-31</td>
<td>ID</td>
<td>RW</td>
<td>3 INTERFACE</td>
</tr>
</tbody>
</table>
</div>
</li>
</ul>
</div>
-
position:fixed
将元素放在文档流之外 relative到最近的视口(viewport)。默认情况下,这将是 <body>
.
-
position:absolute
会将元素放在文档流之外相对于最近定位的祖先。那将是最近的祖先集合 position
, 除了 static
(这是默认的)。
最后,请给出您的 <button>
position:absolute
和你的 <ul>
position:relative;
我是一名优秀的程序员,十分优秀!