日志分类:html5+css3

时尚的CSS3进度条

时间:2012年01月01日作者:愚人码头查看次数:2,737 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,646 views评论次数:0

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

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

标签:,分类:html5+css3

CSS Filter

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

今天在前端观察上看到了《-webkit-filter是神马?》,感觉特别有意思,具体关于CSS Filter可以看Filter Effects 1.0,以及 filter功能,Webkit率先支持了这几个功能,效果非常赞+10086!

支持的效果有:

  • blur(模糊)
  • grayscale(灰度)
  • drop-shadow(阴影)
  • sepia(褐色滤镜)
  • brightness(亮度)
  • contrast(对比)
  • hue-rotate(色相)
  • invert(反相)
  • saturate(饱和度)
  • opacity(透明度)

 

Chrome 18.0.976.0以上版本看这个demo:

http://www.css88.com/html5-demo/-webkit-filter/index.html 或 (翻墙)http://html5-demos.appspot.com/static/css/filters/index.html

标签:分类:html5+css3

28个你必须知道的HTML5的新特性,技巧以及技术

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

原文:http://net.tutsplus.com/tutorials/html-css-techniques/25-html5-features-tips-and-techniques-you-must-know/

译文来自:http://adamlu.com/?p=584

总结一下:

1. 新的Doctype

尽管使用<!DOCTYPE html>,即使浏览器不懂这句话也会按照标准模式去渲染

2. Figure元素

用<figure>和<figcaption>来语义化地表示带标题的图片

<figure>

<img src="path/to/image" alt="About image" />

<figcaption>

<p>This is an image of something interesting. </p>

</figcaption>

</figure>

继续阅读:28个你必须知道的HTML5的新特性,技巧以及技术»

CSS3动画效果-animate.css

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

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

标签:,分类:html5+css3

用纯CSS3做成的Path菜单效果

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

文章来自36氪

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

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

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

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

 

标签:分类:html5+css3

html5客户端本地存储之sessionStorage及storage事件

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

首先您可以看一下《JavaScript本地存储实践(html5的localStorage和ie的userData)
sessionStorage和上文中提到的localStorage非常相识,方法也几乎一样:

非常通俗易懂的接口:

  • sessionStorage.getItem(key):获取指定key本地存储的值
  • sessionStorage.setItem(key,value):将value存储到key字段
  • sessionStorage.removeItem(key):删除指定key本地存储的值
  • sessionStorage.length是sessionStorage的项目数

直接上demo:http://www.css88.com/demo/sessionStorage/

sessionStorage与 localStorage 的异同

sessionStorage 和 localStorage 就一个不同的地方, sessionStorage数据的存储仅特定于某个会话中,也就是说数据只保持到浏览器关闭,当浏览器关闭后重新打开这个页面时,之前的存储已经被清除。而 localStorage 是一个持久化的存储,它并不局限于会话。

sessionStorage和localStorage提供的key()和length可以方便的实现存储的数据遍历,例如下面的代码:


var storage = window.localStorage;
for (var i=0, len = storage.length; i < len; i++){
var key = storage.key(i);
var value = storage.getItem(key);
console.log(key + "=" + value);
}

sessionStorage 和 localStorage的clear()函数的用于清空同源的本地存储数据,比如localStorage.clear(),它将删除所有同源的本地存储的localStorage数据,而对于Session Storage,它只清空当前会话存储的数据。

关闭页面会导致 sessionStorage 的数据被清除,但刷新或重新打开新页面数据还是存在,如果需要存储的只是少量的临时数据。我们可以使用sessionStorage 。或者做页面间的小交互。

sessionStorage 和 localStorage具有相同的方法storage事件,在存储事件的处理函数中是不能取消这个存储动作的。存储事件只是浏览器在数据变化发生之后给你的一个通知。当setItem(),removeItem()或者clear() 方法被调用,并且数据真的发生了改变时,storage事件就会被触发。注意这里的的条件是数据真的发生了变化。也就是说,如果当前的存储区域是空的,你再去调用clear()是不会触发事件的。或者你通过setItem()来设置一个与现有值相同的值,事件也是不会触发的。当存储区域发生改变时就会被触发,这其中包含许多有用的属性:

  • storageArea: 表示存储类型(Session或Local)
  • key:发生改变项的key
  • oldValue: key的原值
  • newValue: key的新值
  • url*: key改变发生的URL
  • * 注意: url 属性早期的规范中为uri属性。有些浏览器发布较早,没有包含这一变更。为兼容性考虑,使用url属性前,你应该先检查它是否存在,如果没有url属性,则应该使用uri属性
    如果调用clear()方法,那么key、oldValue和newValue都会被设置为null。
    PS.在firefox和chrome中存储和读取都是正常的, 但是对storage事件的触发似乎有点问题, 自身页面进行setItem后没有触发window的storage事件, 但是同时访问A.html和B.html, 在A页面中进行 setItem能触发B页面中window的storage事件, 同样的在B页面中进行setItem能触发A页面中window的storage事件. 在IE9中, 页面自身的设值能触发当前页面的storage事件,同样当前页面的设值能触发同一”起源”下其他页面window的storage事件,这看起来似乎更让人想的通些.

    直接上demo,同事打开这两个页面(代码一模一样):

    http://www.css88.com/demo/sessionStorage/index2.html 

    http://www.css88.com/demo/sessionStorage/index3.html 

    感谢:Mr.Prime在storage事件上给予的帮助,另外推荐一下他写的关于storage的博文:http://www.cnblogs.com/AndyWithPassion/archive/2011/07/04/html5_localstorage.html

行内元素vertical-align:middle在html5和xhtml1.0及以下版本中的表现差异

时间:2011年10月08日作者:愚人码头查看次数:3,093 views评论次数:9

今天在做页面的时候无意中发现静态页面中小图标和文本对的很齐的,在线上的页面却小图标和文本没有对齐。同事啄木鸟找出的原因是静态页面和线上的页面的html DOCTYPE不一样,静态页面为html5,线上的页面xhtml 1.0;一直以为xhtml和html5表现上是一样的,只是DOCTYPE不一样!

经过同事啄木鸟多番测试终于找出了差异的问题所在,那就是行内元素的vertical-align:middle样式。详细看demo1 (DOCTYPE为HTML 5)demo2 (DOCTYPE为XHTML 1.0)

注:

  1. 以上demo只测试了firefox 7和chrome,ie各个版本没有测试;
  2. DOCTYPE为xhtml 1.1和DOCTYPE为html5的表现一致;
  3. DOCTYPE为xhtml 1.0和DOCTYPE为html 4的表现一致;
产生差异的具体原因未知,未做深入学习,其他css属性不知道是不是也会存在细微的差异,如果您知道原因或者也碰到过这方面的问题,欢迎留言告知交流,感激不尽!

方便的CSS和jQuery下拉菜单解决方案

时间:2011年08月31日作者:愚人码头查看次数:8,758 views评论次数:4

来源:http://www.designerterminal.com/resource/jquery/css-jquery-dropdown-menu-solutions.html

如果您正在 寻找 一些很酷 的 下拉菜单解决 方案 , 那么这些要 。今天 , 我收集了 一些有用的 CSS和jQuery 下拉菜单 解决 方案 。

Creating a pure CSS dropdown menu

Creating a pure CSS dropdown menu

Sexy Drop Down Menu w/ jQuery & CSS

Sexy Drop Down Menu

  继续阅读:方便的CSS和jQuery下拉菜单解决方案»

分类:html5+css3, jQuery

Tip中小三角的实现

时间:2011年07月26日作者:愚人码头查看次数:5,585 views评论次数:21

前段时间专门研究了一下腾讯微博的Tip,很有意思!tip中的小箭头是用“◆”(encode为:&#9670;)字符模拟的。以前也写过类似的实现方案《用css的border属性实现三角》。用“◆”字符模拟小三角有一个有点就是:比如tip有border时,也可以用两个绝对定位的“◆”字符模拟。如图:

注意:最好根据您的实际情况设置“◆”的字体,我这里用了宋体,有棱有角真好!

demo页面:http://www.css88.com/demo/tipbox/

Page 1 of 3123