我想创建一个自定义的音频播放器,带基本上是:如何使用CSS水平堆叠元素?
- 一个按钮,用于播放
- 一个灵活条,即自身适应玩家宽度
- 在一组按钮玩家的权利,即下载按钮等
对于两个第一部分我没有问题(见小提琴),但它是第二个按钮组我有麻烦。
我试着把这个组合放在float:right
,但是在这种情况下它会从玩家身上踢出来。然后,我试图将flexible
条设置为浮动属性,但在这种情况下,我必须指定其宽度,并且它变得不灵活。
这是我到目前为止有:
HTML:
<div class="player" style="width:500px">
<div class="group">
<a class="button" href="#"></a>
</div>
<div class="flexible">
<div class="bar"></div>
</div>
<div class="clear"></div>
</div>
CSS:
.player
{
height:24px;
background-color: #222222;
}
.player .group
{
float:left;
}
.player .group .button,
.player .group2 .button
{
display: inline-block;
width:24px;
height:24px;
background-color:#444444;
}
.player .group2
{
float:right;
}
.player .flexible
{
box-sizing:border-box;
overflow:hidden;
}
.player .flexible .bar
{
margin : 8px;
height : 8px;
background-color:#225599;
}
JSFiddle: https://jsfiddle.net/grh7sahq/3/
您有什么建议吗?
感谢
如果你有一个图像显示你想要达到的效果会很好 –