纯CSS3实现苹果iOS 7风格进度条

还记得iOS 7的“颠覆性”扁平化设计吗?其中的各种扁平化UI界面都让我们为之惊叹,其中的进度条更是让人喜欢 的不得了。今天就给大家分享一个用CSS3制作的iOS7进度条小教程,这是一款非常优秀的UI交互设计。下面就来看看演示效果以及实现方式吧!

HTML结构代码

首先设计HTML的基本结构,大概如下:

<div class="container">
  <h1 class="text-center">iOS 7进度条</h1>
  <div class="progress">
    <div class="progress-bar">
      <div class="progress-shadow"></div>
    </div>
  </div>
</div>

  

CSS3样式代码

结构写好后,那么我们接下来就是根据iOS的UI设计风格来编写css样式。仔细研究下界面元素,我们可以使用CSS3的渐变属性linear-gradient来完成彩色的横条,除此之外,我们可以注意到横条的下方有一条倾斜的投影,这个细节处理非常好,让整体看起来更加立体、更具美感!但这投影实现比较特殊,我们就不采用box-shadow来制作,我们还是采用渐变属性来完成,然后通过transform来修改其角度,从而达到我们需要的效果。好了,具体全部css代码如下,大家可以参考一下。

<style>
/* www.datouwang.com */
/* VARIABLES */
/* COLORS */
/* BASE */
html, body {
	height: 100%;
}
body {
	background-color: #f5f7f9;
	color: #6c6c6c;
	font: 300 1em/1.5em "Helvetica Neue", sans-serif;
	margin: 0;
	position: relative;
}
h1 {
	font-size: 2.25em;
	font-weight: 100;
	line-height: 1.2em;
	margin: 0 0 1.5em;
}
/* HELPERS */
.text-center {
	text-align: center;
}
/* GRID */
.container {
	left: 50%;
	position: absolute;
	top: 50%;
	transform: translate(-50%, -50%);
}
/* PROGRESS */
.progress {
	background-color: #e5e9eb;
	height: 0.25em;
	position: relative;
	width: 24em;
}
.progress-bar {
	animation-duration: 3s;
	animation-name: width;
	background-image: linear-gradient(to right, #4cd964, #5ac8fa, #007aff, #34aadc, #5856d6, #ff2d55);
	background-size: 24em 0.25em;
	height: 100%;
	position: relative;
}
.progress-shadow {
	background-image: linear-gradient(to bottom, #eaecee, transparent);
	height: 4em;
	position: absolute;
	top: 100%;
	transform: skew(45deg);
	transform-origin: 0 0;
	width: 100%;
}

/* ANIMATIONS */
@keyframes width {
       0%, 100% {
       transition-timing-function: cubic-bezier(1, 0, 0.65, 0.85);
  }
  0% {
       width: 0;
  }
   100% {
      width: 100%;
  }
}
</style>

  

添加CSS3无前缀脚本prefixfree.js

到这里之后,进度条基本已经制作完成了,看着界面是不是有很熟悉的感觉。但是如果细心的你一定会发现,上面的css3代码都没有添加浏览器兼容的前缀。这样子就会导致在不同浏览器下会没有动画效果。这个时候我们可以使用prefixfree.js脚本,这个脚本会自动补上需要的前缀,让各种浏览器支持该CSS3属性。(当然,如果你手动添加所有css3前缀,那么就不需要引入这个插件)

<script src="http://www.datouwang.com/uploads/demo/jiaoben/201501/jiaoben467/js/prefixfree.min.js"></script>

  

时间: 2024-07-30 13:25:32

纯CSS3实现苹果iOS 7风格进度条的相关文章

Xamarin iOS教程之进度条和滚动视图

Xamarin iOS教程之进度条和滚动视图 Xamarin iOS 进度条 进度条可以看到每一项任务现在的状态.例如在下载的应用程序中有进度条,用户可以很方便的看到当前程序下载了多少,还剩下多少.QQ音乐播放器中也使用到了进度条,它可以让用户看到当前音乐播放了多少,还剩多少等.在Xamarin.iOS中也提供实现进度条的类,即UIProgressView. [示例2-23]以下将实现进度条加载的效果.具体步骤如下: (1)创建一个Single View Application类型的工程,命名为

纯css使用线性渐变实现滚动进度条

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" con

CSS3和js谷歌Material Design进度条插件

mprogress是一款使用纯JS和CSS3制作的谷歌Material Design样式的进度条插件.该插件没有依赖任何外部库.它可以制作4种类型的进度条动画,使用扁平化设计,非常时尚. 该进度条插件有4种类型的动画方式,分别是:确定型.缓冲型.不确定型和查询确定型. mprogress是移动设备优先的js插件,?所有类型的进度条都可以工作在Chrome 和 Firefox浏览器上.Determinate类型的进度条可以工作在所有浏览器上. 在线演示:http://www.htmleaf.com

iOS 贝赛尔 圆形进度条

UIBezierPath *aPth = [UIBezierPath bezierPathWithArcCenter:CGPointMake(55, 65.f) radius:50.f startAngle:-M_PI_2 endAngle:M_PI_2 clockwise:YES]; aPth.lineWidth = 5.0f; aPth.lineCapStyle = kCGLineCapRound; aPth.lineJoinStyle = kCGLineJoinRound; [[UICol

iOS-Quart2D 进度条

// // HMProgressView.h // 进度条 // // Created by YaguangZhu on 15/9/9. // Copyright (c) 2015年 YaguangZhu. All rights reserved. // #import <UIKit/UIKit.h> @interface HMProgressView : UIView @property(nonatomic,assign)CGFloat progress; @end // // HMProg

ios 画圆环进度条

#import <UIKit/UIKit.h> @interface SNCircleProgressView : UIView /** * 进度值0-1.0之间 */ @property (nonatomic,assign)CGFloat progressValue; /** * 边宽 */ @property(nonatomic,assign) CGFloat progressStrokeWidth; /** * 进度条颜色 */ @property(nonatomic,strong)UI

仿IOS圆形下载进度条

/** * Created by C058 on 2016/5/25. */ public class MyHoriztalProgressBar extends ProgressBar { private static final int DEFAULT_REACH_COLOR = 0xff24F569; private static final int DEFAULT_UNREACH_COLOR = 0xffC0C0C0; private static final int DEFAULT_R

xamarin.ios 实现圆形进度条

using System; using UIKit; using System.Drawing; using CoreAnimation; namespace PMM { public class ProgressCircleView : UIView { protected CAShapeLayer _progressCircle; protected CAShapeLayer PageGrayCircle; public override CoreGraphics.CGRect Bounds

CSS3 中的按钮效果与进度条

效果如图 CSS <style type="text/css">    .add-btn,.min-btn{        width:140px;        height:140px;        border-radius:8px;        background:#ccd0d4;        position:relative;        display:inline-block;        box-shadow:inset 0 0 35px 5p