使用CSS3实现的player播放按钮
2014-08-15 11:42
309 查看
完成的效果如下
查看效果并下载
Step 1:先了解border的原理:
Step 2:HTML代码结构
Html代码
<section class="playContainer">
<li class="playBtn">
<a href="#" title="start">Start</a>
</li>
<li class="pauseBtn">
<a href="#" title="pause">Pause</a>
</li>
<li class="stopBtn">
<a href="#" title="stop">Stop</a>
</li>
<li class="forwardBtn playBtn">
<a href="#" title="forward">Forward</a>
<a href="#" title="forward">Forward</a>
</li>
<li class="rewindBtn">
<a href="#" title="rewind">Rewind</a>
<a href="#" title="rewind">Rewind</a>
</li>
<li class="ejectBtn">
<a href="#" class="arrow">Eject</a>
<a href="#" class="dash">Eject</a>
</li>
</section>
Step 3:画背景圆,position:relative
Css代码
.playContainer li { position: relative; float: left; border: 25px solid #404040; color: #404040; height: 0; width:0; -webkit-border-radius: 100%; -moz-border-radius: 100%; -o-border-radius: 100%; border-radius: 100%; margin: 0 20px; }
Step 4:画stop按钮,要让按钮居中。
按钮相对外层圆圈绝对定位,从圆圈的中心开始,所以要调整top和left值
stop按钮边长14px,相对原点需要向上、向左移动7个像素,居中。
全部的CSS如下:
Css代码
.playContainer { position: relative; float: left; background: rgba(0, 0, 0, 0.8); padding: 20px; }
.playContainer li { position: relative; float: left; border: 25px solid #404040; color: #404040; height: 0; width:0; -webkit-border-radius: 100%; -moz-border-radius: 100%; -o-border-radius: 100%; border-radius: 100%; margin: 0 20px; }
.playContainer a { border-style: solid; text-indent: -9999px; position: absolute; top: -8px; left: -3px; }
.playBtn a { border-color: transparent transparent transparent #fff; border-width: 8px 0 8px 12px; width: 0; height: 0; }
.pauseBtn a { border-color: transparent white; border-width: 0 6px; height: 15px; width: 6px; left: -9px; }
.stopBtn a { border: 7px solid #fff; height: 0; width: 0; left: -7px; top: -7px;}
.forwardBtn a { border-left-width: 8px; left: 1px; }
.forwardBtn a:first-child { margin-left: -7px; }
.rewindBtn a { border-width: 8px 8px 8px 0; border-color: transparent #fff transparent transparent; width: 0; height: 0; }
.rewindBtn a:first-child { margin-left: -7px; }
.ejectBtn a.arrow { border-width: 0 8px 8px 8px; border-color: transparent transparent #fff transparent; top:-26px; left:-8px; }
ectBtn a.dash { border-width: 0 0 4px; border-color: transparent transparent #fff; height: 0; width:16px; left: -8px; top: 4px; }
查看效果并下载
Step 1:先了解border的原理:
Step 2:HTML代码结构
Html代码
<section class="playContainer">
<li class="playBtn">
<a href="#" title="start">Start</a>
</li>
<li class="pauseBtn">
<a href="#" title="pause">Pause</a>
</li>
<li class="stopBtn">
<a href="#" title="stop">Stop</a>
</li>
<li class="forwardBtn playBtn">
<a href="#" title="forward">Forward</a>
<a href="#" title="forward">Forward</a>
</li>
<li class="rewindBtn">
<a href="#" title="rewind">Rewind</a>
<a href="#" title="rewind">Rewind</a>
</li>
<li class="ejectBtn">
<a href="#" class="arrow">Eject</a>
<a href="#" class="dash">Eject</a>
</li>
</section>
Step 3:画背景圆,position:relative
Css代码
.playContainer li { position: relative; float: left; border: 25px solid #404040; color: #404040; height: 0; width:0; -webkit-border-radius: 100%; -moz-border-radius: 100%; -o-border-radius: 100%; border-radius: 100%; margin: 0 20px; }
Step 4:画stop按钮,要让按钮居中。
按钮相对外层圆圈绝对定位,从圆圈的中心开始,所以要调整top和left值
stop按钮边长14px,相对原点需要向上、向左移动7个像素,居中。
全部的CSS如下:
Css代码
.playContainer { position: relative; float: left; background: rgba(0, 0, 0, 0.8); padding: 20px; }
.playContainer li { position: relative; float: left; border: 25px solid #404040; color: #404040; height: 0; width:0; -webkit-border-radius: 100%; -moz-border-radius: 100%; -o-border-radius: 100%; border-radius: 100%; margin: 0 20px; }
.playContainer a { border-style: solid; text-indent: -9999px; position: absolute; top: -8px; left: -3px; }
.playBtn a { border-color: transparent transparent transparent #fff; border-width: 8px 0 8px 12px; width: 0; height: 0; }
.pauseBtn a { border-color: transparent white; border-width: 0 6px; height: 15px; width: 6px; left: -9px; }
.stopBtn a { border: 7px solid #fff; height: 0; width: 0; left: -7px; top: -7px;}
.forwardBtn a { border-left-width: 8px; left: 1px; }
.forwardBtn a:first-child { margin-left: -7px; }
.rewindBtn a { border-width: 8px 8px 8px 0; border-color: transparent #fff transparent transparent; width: 0; height: 0; }
.rewindBtn a:first-child { margin-left: -7px; }
.ejectBtn a.arrow { border-width: 0 8px 8px 8px; border-color: transparent transparent #fff transparent; top:-26px; left:-8px; }
ectBtn a.dash { border-width: 0 0 4px; border-color: transparent transparent #fff; height: 0; width:16px; left: -8px; top: 4px; }
相关文章推荐
- CSS3实现的player播放按钮
- 冒泡动画按钮的简单实现(使用CSS3)
- 无需图片,使用CSS3实现圆角按钮[转]
- 在触屏上使用CSS3为按钮实现激活效果
- Android视频播放框架Vitamio集成及使用MediaPlayer+SurfaceView、VideoView+MediaController实现播放网络视频
- 使用SurfaceView+MediaPlayer+SeekBar实现视频播放
- 使用jQuery和CSS3实现的“加载中”效果按钮 极客标签 - 做最棒的极客知识分享平台
- Android 使用VDPlayerSDK组件实现播放视频(二)
- [HTML5-SVG]使用raphaeljs:代替css3实现qq空间关闭按钮旋转特效
- 练习使用css3实现3d按钮
- 无需图片,使用CSS3实现圆角按钮[转]
- 本地音频播放,使用AVFoundation.framework中的AVAudioPlayer来实现
- 使用IjkMediaPlayer结合surfaceView播放视频,自己写的播放和暂停按钮(四)
- 使用CSS3实现按钮特效
- Android 使用VDPlayerSDK组件实现播放视频(一)
- CSS3实现的渐变按钮,在IE7、IE6下的滤镜使用。
- 冒泡动画按钮的简单实现(使用CSS3)
- 使用伪元素实现播放按钮居中
- Visual Studio 2010 使用Windows Media Player控件实现播放音乐视频