日志标签:css3

时尚的CSS3进度条

时间:2012年01月01日作者:愚人码头查看次数:2,721 views评论次数:9

时尚的CSS3进度条先看效果图,非常漂亮吧:

demo:http://www.css88.com/demo/css3-progress-bars/

英文原文:http://www.red-team-design.com/stylish-css3-progress-bars

HTML代码:
HTML代码比较简单

1
2
3
<div class="progress-bar blue stripes">
    <span style="width: 40%"></span>
</div>
  1. .progress-bar – 定义进度栏的常规样式。
  2. .blue – 定义进度条的风格,这里是蓝色的
  3. .stripes – 当前进度的动画类型。
  4. span – 填充进度条。内联设置的宽度,0%-100%,进度条的宽度。

CCS代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
.progress-bar {
background-color: #1a1a1a;
height: 25px;
padding: 5px;
width: 350px;
margin: 50px 0;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
-webkit-box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
box-shadow: 0 1px 5px #000 inset, 0 1px 0 #444;
}

.progress-bar span {
display: inline-block;
height: 25px;
width: 200px;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
-webkit-box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset;
-webkit-transition: width .4s ease-in-out;
-moz-transition: width .4s ease-in-out;
-ms-transition: width .4s ease-in-out;
-o-transition: width .4s ease-in-out;
transition: width .4s ease-in-out;
}

添加颜色,进度条风格:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
.blue span {
background-color: #34c2e3;
}

.orange span {
background-color: #fecf23;
background-image: -webkit-gradient(linear, left top, left bottom, from(#fecf23), to(#fd9215));
background-image: -webkit-linear-gradient(top, #fecf23, #fd9215);
background-image: -moz-linear-gradient(top, #fecf23, #fd9215);
background-image: -ms-linear-gradient(top, #fecf23, #fd9215);
background-image: -o-linear-gradient(top, #fecf23, #fd9215);
background-image: linear-gradient(top, #fecf23, #fd9215);
}

.green span {
background-color: #a5df41;
background-image: -webkit-gradient(linear, left top, left bottom, from(#a5df41), to(#4ca916));
background-image: -webkit-linear-gradient(top, #a5df41, #4ca916);
background-image: -moz-linear-gradient(top, #a5df41, #4ca916);
background-image: -ms-linear-gradient(top, #a5df41, #4ca916);
background-image: -o-linear-gradient(top, #a5df41, #4ca916);
background-image: linear-gradient(top, #a5df41, #4ca916);
}

条纹样式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
.stripes span {
-webkit-background-size: 30px 30px;
-moz-background-size: 30px 30px;
background-size: 30px 30px;
background-image: -webkit-gradient(linear, left top, right bottom,
color-stop(.25, rgba(255, 255, 255, .15)), color-stop(.25, transparent),
color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .15)),
color-stop(.75, rgba(255, 255, 255, .15)), color-stop(.75, transparent),
to(transparent));
background-image: -webkit-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
transparent 75%, transparent);
background-image: -moz-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
transparent 75%, transparent);
background-image: -ms-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
transparent 75%, transparent);
background-image: -o-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
transparent 75%, transparent);
background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
transparent 75%, transparent);

-webkit-animation: animate-stripes 3s linear infinite;
-moz-animation: animate-stripes 3s linear infinite;
}

@-webkit-keyframes animate-stripes {
0% {background-position: 0 0;} 100% {background-position: 60px 0;}
}

@-moz-keyframes animate-stripes {
0% {background-position: 0 0;} 100% {background-position: 60px 0;}
}


闪烁样式:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
.shine span {
position: relative;
}

.shine span::after {
content: '';
opacity: 0;
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: #fff;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
border-radius: 3px;

-webkit-animation: animate-shine 2s ease-out infinite;
-moz-animation: animate-shine 2s ease-out infinite;
}

@-webkit-keyframes animate-shine {
0% {opacity: 0; width: 0;}
50% {opacity: .5;}
100% {opacity: 0; width: 95%;}
}

@-moz-keyframes animate-shine {
0% {opacity: 0; width: 0;}
50% {opacity: .5;}
100% {opacity: 0; width: 95%;}
}

发光样式:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
.glow span {
-moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;
-webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;
box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;

-webkit-animation: animate-glow 1s ease-out infinite;
-moz-animation: animate-glow 1s ease-out infinite;
}

@-webkit-keyframes animate-glow {
0% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
50% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .3) inset, 0 -5px 5px rgba(255, 255, 255, .3) inset;}
100% { -webkit-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
}

@-moz-keyframes animate-glow {
0% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
50% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .3) inset, 0 -5px 5px rgba(255, 255, 255, .3) inset;}
100% { -moz-box-shadow: 0 5px 5px rgba(255, 255, 255, .7) inset, 0 -5px 5px rgba(255, 255, 255, .7) inset;}
}

在不支持css3的浏览器下的表现:

demo:http://www.css88.com/demo/css3-progress-bars/

标签:分类:html5+css3

用CSS3做的动画按钮

时间:2012年01月01日作者:愚人码头查看次数:1,632 views评论次数:0

在Codrops上看到了这篇文章《Animated Buttons with CSS3》,按钮效果非常赞!转过来分享一下:

demo:http://www.css88.com/demo/AnimatedButtons/ (页面有广告,点击需谨慎!!!)

标签:,分类:html5+css3

CSS3动画效果-animate.css

时间:2011年12月14日作者:愚人码头查看次数:3,228 views评论次数:3

animate.css 是提供炫酷,有趣,跨浏览器css3动画的网站,你可以在高级项目中使用这些效果,为高级浏览器用户提供更好的交互体验。动画效果包括强调突出,滑块,淡入淡出,放大缩小等等。你也可以结合jQuery一起使用,例如$(‘.bouncy’).addClass(‘bounceInDown’);

标签:,分类:html5+css3

用纯CSS3做成的Path菜单效果

时间:2011年12月05日作者:愚人码头查看次数:2,225 views评论次数:2

文章来自36氪

Path的UI惊起哇声一片,最大的亮点无疑是左下角的菜单展开效果。于是有各个版本的仿Path菜单出现,比如我们之前报道过的国内某牛人的作品,这里还有若干个关于Path菜单的讨论。但最引人注意的还是来自法国小伙Victor的作品:用纯CSS3制作的Path菜单效果。

他说他喜欢Path的新界面,尤其是添加菜单,作为一个前端设计师的他打算在浏览器里实现同样的效果。以下是他制作的一段视频:

整个作品通过html/css3完成,没有使用任何图片,没有任何javascript。因此仅支持Webkit浏览器。Victor通过Sass+Compass计算每个图标的坐标,并生成了动画效果。你不用重写代码就可以添加或删除项目。

实际效果请移步至这里,你可以在github上找到这段源代码

 

标签:分类:html5+css3

HTML5和CSS3特性检测-Modernizr

时间:2011年07月18日作者:愚人码头查看次数:3,384 views评论次数:2

HTML5和CSS3逐渐成为WEB前端开发的必须技能,开发过程中检查不同浏览器对HTML5和CSS3支持情况成了是一件非常烦心的事情。

比如我们要检查某个浏览器是否支持canvas元素:


function SUP_canvas() {
var elem = document.createElement('canvas');
return !!(elem.getContext &amp;amp;amp;amp;amp;&amp;amp;amp;amp;amp; elem.getContext('2d'));
};

是否支持WebGL:


function SUP_webgl() {
return !!window.WebGLRenderingContext;
};

还有很多html5和css3其他属性…,值得庆幸的是我们发现了Modernizr开源Javascript库

Modernizr是一个用来检测浏览器是否支持HTML5以及CSS3特性的基于MIT证书的开源Javascript库。Modernizr的功能其实很简单,就是用js检测浏览器对HTML5/CSS3的特性支持情况,支持某个属性,就在页面的标 签上添加一个相应的class,不支持的话就添加一个no-前缀的class,比如,如果检测的浏览器支持video标签,MODERNIZR就会 在标签上添加video类,否则,添加no-video类。

最新的Modernizr是2.0.6版本的,如果你下载开发(development)版本,给我们提供全部的内容,如果要下载production版本的modernizr,我们会发现,我们可以根据自己的需要进行订制。在其下载页面上,我们选择自己所需的HTML和CSS特性,然后生成一个javascript文件。这么做会极大程度上减少冗余代码,减少不必要的检测,对web前端这个很看重用户体验的地方,性能就是一点一点压出来的。

使用Modernizr也非常简单,只要而且必须在标签里应用就可以了,无需调用Modernizr_init()之类的初始化方法。modernizr必须放在里,最好放在css声明之后,因为HTML5 Shiv(用以在IE中启用HTML元素)必须在之前执行,而且要使用modernizr添加的class,需要阻止FOUC。还有一点在于html声明里的no-js的class。它设置了一个默认状态,如果页面禁用了javascript我们就可以知道了。

用调试工具我们看到在html标签里加了很多样式类,从这些样式类里我们可以完全看出您使用的浏览器对HTML5和CSS3支持情况,以“no-”开头的,就是这个浏览器不支持的特性:

知道了这些特性的支持情况我们就可以使用css选择器做一些表现上的差异,比如,如果不支持标签,那么test类文本为红色。
.canvas .test {
color: blue;
}

.canvas .test {
color: red;
}

同样,我们也可以在JavaScript利用这些特性检测的结果,代码:


if(Modernizr.canvas){
//开始画图啦!

}else{
alert("fuck!");
}

Modernizr 2还提供了一种load机制,方便代码管理,比如:


Modernizr.load({
test: Modernizr.canvas,//检查是否支持标签及相应的属性
yep : 'canvas.js',//如果支持标签及相应的属性那么加载canvas.js,
nope: 'no-canvas.js'//如果不支持标签及相应的属性那么加载no-canvas.js,
});

如果直接用的是development版本的modernizr,你会发现,根本就没有Modernizr.load,因为它是作为一个单独文件发布的:yepnope.js。而在production版本,我们选择将其包含在modernizr里。

官方网址:http://www.modernizr.com/

标签:,分类:html5+css3, JS

WebKit CSS3 动画基础

时间:2010年05月19日作者:愚人码头查看次数:15,147 views评论次数:11

前几天在Qzone上看到css3动画,非常神奇,所以也学习了一下。首先看看效果http://www.css88.com/demo/css3_Animation/

很悲剧的是css3动画现在只有WebKit内核的浏览器(Safari和Chrome)支持,虽然应用还不是时候,但是效果却不可低估。

在哪里定义动画效果?

css3动画一般通过鼠标事件或者说状态定义动画,通常我们可以用CSS中伪类js中的鼠标事件来定义。

动态伪类 起作用的元素 描述
:link 只有链接 未访问的链接
:visited 只有链接 访问过的链接
:hover 所有元素 鼠标经过元素
:active 所有元素 鼠标点击元素
:focus 所有可被选中的元素 元素被选中

js的事件也可以,比如click,focus,mousemove,mouseover,mouseout等等

transition的基本语法:

css3动画通过transition属性和其他css属性(颜色,宽高,变形,位置等等)配合来实现。

transition的语法:

transition : [<'transition-property'> || <'transition-duration'> || <'transition-timing-function'> || <'transition-delay'> [, [<'transition-property'> || <'transition-duration'> || <'transition-timing-function'> || <'transition-delay'>]]*

当然这是简写,我们也可以完整的写:

transition-property : none | all | [ <IDENT> ] [ '

1
,

' <IDENT> ]*;

transition-duration : <time> [, <time>]*

transition-timing-function : ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier(<number>, <number>, <number>, <number>) [, ease | linear | ease-in | ease-out | ease-in-out | cubic-bezier(<number>, <number>, <number>, <number>)]*

transition-delay : <time> [, <time>]*

继续阅读:WebKit CSS3 动画基础»

标签:,,分类:html5+css3

IE下模拟css3中的box-shadow(阴影)

时间:2010年04月29日作者:愚人码头查看次数:8,883 views评论次数:5

css3中的box-shadow(阴影)可以查看:http://www.css88.com/archives/2136或者http://www.css88.com/tool/css3Preview/Box-Shadow.html

在ie下模拟css3中的box-shadow(阴影)可以使用ie的Shadow(阴影)滤镜

基本语法:filter: progid:DXImageTransform.Microsoft.Shadow(color=’颜色值’, Direction=阴影角度(数值), Strength=阴影半径(数值));

注意:该滤镜必须配合background属性一起使用,否则该滤镜失效。

IE下模拟css3中的box-shadow(阴影)代码:


.box-shadow{

filter: progid:DXImageTransform.Microsoft.Shadow(color='#969696', Direction=135, Strength=5);/*for ie6,7,8*/

background-color: #eee;

-moz-box-shadow:2px 2px 5px #969696;/*firefox*/

-webkit-box-shadow:2px 2px 5px #969696;/*webkit*/

box-shadow:2px 2px 5px #969696;/*opera或ie9*/

}

演示地址:http://www.css88.com/demo/box-shadow/

标签:,分类:html5+css3

让IE实现CSS3中的border-radius(圆角)

时间:2010年04月28日作者:愚人码头查看次数:12,141 views评论次数:12

今天网上看到了一个让IE实现CSS3中的border-radius(圆角):


.box-radius {
border-radius: 15px;
behavior: url(border-radius.htc);
}

演示地址:http://www.css88.com/demo/border-radius/

下载htc文件(源码来自):http://code.google.com/p/curved-corner/

注意:htc文件是要放在服务器上,放在本地测试是不行的!

让IE 6,7,8支持部分的CSS3属性

时间:2010年04月14日作者:愚人码头查看次数:8,373 views评论次数:13

大家知道IE 6,7,8不支持CSS3中新加属性,老外写了一个htc,可以让IE 6,7,8模拟部分的CSS3属性,包括:border-radius(圆角),box-shadow(阴影),text-shadow(文本阴影):

注意:htc文件是要放在服务器上,放在本地测试是不行的!

见代码:


.box {
-moz-border-radius: 15px; /* Firefox */
-webkit-border-radius: 15px; /* Safari and Chrome */
border-radius: 15px; /* Opera 10.5+, future browsers, and now also Internet Explorer 6+ using IE-CSS3 */

-moz-box-shadow: 10px 10px 20px #000; /* Firefox */
-webkit-box-shadow: 10px 10px 20px #000; /* Safari and Chrome */
box-shadow: 10px 10px 20px #000; /* Opera 10.5+, future browsers and IE6+ using IE-CSS3 */

behavior: url(ie-css3.htc); /* 可以让IE 6,7,8模拟部分的CSS3属性 */
}

下载htc文件:http://www.css88.com/demo/ie-css3/ie-css3.htc

原站:http://fetchak.com/ie-css3/

标签:分类:html+css, html5+css3

CSS3 和 HTML5 兼容速查表

时间:2010年04月14日作者:愚人码头查看次数:6,799 views评论次数:4

原文地址:http://www.findmebyip.com/litmus/#target-selector

从网页上截了了个图下来:

标签:,分类:html+css, html5+css3
Page 1 of 212