Quantcast
Channel: w3cplus
Viewing all 1557 articles
Browse latest View live

CSS3制作3D立体分页导航

$
0
0
CSS3制作3D立体分页导航

收集了很多DEMO和相关的PSD,于是想能不能通过自己学的CSS3相关技巧,将有关PSD图效果转换成CSS3效果。灵光的冲动,让我开始做起了这件事情,今天开始我会开始制作一些CSS3的DEMO效果,而这些DEMO效果都是由对应的PSD转换过来的,换句话说,如果你不考虑兼容IE低版本的话,这些DEMO你都可以使用。那我们开始吧

这个DEMO主要是一个3D立体居中的分页导航效果,其实主要三个关键处,第一渐变有明显的分隔线,即上半部是一色,下半部是一色;第二使用box-shadow来制作立体效果;第三使用CSS3伪类选择器,改变第一和最后两年导航项的效果。详细的看代码吧。

demodownload

HTML 结构:

<div class="pager">
  <a href="#">prev</a>
  <a href="#">1</a>
  <a href="#">2</a>
  <a href="#" class="current">3</a>
  <a href="#">4</a>
  <a href="#">5</a>
  <a href="#">next</a>
</div<

CSS 代码

*{
  margin: 0;
  padding: 0;
}
body {
  background: url(data:image/jpeg;base64,/...=) repeat;
}
.pager {
  margin: 20px;
  text-align: center;
}
.pager a {
  display: inline-block;
  padding: 5px 15px;
  color: #474747;
  font-size: 26px;
  font-family: 'Francois One', sans-serif;
  text-transform: capitalize;
  border-radius: 10px;
  text-decoration: none;
  border: 1px solid #fff;
  box-shadow: 0 1px 0 0 #a1a0a0,0 2px 0 0 #a1a0a0,0 3px 0 0 #a1a0a0,0 4px 0 0 #a1a0a0,0 5px 0 0 #a1a0a0;
  background: #e7e7e7; /* Old browsers */
  background-color: #ffffff; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjQ5JSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2U3ZTdlNyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9Ijk5JSIgc3RvcC1jb2xvcj0iI2U3ZTdlNyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
  background-image: -moz-linear-gradient(top,  #ffffff 0%, #ffffff 49%, #e7e7e7 50%, #e7e7e7 1%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(49%,#ffffff), color-stop(50%,#e7e7e7), color-stop(99%,#e7e7e7)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #ffffff 0%,#ffffff 49%,#e7e7e7 50%,#e7e7e7 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #ffffff 0%,#ffffff 49%,#e7e7e7 50%,#e7e7e7 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #ffffff 0%,#ffffff 49%,#e7e7e7 50%,#e7e7e7 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #ffffff 0%,#ffffff 49%,#e7e7e7 50%,#e7e7e7 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e7e7e7',GradientType=0 ); /* IE6-8 */
}
.pager a:first-child,
.pager a:last-child {
  color: #fff;
  background-color: #f35252; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2YzNTI1MiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iI2YzNTI1MiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iI2IzMDEwMSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNiMzAxMDEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
  background-image: -moz-linear-gradient(top,  #f35252 0%, #f35252 50%, #b30101 51%, #b30101 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f35252), color-stop(50%,#f35252), color-stop(51%,#b30101), color-stop(100%,#b30101)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #f35252 0%,#f35252 50%,#b30101 51%,#b30101 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #f35252 0%,#f35252 50%,#b30101 51%,#b30101 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #f35252 0%,#f35252 50%,#b30101 51%,#b30101 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #f35252 0%,#f35252 50%,#b30101 51%,#b30101 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f35252', endColorstr='#b30101',GradientType=0 ); /* IE6-8 */
  box-shadow: 0 1px 0 0 #7f0505,0 2px 0 0 #7f0505,0 3px 0 0 #7f0505,0 4px 0 0 #7f0505,0 5px 0 0 #7f0505;
  border-color: #e25c5c #b75555 #d96767 #fdb0b0;
}
.pager a:hover,
.pager a:active,
.pager a.current{
  box-shadow: 0 1px 0 0 #a1a0a0,0 2px 0 0 #a1a0a0,0 3px 0 0 #a1a0a0;
  position:relative;
  top:2px;
}
.pager a:first-child:hover,
.pager a:last-child:hover {
  box-shadow: 0 1px 0 0 #7f0505,0 2px 0 0 #7f0505,0 3px 0 0 #7f0505;
}

demodownload

如需转载,烦请注明出处:http://www.w3cplus.com/demo/css3-pager.html


css3时钟

$
0
0
css3 clock

本实例纯css3打造,因为没有获取当前时间,所以初始化时间为12点,打开即开始走动。圆盘使用border-radius做成,然后一个:before生成中间的圆点,一个:after生成倒影。至于三个指针就是关键了,其高度及宽度不等,绝对定位于中间的同一圆点,然后以这点为坐标旋转,旋转使用动画一样,只是旋转一周的持续时间不一样,秒针为60s,分针为3600s,时钟为43200s。

demodownload

css主要代码:

#clock {
	position: relative;
	width: 120px;
	height: 120px;
	background: #96d2d0;
	margin: 50px auto 0;
	border: 10px solid #fff;
	
	-moz-border-radius: 50%;
	-webkit-border-radius: 50%;
	border-radius: 50%;
}

#clock:after {
	content: '';
	position: absolute;
	bottom: -7px;
	width: 120px;
	left: 0;
	height: 0px;
	
	-moz-border-radius: 50%;
	-webkit-border-radius: 50%;
	border-radius: 50%;
	
	-webkit-box-shadow: 0px 0px 2px 2px rgba(0,0,0,0.8);
	-moz-box-shadow: 0px 0px 8px 2px rgba(0,0,0,0.8);
	box-shadow: 0px 0px 8px 2px rgba(0,0,0,0.8);
	
	z-index: -1;
}

#clock:before {
	content: '';
	position: absolute;
	z-index: 2;
	width: 8px;
	height: 8px;
	background: #333;
	left: 50%;
	top: 50%;
	margin: -4px 0 0 -4px;
	
	-moz-border-radius: 50%;
	-webkit-border-radius: 50%;
	border-radius: 50%;
}

/* Hands */
#clock span.hand {
	background: #555;
	position: absolute;
	left: 50%;
	-webkit-animation: rotate 60s infinite linear;
	-webkit-transform-origin: left bottom;
	-moz-animation: rotate 60s infinite linear;
	-moz-transform-origin: left bottom;
	-ms-animation: rotate 60s infinite linear;
	-ms-transform-origin: left bottom;
	-o-animation: rotate 60s infinite linear;
	-o-transform-origin: left bottom;
	animation: rotate 60s infinite linear;
	transform-origin: left bottom;
}

#clock span.hand.second {
	height: 50px;
	width: 2px;	
	margin-left: -1px;
	top: 10px;
}

#clock span.hand.minute {
	height: 40px;
	width: 4px;	
	margin-left: -2px;
	top: 20px;
	-webkit-animation-duration: 3600s;
	-moz-animation-duration: 3600s;
	-ms-animation-duration: 3600s;
	-o-animation-duration: 3600s;
	animation-duration: 3600s;
}

#clock span.hand.hour {
	height: 30px;
	width: 6px;	
	margin-left: -3px;
	top: 30px;
	-webkit-animation-duration: 43200s;
	-moz-animation-duration: 43200s;
	-ms-animation-duration: 43200s;
	-o-animation-duration: 43200s;
	animation-duration: 43200s;
}

@-webkit-keyframes rotate {
	0% { -webkit-transform: rotate(0deg);}
	100% { -webkit-transform: rotate(360deg);}
}	

@-moz-keyframes rotate {
	0% { -moz-transform: rotate(0deg);}
	100% { -moz-transform: rotate(360deg);}
}	

@-ms-keyframes rotate {
	0% { -ms-transform: rotate(0deg);}
	100% { -ms-transform: rotate(360deg);}
}	

@-o-keyframes rotate {
	0% { -o-transform: rotate(0deg);}
	100% { -o-transform: rotate(360deg);}
}	

@keyframes rotate {
	0% { transform: rotate(0deg);}
	100% { transform: rotate(360deg);}
}	

demodownload

查看更多:http://cssdeck.com/labs/non-functional-pure-css3-animated-clock

CSS3 Menu

$
0
0
CSS3 Nav Menu

导航是WEB页面中不可或缺的一部分,以前制作渐变、圆角类型的导航,都需要使用背景图片来制作,今天给大家介绍一个使用CSS3制作的导航效果,在这个实例中主要运用了CSS3的渐变和box-shadow。

demodownload

HTML Code:

<ul id="nav">
  <li class="current"><a href="#">Home</a></li>
  <li><a href="#">About</a></li>
  <li><a href="#">Blog</a></li>
  <li><a href="#">Contact</a></li>
</ul>

CSS Code:

*{
 margin: 0;
 padding: 0;
}
body {
 background-color: #434343;
 color: #fff;
 font-family: 'Courgette', cursive;
 padding: 50px;
 text-align: center;
}
#nav:after,
#nav:before {
 content:"";
 display: table;
}
#nav:after {
 clear:both;
 overflow:hidden;
}
#nav {
 zoom: 1;
 width:430px;
 padding: 10px 20px;
 margin: 100px auto;
 background-color: #4c505b; /* Old browsers */
 /* IE9 SVG, needs conditional override of 'filter' to 'none' */
 background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzRjNTA1YiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iIzM4M2I0NCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iIzMyMzQzYyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMyMTIyMjciIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
 background-image: -moz-linear-gradient(top,  #4c505b 0%, #383b44 50%, #32343c 51%, #212227 100%); /* FF3.6+ */
 background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#4c505b), color-stop(50%,#383b44), color-stop(51%,#32343c), color-stop(100%,#212227)); /* Chrome,Safari4+ */
 background-image: -webkit-linear-gradient(top,  #4c505b 0%,#383b44 50%,#32343c 51%,#212227 100%); /* Chrome10+,Safari5.1+ */
 background-image: -o-linear-gradient(top,  #4c505b 0%,#383b44 50%,#32343c 51%,#212227 100%); /* Opera 11.10+ */
 background-image: -ms-linear-gradient(top,  #4c505b 0%,#383b44 50%,#32343c 51%,#212227 100%); /* IE10+ */
 background-image: linear-gradient(to bottom,  #4c505b 0%,#383b44 50%,#32343c 51%,#212227 100%); /* W3C */
 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c505b', endColorstr='#212227',GradientType=0 ); /* IE6-8 */
 border: 1px solid #1e1e1e;
 border-radius: 8px;
 box-shadow:inset 0 1px 0 rgb(115, 122, 140), inset -1px 0 0 rgb(80, 83, 96),inset 0 -1px 0 rgb(47, 50, 57), inset 1px 0 0 rgb(78, 82, 94), 1px 2px 3px rgb(28, 28, 28); 
}
#nav li {
 float: left;
 display: inline;
}
#nav a {
 display: block;
 float: left;
 color: #fff;
 text-decoration: none;
 font-weight: bold;
 padding: 5px 15px;
 border: 1px solid #18191d;
 margin: 0 15px;
 border-radius: 5px;
 box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.14),0 1px 1px rgba(255, 255, 255, 0.15);
 background-color: rgb(59,64,79); /* Old browsers */
 /* IE9 SVG, needs conditional override of 'filter' to 'none' */
 background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzNiNDA0ZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMxNTE3MWQiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
 background-image: -moz-linear-gradient(top,  rgba(59,64,79,1) 0%, rgba(21,23,29,1) 100%); /* FF3.6+ */
 background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(59,64,79,1)), color-stop(100%,rgba(21,23,29,1))); /* Chrome,Safari4+ */
 background-image: -webkit-linear-gradient(top,  rgba(59,64,79,1) 0%,rgba(21,23,29,1) 100%); /* Chrome10+,Safari5.1+ */
 background-image: -o-linear-gradient(top,  rgba(59,64,79,1) 0%,rgba(21,23,29,1) 100%); /* Opera 11.10+ */
 background-image: -ms-linear-gradient(top,  rgba(59,64,79,1) 0%,rgba(21,23,29,1) 100%); /* IE10+ */
 background-image: linear-gradient(to bottom,  rgba(59,64,79,1) 0%,rgba(21,23,29,1) 100%); /* W3C */
 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#3b404f', endColorstr='#15171d',GradientType=0 ); /* IE6-8 */
}
#nav a:hover,
#nav .current a {
 background-color: rgb(56,61,75); /* Old browsers */
 /* IE9 SVG, needs conditional override of 'filter' to 'none' */
 background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzM4M2Q0YiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMxNTE3MWQiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
 background-image: -moz-linear-gradient(top,  rgba(56,61,75,1) 0%, rgba(21,23,29,1) 100%); /* FF3.6+ */
 background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(56,61,75,1)), color-stop(100%,rgba(21,23,29,1))); /* Chrome,Safari4+ */
 background-image: -webkit-linear-gradient(top,  rgba(56,61,75,1) 0%,rgba(21,23,29,1) 100%); /* Chrome10+,Safari5.1+ */
 background-image: -o-linear-gradient(top,  rgba(56,61,75,1) 0%,rgba(21,23,29,1) 100%); /* Opera 11.10+ */
 background-image: -ms-linear-gradient(top,  rgba(56,61,75,1) 0%,rgba(21,23,29,1) 100%); /* IE10+ */
 background-image: linear-gradient(to bottom,  rgba(56,61,75,1) 0%,rgba(21,23,29,1) 100%); /* W3C */
 filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#383d4b', endColorstr='#15171d',GradientType=0 ); /* IE6-8 */
 box-shadow:0 1px 1px rgba(255, 255, 255, 0.15);   
}

demodownload

如需转载,烦请注明出处:http://www.w3cplus.com/demo/css3-nav-menu.html

CSS3制作凤凰网导航

$
0
0
CSS3制作凤凰网导航

今天在群讨论一个导航制作(凤凰网娱乐),看过同学发来的gif动画图,想将此图转画为CSS3导航,动手试了一下,还是可以实现的。在这个实例中中要运用了以下知识点:box-shadow,CSS制作图形,旋转,动画。感兴趣的同学可以来围观。

demodownload

HTML Code

<ul id="nav">
  <li><a href="#">Home</a></li>
  <li><a href="#">Blog</a></li>
  <li class="expansion">
    <a href="#">Tutorial</a>
    <ul class="sub-menu">
      <li><a href="#">css</a></li>
      <li><a href="#">css3</a></li>
      <li><a href="#">html</a></li>
      <li><a href="#">html5</a></li>
      <li><a href="#">jquery</a></li>
      <li><a href="#">javascript</a></li>
      <li><a href="#">php</a></li>
    </ul>
  </li>
  <li><a href="demo2.html">Demo</a></li>
  <li><a href="#">Contact</a></li>
</ul>

CSS Code

*{
  margin: 0;
  padding: 0;
}
body {
  font-size: 12px;
  font-family: 'Covered By Your Grace', cursive;
  padding: 100px;
}
.container {
  width: 960px;
  margin: 0 auto;
}
/*menu style start*/
#nav {
  width: 960px;
  margin: 50px auto;
  background: #8c319c;
  color: #fff;
  position:relative;
  box-shadow: -1px 0 0 #732184,-2px 0 0 #732184,-3px 0 0 #732184,-4px 0 0 #732184,-5px 0 0 #732184,-6px 0 0 #732184,-7px 0 0 #732184,-8px 0 0 #732184,-9px 0 0 #732184,-10px 0 0 #732184;
  border-top: 10px solid #000;
  float: left;
  width: 100%;
}
#nav::before {
  content:"";
  border: 5px solid #732184;
  border-color:#732184 #732184 #cecece #cecece;
  position: absolute;
  bottom: 0;
  left: -10px;
  width: 0;
  height: 0;
  display: block;
  z-index:2;
}
#nav::after {
  content:"";
  width: 10px;
  height: 9px;
  background: #000;
  position: absolute;
  top: -9px;
  left: -10px;
  display: block;
} 
#nav li {
  float: left;
  display: inline;
}
#nav a {
  display: block;
  float: left;
  padding: 10px 15px;
  text-decoration: none;
  text-transform: uppercase;
  color: #fff;
  font-weight: bold;
  font-size: 24px;
  box-shadow: 2px 0 0 rgba(255,255,255,0.5);
  -webkit-transition: all 0.5s ease-in .218s;
  -moz-transition: all 0.5s ease-in .0038s;
  -o-transition: all 0.5s ease-in .0038s;
  transition: all 0.5s ease-in .0038s;
}
#nav .sub-menu {
  position: absolute;
  left: 0;
  top: 100%;
  background: #eff7f7;
  right: 0;
  box-shadow: -1px 0 0 #cecece,-2px 0 0 #cecece,-3px 0 0 #cecece,-4px 0 0 #cecece,-5px 0 0 #cecece,-6px 0 0 #cecece,-7px 0 0 #cecece,-8px 0 0 #cecece,-9px 0 0 #cecece,-10px 0 0 #cecece;
}
#nav .sub-menu::before {
  content:"";
  border: 5px solid #cecece;
  border-color:#cecece #cecece #fff #fff;
  position: absolute;
  bottom: 0;
  left: -10px;
  width: 0;
  height: 0;
  display: block;
  z-index:2;
}
		
#nav .sub-menu a {
  color: #000;
  font-size: 20px;
  font-weight: normal;
}
#nav a:hover,
#nav .expansion a {
  background: #eff7f7;
  color: #000;
  box-shadow: 1px 0 0 #a5adad, 2px 0 0 #b5bdbd,3px 0 0 #a5adad;
  padding-top: 14px;
  margin-top: -4px;
}
#nav .sub-menu a {
  background: none;
  box-shadow: none;
  padding-top: 10px;
  margin-top: 0;
}
#nav .sub-menu a:hover {
  color: rgb(140, 49, 156);
}

demodownload

接下来在给大家提供馨儿同学做的同等效果的DEMO代码。大家可以对比一下制作思路与实现方法

demodownload

HTML 结构

<div class="nav">
  <ul>
<li class="active">娱乐首页</li>
<li>明星</li>
<li>电视</li>
<li>电影</li>
<li>音乐</li>
<li>图片</li>
<li>星座</li>
<li>演出</li>
<li>凤凰网·非常道</li>
<li>官网</li>
</ul>
<div class="sNav"><a href="#">这是子导航</a></div>
</div>

CSS Code:

body,ul,li{padding: 0; margin:0;}
body{ margin:100px}
.nav{position: relative; border-top: 10px solid #000;width: 960px; margin: 0 auto;}
.nav:after,.nav:before{ display: block; content: ""; position: absolute; left: 0; width: 10px}
.nav:before{ background: #8c319c; height: 25px; -webkit-transform:skew(0,50deg); top: 10px; }
.nav:after{ background: #cecece; height: 35px; -webkit-transform:skew(0,50deg); top: 30px}
.nav ul{ background:#8c319c; height: 30px;list-style-type: none; line-height: 30px; padding: 0 10px}
.nav li{ display: inline-block;padding: 0 15px; border-right:1px solid #a552ad}
.nav li.active{ background:#eff7f7; border-right:3px solid #b5bdbd; position: relative; top: -5px; height: 35px;}
.nav .sNav{ background:#eff7f7; line-height: 40px; margin-left: 10px}
.nav .sNav a{ color: #000; text-decoration: none; margin: 0 10px}

demodownload

如需转载,烦请注明出处:http://www.w3cplus.com/demo/create-ent-ifeng-menu-with-css3.html

CSS3 Loading Bar

$
0
0
CSS3 Loading Bar

CSS3制作一个类似于文件Loading的效果,在这里没有写动画效果,主要考虑文件加载对应的文本,css实现效果会有难度。在这个DEMO中主要运用了四个知识点:第一是google font api,用来制作特殊的英文字体效果;第二个是使用CSS的渐变,制作了渐变的面板效果;第三使用box-shadow,制作面板之类的描边效果;第四就是使用border-radius制作圆角效果。

demodownload

HTML Code:

<div class="loading">
  <h2>Copying</h2>
  <div class="loading-bar">
    <div class="metro"><span></span></div>
    <div class="metro-des">1 MB of 35 MB</div>
  </div>
</div>

CSS Code:

/*loading Bar*/
.loading{
  width: 415px;
  margin: 20px auto;
  border: 1px solid #000;
  border-radius: 5px;
  box-shadow: 0 3px 3px rgba(0,0,0,0.22);
  background-color: rgb(45,42,42); /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzJkMmEyYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMzZTNmNDAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
  background-image: -moz-linear-gradient(top,  rgba(45,42,42,1) 0%, rgba(62,63,64,1) 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(45,42,42,1)), color-stop(100%,rgba(62,63,64,1))); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  rgba(45,42,42,1) 0%,rgba(62,63,64,1) 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  rgba(45,42,42,1) 0%,rgba(62,63,64,1) 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  rgba(45,42,42,1) 0%,rgba(62,63,64,1) 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  rgba(45,42,42,1) 0%,rgba(62,63,64,1) 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2d2a2a', endColorstr='#3e3f40',GradientType=0 ); /* IE6-8 */
}
.loading h2 {
  padding: 5px 10px;
  font-size: 20px;
  text-shadow: -2px -3px 0 rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid black;
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.13),inset 0 2px 0 rgba(255,255,255,0.13);
  background-color: rgb(50,50,50); /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzMyMzIzMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMyMzIzMjMiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
  background-image: -moz-linear-gradient(top,  rgba(50,50,50,1) 0%, rgba(35,35,35,1) 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(50,50,50,1)), color-stop(100%,rgba(35,35,35,1))); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  rgba(50,50,50,1) 0%,rgba(35,35,35,1) 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  rgba(50,50,50,1) 0%,rgba(35,35,35,1) 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  rgba(50,50,50,1) 0%,rgba(35,35,35,1) 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  rgba(50,50,50,1) 0%,rgba(35,35,35,1) 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#323232', endColorstr='#232323',GradientType=0 ); /* IE6-8 */
  border-radius: 5px 5px 0 0;
}
.loading-bar {
  padding: 15px;
}
.metro {
  border: 1px solid #000;
  border-radius: 5px;
  height: 20px;
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.13);
  margin-bottom: 10px;
  background: #292929;
}
.metro span {
  display: block;
  height: 20px;
  width: 35%;
  border-radius: 5px;
  background-color: rgb(75,117,204); /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzRiNzVjYyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUwJSIgc3RvcC1jb2xvcj0iIzRiNzVjYyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUxJSIgc3RvcC1jb2xvcj0iIzMwNjFjNCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiMzMDYxYzQiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background-image: -moz-linear-gradient(top,  rgba(75,117,204,1) 0%, rgba(75,117,204,1) 50%, rgba(48,97,196,1) 51%, rgba(48,97,196,1) 100%); /* FF3.6+ */
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(75,117,204,1)), color-stop(50%,rgba(75,117,204,1)), color-stop(51%,rgba(48,97,196,1)), color-stop(100%,rgba(48,97,196,1))); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  rgba(75,117,204,1) 0%,rgba(75,117,204,1) 50%,rgba(48,97,196,1) 51%,rgba(48,97,196,1) 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  rgba(75,117,204,1) 0%,rgba(75,117,204,1) 50%,rgba(48,97,196,1) 51%,rgba(48,97,196,1) 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  rgba(75,117,204,1) 0%,rgba(75,117,204,1) 50%,rgba(48,97,196,1) 51%,rgba(48,97,196,1) 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  rgba(75,117,204,1) 0%,rgba(75,117,204,1) 50%,rgba(48,97,196,1) 51%,rgba(48,97,196,1) 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4b75cc', endColorstr='#3061c4',GradientType=0 ); /* IE6-8 */
}
.metro-des {
  color: #a49f9f;
  text-shadow: -1px -2px 0 rgba(0, 0, 0, 0.3);
}

demodownload

如需转载,烦请注明出处:http://www.w3cplus.com/demo/css3-loading-bar.html

CSS3 Share Button

$
0
0
CSS3 Share Button

首先非常感谢藤藤提供的代码,是她用CSS3写的一个分享按钮的效果,而且写得非常不错。结过她的同意,我稍加做了点点的修改,增加了ICON图标上去,让效果看上去更清晰一些。在这个效果中主要使用了:CSS3的伪类选择器(伪元素)、box-shadow和@font-face三个属性,结过颜色细腻的搭配,制作了这么一个完美的分享按钮。

demodownload

HTML Code

<div class="box">
  <a href="#">
    <span>12</span>
    <span>Tweet</span>
  </a>
  <a href="#">
    <span>32</span>
    <span>Like</span>
  </a>
  <a href="#">
    <span>12</span>
    <span>109</span>
  </a>
</div>

CSS Code

/*share button*/
@font-face {
  font-family: 'fontello';
  src: url("font/fontello.eot");
  src: url("font/fontello.eot?#iefix") format('embedded-opentype'), url("font/fontello.woff") format('woff'), url("font/fontello.ttf") format('truetype'), url("font/fontello.svg#fontello") format('svg');
  font-weight: normal;
  font-style: normal;
}
.box {
  width: 960px;
  margin:20px auto;
  text-align:center;
}
.box a{ 
  display: inline-block; 
  width: 80px; 
  height: 80px; 
  background:#dfe7ea;
  border-radius: 10px; 
  border:1px solid #b5babe; 
  text-align: center; 
  margin-right: 20px; 
  font-weight: bold; 
  position: relative;
  box-shadow:0 1px 0 rgb(85, 156, 184),0 2px 0 rgb(85, 156, 184),0 3px 0 rgb(85, 156, 184),0 4px 0 rgb(85, 156, 184),0 6px 0 rgb(85, 156, 184),0 7px 0 rgba(0, 0, 0, 0.5);
  text-decoration: none;
}
.box a:nth-of-type(2){ 
  box-shadow:0 1px 0 rgb(45, 65, 126),0 2px 0 rgb(45, 65, 126),0 3px 0 rgb(45, 65, 126),0 4px 0 rgb(45, 65, 126),0 6px 0 rgb(45, 65, 126),0 7px 0 rgba(0, 0, 0, 0.5);
}
.box a:nth-of-type(3){ 
  box-shadow: 0 1px 0 rgb(58, 59, 61),0 2px 0 rgb(58, 59, 61),0 3px 0 rgb(58, 59, 61),0 4px 0 rgb(58, 59, 61),0 6px 0 rgb(58, 59, 61),0 7px 0 rgba(0, 0, 0, 0.5);
}
.box a span{ 
  height: 40px; 
  display:block; 
  width: 80px; 
  margin-left: -1px;
  color: #000;
}
.box a span:first-child{
  position: relative;
}
.box a span:first-child:after,
.box a span:first-child:before{ 
  display: block; 
  content: ""; 
  position: absolute; 
  width: 0; 
  height: 0;  
  left: 50%;
  border-style: solid; 
  z-index: 9;
}
.box a span:first-child:before{ 
  border-color:#63a9b5 transparent transparent transparent; 
  border-width: 8px;
  bottom:-16px; 
  margin-left:-8px;
}
.box a span:first-child:after{ 
  border-color: #dfe7ea transparent transparent transparent; 
  border-width: 6px; 
  bottom:-11px; 
  margin-left:-6px;
}

.box a:nth-of-type(2) span:first-child:before{ 
  border-color:#354267 transparent transparent transparent;
}
.box a:nth-of-type(3) span:first-child:before{ 
  border-color:#252629 transparent transparent transparent;
}
.box a span:last-child{  
  color: #fff;
  box-shadow:inset 0 -2px 4px rgba(255,255,255,.3); 
  border-radius: 0 0 10px 10px;
  background:#6dc2df;
  border: 1px solid #64aab6; 
  text-shadow:1px 2px 1px rgba(0,0,0,.2);
  position: relative;
  z-index: 0;
}

.box a:nth-of-type(2) span:last-child{
  background:#556eb0; 
  border: 1px solid #354267;
}
.box a:nth-of-type(3) span:last-child{
  background:#5a5c5b; 
  border: 1px solid #252629;
}

.box a span:last-child:before {
  font-family: 'fontello';
  font-style: normal;
  font-weight: normal;
  speak: none;
  display: inline-block;
  text-decoration: inherit;
  width: 1em;
  margin-right: 0.4em;
  text-align: center;
  vertical-align: 1px;
}
.box a:nth-of-type(1) span:last-child:before{ content: '\f310'; } 
.box a:nth-of-type(2) span:last-child:before { content: '\f301'; } 
.box a:nth-of-type(3) span:last-child:before { content: '\f309'; } 

demodownload

再次感谢藤藤的分享。希望有更多的同学参与我们的CSS3案例分享当中来,用你的创意,带动大家一起学习CSS3。

如需转载,烦请注明出处:http://www.w3cplus.com/demo/css3-share-button.html

css3圆环形旋转

$
0
0
css3圆环形旋转

本实例看起来有点像太极,其实更如一块环形的玉佩,设计比较好看。先设计一个圆形填充一个135deg的两个颜色的渐变,各位一半。然后设计三个子元素为上中下的小圆,一个为浅色的与渐变背景的浅色的一样,一个为黑色的充当中间的孔,一个为深色的与渐变背景的深色一样,为了表现更佳,给这三个小圆各自应用了box-shadow生成阴影。然后就是父元素的animate转动360deg。

demodownload

html主要代码:

<div id="wrapper" class="wrapper">
	<div id="up"></div>
	<div id="mid"></div>
	<div id="down"></div>
</div>

css主要代码:

#wrapper{
width:150px;
height:150px;
background: -moz-linear-gradient(135deg, rgba(111,219,68,1) 0%,rgba(111,219,68,1) 50%,rgba(3,153,8,1) 50%,rgba(3,153,8,1) 100%);
background: -webkit-linear-gradient(135deg, rgba(111,219,68,1) 0%,rgba(111,219,68,1) 50%,rgba(3,153,8,1) 50%,rgba(3,153,8,1) 100%);
background: linear-gradient(135deg, rgba(111,219,68,1) 0%,rgba(111,219,68,1) 50%,rgba(3,153,8,1) 50%,rgba(3,153,8,1) 100%);

margin:20px auto;
border-radius:100px;
box-shadow:0 0 3px rgba(0,0,0,.7);
}
#up{
float:right;
width:50px;
height:50px;
border-radius:100px;
background:#6fdb44;
/*box-shadow*/
box-shadow:-2px -2px 1px rgba(0,0,0,.6);
margin-right:18px;
margin-top:11px;
}
#down{
float:left;
width:50px;
height:50px;
border-radius:100px;
background:#039908;
margin:-14px 15px;
box-shadow:2px 2px 1px rgba(0,0,0,.6);
}
#mid{
float:left;
width:49px;
height:49px;
border-radius:100px;
background:#333;
margin-left:50px;
margin-top:-10px;
box-shadow:inset 0 0 10px #000;
}
@-moz-keyframes rotate{
0%{ -moz-transform:rotate(0deg);}
	100%{-moz-transform:rotate(-360deg);}
}
@-webkit-keyframes rotate{
0%{ -webkit-transform:rotate(0deg);}
	100%{-webkit-transform:rotate(-360deg);}
}
.wrapper{
 -moz-animation:rotate 2s ease infinite;
 -webkit-animation:rotate 2s ease infinite;
 animation:rotate 2s ease infinite;
}
.wrapper:nth-child(2){
	-moz-animation:rotate 2s linear infinite;
	-webkit-animation:rotate 2s linear infinite;
	animation:rotate 2s linear infinite;
}

demodownload

查看更多:http://cssdeck.com/labs/minimalist-css3-spinner

css3复选框

$
0
0
css3复选框

本实例主要应用了checkbox的:checked状态来设置其同级后面的label元素的样式及:before&:after生成的内容。所以我们看到的样式其实不是checkbox的,而是其同级后面的label元素的。

demodownload

html主要代码:

<span class="checkbox">
	<input type="checkbox">
	<label data-on="ON" data-off="OFF"></label>
</span>

css主要代码:

.checkbox {
  display:inline-block;
  position:relative;
  text-align:left;
  width:60px;
  height:30px;
  background-color:#222;
  overflow:hidden;
  -webkit-box-shadow:inset 0 1px 2px black,0 1px 0 rgba(255,255,255,0.1);
  -moz-box-shadow:inset 0 1px 2px black,0 1px 0 rgba(255,255,255,0.1);
  box-shadow:inset 0 1px 2px black,0 1px 0 rgba(255,255,255,0.1);
  -webkit-border-radius:6px;
  -moz-border-radius:6px;
  border-radius:6px;
}

.checkbox input {
  display:block;
  position:absolute;
  top:0;
  right:0;
  bottom:0;
  left:0;
  width:100%;
  height:100%;
  margin:0 0;
  cursor:pointer;
  opacity:0;
  filter:alpha(opacity=0);
  z-index:2;
}

.checkbox label {
  background-color:#3c3c3c;
  background-image:-webkit-linear-gradient(-40deg,rgba(0,0,0,0),rgba(255,255,255,0.1),rgba(0,0,0,0.2));
  background-image:-moz-linear-gradient(-40deg,rgba(0,0,0,0),rgba(255,255,255,0.1),rgba(0,0,0,0.2));
  background-image:-ms-linear-gradient(-40deg,rgba(0,0,0,0),rgba(255,255,255,0.1),rgba(0,0,0,0.2));
  background-image:-o-linear-gradient(-40deg,rgba(0,0,0,0),rgba(255,255,255,0.1),rgba(0,0,0,0.2));
  background-image:linear-gradient(-40deg,rgba(0,0,0,0),rgba(255,255,255,0.1),rgba(0,0,0,0.2));
  -webkit-box-shadow:0 0 0 1px rgba(0,0,0,0.1),0 1px 2px rgba(0,0,0,0.7);
  -moz-box-shadow:0 0 0 1px rgba(0,0,0,0.1),0 1px 2px rgba(0,0,0,0.7);
  box-shadow:0 0 0 1px rgba(0,0,0,0.1),0 1px 2px rgba(0,0,0,0.7);
  -webkit-border-radius:5px;
  -moz-border-radius:5px;
  border-radius:5px;
  display:inline-block;
  width:40px;
  text-align:center;
  font:bold 11px/28px Arial,Sans-Serif;
  color:#999;
  text-shadow:0 -1px 0 rgba(0,0,0,0.7);
  -webkit-transition:margin-left 0.2s ease-in-out;
  -moz-transition:margin-left 0.2s ease-in-out;
  -ms-transition:margin-left 0.2s ease-in-out;
  -o-transition:margin-left 0.2s ease-in-out;
  transition:margin-left 0.2s ease-in-out;
  margin:1px;
}

.checkbox label:before {
  content:attr(data-off);
}

.checkbox input:checked + label {
  margin-left:19px;
  background-color:#034B78;
  color:white;
}

.checkbox input:checked + label:before {
  content:attr(data-on);
}

demodownload

查看更多:http://cssdeck.com/labs/pure-css3-metal-checkbox


CSS3制作日历备忘录

$
0
0
CSS3制作日历备忘录

在发这个案例前,首先非常感谢藤藤加入w3cplus,今天开始w3cplus又多了一员猛将,我们会继续为大家制作一些实际可用的CSS3案例,帮助喜欢CSS3的同学一起学习和成长。今天这个案例就是藤藤(本来是要用藤藤的名发布,但由于我们设置还出了问题,所以先放上来让大家看看效果吧)制作的,将两张psd图转换到一个CSS3案例中。在这个案例中主要使用了:CSS3渐变制作日期的头部渐变效果;使用box-shadow制作了多层纸张的效果。

demodownload

HTML Code:

<div class="box" id="box">
	<h2>
		<a href="#" class="left"><<</a>
		<a href="#" class="right">>></a>
		June
	</h2>
	<ul class="cal">
		<li class="fgray">29</li>
		<li class="fgray">30</li>
		<li>1</li>
		<li>2</li>
		<li>3</li>
		<li>4</li>
		<li>5</li>
		<li>6</li>
		<li>7</li>
		<li>8</li>
		<li>9</li>
		<li class="pink">10</li>
		<li>11</li>
		<li>12</li>
		<li>13</li>
		<li>14</li>
		<li class="gray">15</li>
		<li>16</li>
		<li>17</li>
		<li>18</li>
		<li>19</li>
		<li>20</li>
		<li>21</li>
		<li>22</li>
		<li>23</li>
		<li>24</li>
		<li class="tip">25
			<div class="tooltipBox">
				<h2>Your Journey(2 items)</h2>
				<ul class="tooltip">
					<li>
						<div class="timg">
							<img src="http://www.w3cplus.com/sites/all/themes/marvin/logo.png" alt="大漠 前端攻城师">
						</div>
						<div class="ttext">
							http://www.w3cplus.com
						</div>
					</li>
					<li>
						<div class="timg">
							<img src="http://www.w3cplus.com/sites/all/themes/marvin/logo.png" alt="大漠 前端攻城师">
						</div>
						<div class="ttext">
							http://www.w3cplus.com
						</div>
					</li>
				</ul>
			</div>
		</li>
		<li>26</li>
		<li>27</li>
		<li>28</li>
		<li class="tip">29
			<div class="tooltipBox">
				<h2>Your Journey(2 items)</h2>
				<ul class="tooltip">
					<li>
						<div class="timg"><img src="http://www.w3cplus.com/sites/all/themes/marvin/logo.png" alt="大漠 前端攻城师"></div>
						<div class="ttext">http://www.w3cplus.com</div>
					</li>
					<li>
						<div class="timg"><img src="http://www.w3cplus.com/sites/all/themes/marvin/logo.png" alt="大漠 前端攻城师"></div>
						<div class="ttext">http://www.w3cplus.com</div>
					</li>
				</ul>
			</div>
		</li>
		<li>30</li>
		<li>31</li>
		<li class="fgray">1</li>
		<li class="fgray">2</li>
	</ul>
</div>

CSS Code

*{
	margin: 0;
	padding: 0;
}
body{
	background:url(data:image/jpeg...k=);
	font:12px 'Courgette', cursive; 
	color: #000; 
	line-height: 32px; 
	font-weight: bold;
	padding: 50px;
}
ul{ 
	list-style: none;
}
h2{ 
	font-size: 14px;
}
a{ 
	color:#fff; 
	text-decoration: none; 
	letter-spacing: -3px;
}
.left{ 
	float: left;
}
.right{
	float:right;
}
.box{ 
	width: 211px;  
	padding: 4px; 
	box-shadow: 0 1px 1px #ebedea; 
	margin:50px auto; 
	background: #a2a4a1; 
	border-radius: 5px;
}
.box > h2{ 
	margin:0 -1px 0 0; 
	border:1px solid #41531d; 
	box-shadow:inset 0 1px 1px #a5ce55; 
	border-radius: 3px 3px 0 0;
	padding:0 8px; 
	text-align: center; 
	color: #fff; 
	text-shadow:0 -1px 0px #999; 
	height: 32px;	
	background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(146,183,74,1)), color-stop(100%,rgba(100,134,34,1)));
	background-image: -webkit-linear-gradient(top, rgba(146,183,74,1) 0%, rgba(100,134,34,1) 100%);
	background-image: -moz-linear-gradient(top, rgba(146,183,74,1) 0%, rgba(100,134,34,1) 100%);
	background-image: -o-linear-gradient(top, rgba(146,183,74,1) 0%, rgba(100,134,34,1) 100%);
	background-image: -ms-linear-gradient(top, rgba(146,183,74,1) 0%, rgba(100,134,34,1) 100%);
	background-image: linear-gradient(top, rgba(146,183,74,1) 0%, rgba(100,134,34,1) 100%);
}
.box .cal:after,
.box .cal:before {
	content:"";
	display: table;
}
.box .cal:after {
	clear:both;
	overflow: hidden;
}
.box .cal{ 
	border-radius: 0 0 5px 5px; 
	border:1px solid #818380; 
	font-size: 0; 
	background: #fff; 
	box-shadow:0 1px 1px #d9d9d9,0 2px 1px #555; 
	margin-right: -1px; 
	zoom: 1;
}

.box .cal > li{  
	float:left; 
	width:29px;
	border-right: 1px solid #ccc; 
	border-top: 1px solid #ccc; 
	text-align: center; 
	font-size: 12px;
	cursor:pointer;
}
.box .cal > li:nth-of-type(7n){ 
	border-right: none;
}	
.fgray{ 
	color: #ccc;
}
.tip{ 
	position: relative;
	color:orange;
}
.tip:after{ 
	display: block; 
	content: ""; 
	position: absolute; 
	border:4px solid orange; 
	border-color:orange orange transparent transparent ; 
	top: 0; 
	right: 0; 
}
.gray,
.pink{ 
	position: relative;
}
.pink{
	color: #a55353; 
	background: #fff6f6;
}
.gray{
	background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(216,216,216,1)), color-stop(100%,rgba(255,255,255,1)));
	background-image: -webkit-linear-gradient(top, rgba(216,216,216,1) 0%, rgba(255,255,255,1) 100%);
	background-image: -moz-linear-gradient(top, rgba(216,216,216,1) 0%, rgba(255,255,255,1) 100%);
	background-image: -o-linear-gradient(top, rgba(216,216,216,1) 0%, rgba(255,255,255,1) 100%);
	background-image: -ms-linear-gradient(top, rgba(216,216,216,1) 0%, rgba(255,255,255,1) 100%);
	background-image: linear-gradient(top, rgba(216,216,216,1) 0%, rgba(255,255,255,1) 100%);

}
.gray:before,
.pink:before{
	content: "·"; 
	position:absolute; 
	display:block; 
	font-size: 16px; 
	top: 10px; 
	left: 50%; 
	margin-left:-3px;
	font-family: "Microsoft YaHei";
}
.gray:before{ 
	color: #d8d8d8;
}
.pink:before{ 
	color: #e5a9a9;
}

.tooltipBox{ 
	position: absolute; 
	top:32px; 
	left:-15px; 
	z-index: 99; 
	display: none;
	width: 215px; 
	background: #eaeff5; 
	border:1px solid #64777e;  
	border-radius:5px; 
	box-shadow:0 1px 0 #cdd5d8,0 2px 0 #64777e,0 3px 0 #cdd5d8,0 4px 0 #64777e;
}
.box .cal > li:hover .tooltipBox{ 
	display: block;
}
.tooltipBox:after,
.tooltipBox:before{ 
	position: absolute; 
	display: block; 
	content: ""; 
	border-style: solid;
}
.tooltipBox:after{ 
	border-width: 10px; 
	border-color: transparent  transparent #64777e; 
	top: -20px; 
	left: 20px;
	z-index: 2;
}
.tooltipBox:before{ 
	border-width: 8px; 
	border-color:transparent  transparent #717f8a; 
	top:-16px; 
	left: 22px; 
	z-index: 3;
}
.tooltipBox > h2{ 
	background: #717f8a; 
	line-height: 40px; 
	color: #fff; 
	border-radius:  4px 4px 0 0; 
	text-indent: 1em;
}
.tooltip li{ 
	min-height: 36px; 
	padding: 5px; 
	border-bottom: 1px solid #a8adb1; 
	box-shadow: 0 1px 1px #fff; 
	color: #232323;
}
.tooltip li:last-child{ 
	border-bottom: none; 
	box-shadow: none;
}
.timg{ 
	width:36px; 
	height: 36px; 
	float: left; 
	margin-right: 10px;
	background: #232323; 
	border-radius: 5px; 
	overflow: hidden;
}
.timg img{ 
	width: 36px; 
	height: 36px;
}
.ttext {
	overflow: hidden;
	zoom:1;
}

demodownload

如需转载,烦请注明出处:http://www.w3cplus.com/demo/create-calendar-with-css3.html

css3动画——垃圾桶

$
0
0
css3动画——垃圾桶

首先非常感谢丸子大师(http://i.wanz.im/)提供这个案例的DEMO源码。这是一个使用CSS3的transform和transition制作的一个动画效果,当鼠标处于悬停状态时,垃圾桶会打开,有一个小卡通被丢进垃圾桶。创意很有意思,实现很简单。如果丸子在花点时间将demo中的图片换成用css3写,就是一个纯CSS3的动画DEMO了,还有一个地方可以改变的,就是不用三个标签,使用CSS3的":before"和":after"来代替里面的子元素。这样就省去两个标签,有兴趣的同学可以尝试一下,在丸子的基础上进行修改,做成后,你会有一种成就感的。

demodownload

HTML 代码

<div class="trashbin">
  <div class="lid"></div>
  <div class="can"></div>
</div>

CSS 代码

.trashbin {
	width: 128px;
	height: 128px;
	margin: 100px auto;
	-webkit-transition:background-position 0.3s ease-in;
	background: url(http://res.wanz.im/images/smile.gif) center no-repeat;
}
.trashbin .lid{
	background: url(http://res.wanz.im/images/trash.png) 0 0 no-repeat;
	height: 38px;
	-webkit-transition:-webkit-transform 0.3s ease-in;
	-webkit-transform: rotateZ(0) translate(0px, 0px);
}
.trashbin:hover{
	-webkit-transition:background-position 0.3s ease-in;
	background-position: center top; 
}
.trashbin:hover .lid{
	-webkit-transition:-webkit-transform 0.3s ease-in;
	-webkit-transform: rotateZ(-45deg) translate(0px, -40px);
}
.trashbin .can{
	background: url(http://res.wanz.im/images/trash.png) 0 -38px no-repeat;
	height: 90px;
}

请使用Webkit内核浏览器浏览,如果您使用的是其他浏览器,请在源码中加上对应的浏览器前缀。

demodownload

非常感谢丸子为W3cplus提供DEMO。

如需转载,烦请注明出处:http://www.w3cplus.com/demo/create-transhbin-with-css3.html

CSS3制作时钟

$
0
0
CSS3制作时钟

这个效果是一个CSS3制作的时钟,不过并不是我们传统的时钟风格,分别用三块显示时、分、秒三个部分,而且这个DEMO中藤藤还为其加上了一个js的效果,能让这个效果和现实时钟的时间同步。这个效果运用到的CSS3知识点就是渐变、阴影,而最为关键的就是CSS3的渐变制作。

demodownload

HTML结构

<div class="box">
  <ul>
    <li><span id="hour"></span><span>Hours</span></li>
    <li><span id="minute"></span><span>Minutes</span></li>
    <li><span id="second"></span><span>Seconds</span></li>
  </ul>
</div>

CSS代码

body,ul,li{ 
  padding: 0; 
  margin:0;
}
a {
  color: rgb(1, 124, 185);
  text-decoration: none;
}
body{ 
  font-size:16px; 
  color: #5a5d63;
  background: #d6d7d9; 
  background: -webkit-radial-gradient(#eeefef, #d6d7d9);
  background: -moz-radial-gradient(#eeefef, #d6d7d9);
  background: -o-radial-gradient(#eeefef, #d6d7d9);
  background: -ms-radial-gradient(#eeefef, #d6d7d9);
  background: radial-gradient(#eeefef, #d6d7d9);
  padding: 50px;
}
.box{ 
  width: 540px; 
  height: 200px; 
  margin: 50px auto;
}
.box li{ 
  position: relative; 
  text-align: center; 
  list-style-type: none; 
  display: inline-block; 
  width: 150px; 
  height:160px;
  text-shadow:0 2px 1px #f4f4f4;  
  border:1px solid #9fa2ad; 
  border-radius: 5px; 
  margin-right:10px;
  background: -webkit-gradient(linear,0 0, 0 100%,
    color-stop(.2,rgba(248,248,248,.3)),
    color-stop(.5,rgba(168,173,190,.5)),
    color-stop(.51,rgba(168,173,190,.3)),
    color-stop(.9,rgba(248,248,248,.2))); 
  background: -webkit-linear-gradient(top,rgba(248,248,248,.3) 20%,rgba(168,173,190,.5) 50%,	rgba(168,173,190,.3) 51%,rgba(248,248,248,.2) 90%); 	
  background: -moz-linear-gradient(top,	rgba(248,248,248,.3) 20%,rgba(168,173,190,.5) 50%,	rgba(168,173,190,.3) 51%,rgba(248,248,248,.2) 90%); 	
  background: -o-linear-gradient(top,rgba(248,248,248,.3) 20%,rgba(168,173,190,.5) 50%,	rgba(168,173,190,.3) 51%,rgba(248,248,248,.2) 90%); 	
  background: -ms-linear-gradient(top,	rgba(248,248,248,.3) 20%,rgba(168,173,190,.5) 50%,rgba(168,173,190,.3) 51%,rgba(248,248,248,.2) 90%); 	
  background: linear-gradient(top,rgba(248,248,248,.3) 20%,rgba(168,173,190,.5) 50%,rgba(168,173,190,.3) 51%,rgba(248,248,248,.2) 90%); 	
  box-shadow:inset 0 -2px 0 #f1f1f1,0 1px 0 #f1f1f1,0 2px 0 #9fa2ad,0 3px 0 #f1f1f1,0 4px 0 #9fa2ad;
}
.box li:before,
.box li:after{
  display: block;
  content: ""; 
  position: absolute;
  width: 150px;
}
.box li:before{
  top:50%; 
  height: 1px; 
  box-shadow: 0 1px 0 #868995,0 2px 1px #fff;
}
.box li:after{ 
  bottom: -65px;  
  height: 60px; 
  border-radius:0 0 5px 5px; 
  background: -webkit-gradient(linear,0 0,0 100%,from(rgba(0,0,0,.1)),to(rgba(0,0,0,0))); 
  background: -webkit-linear-gradient(top,rgba(0,0,0,.1),rgba(0,0,0,0)); 
  background: -moz-linear-gradient(top,rgba(0,0,0,.1),rgba(0,0,0,0)); 
  background: -o-linear-gradient(top,rgba(0,0,0,.1),rgba(0,0,0,0)); 
  background: -ms-linear-gradient(top,rgba(0,0,0,.1),rgba(0,0,0,0)); 
  background: linear-gradient(top,rgba(0,0,0,.1),rgba(0,0,0,0)); 
  z-index: 1
}
.box li span:first-child{ 
  font:120px 'BitstreamVeraSansMonoBold'; 
  color: #52555a; 
  display: block; 
  height: 130px; 
  line-height: 150px; 
}
@font-face {
  font-family: 'BitstreamVeraSansMonoBold';
  src: url('VeraMono-Bold-webfont.eot');
  src: url('VeraMono-Bold-webfont.eot?#iefix') format('embedded-opentype'),
       url('VeraMono-Bold-webfont.woff') format('woff'),
       url('VeraMono-Bold-webfont.ttf') format('truetype'),
       url('VeraMono-Bold-webfont.svg#BitstreamVeraSansMonoBold') format('svg');
  font-weight: normal;
  font-style: normal;
}

JS代码

var hour=document.getElementById('hour');
var minute=document.getElementById('minute');
var second=document.getElementById('second');

function showTime(){

  var oDate=new Date(); 
  var iHours=oDate.getHours();
  var iMinute=oDate.getMinutes();
  var iSecond=oDate.getSeconds();

  hour.innerHTML=AddZero(iHours);
  minute.innerHTML=AddZero(iMinute);
  second.innerHTML=AddZero(iSecond);
	
}

showTime();

setInterval(showTime,1000);

function AddZero(n){

  if(n<10){

    return '0'+n;
	
  }
	
   return ''+n;
}

demodownload

如需转换,烦请注明出处:http://www.w3cplus.com/demo/create-time-with-css3.html

CSS3制作下拉菜单

$
0
0
CSS3制作下拉菜单

导航菜单其实是没有什么可说的,制作方法到处可见,今天这个案例本来不只是一个导航,还有一个搜索表单的,可是为了偷懒,把搜索表单部分去掉了,就变成了一个CSS3制作的下拉菜单。在这个导航中主要两点,一个是渐变运用,另一个就是box-shodow制作的立体效果。

demodownload

HTML 结构

<ul id="nav">
  <li><a href="#">Home</a></li>
  <li>
    <a href="#">Portfolio</a>
    <ul class="sub-menu">
      <li><a href="#">Identity</a></li>
      <li><a href="#">Print</a></li>
      <li><a href="#">Online</a></li>
    </ul>
  </li>
  <li><a href="#">About</a></li>
  <li><a href="#">Contact</a></li>
  <li><a href="#">W3cplus</a></li>
</ul>

CSS代码

*{
  margin: 0;
  padding: 0;
}
body {
  padding: 50px;
  background: url(data:image/j...);
  font-family: 'Jockey One', sans-serif;
  color: #fff;
}
a {
  color: rgb(1, 124, 185);
  text-decoration: none;
}
li {
  list-style: none outside none;
}
#nav:after,
#nav:before {
  content:"";
  display: table;
}
#nav:after {
  clear:both;
  overflow: hidden;
}
#nav {
  zoom: 1;
  margin: 50px auto;
  width: 530px;
}
#nav > li{
  float: left;
  display: inline;
  border-right: 1px solid #848d95;
  border-left: 1px solid #e3e8ec;
  box-shadow: 0 1px 0 rgba(84,95,109,0.75),0 2px 0 rgba(84,95,109,0.75),0 3px 0 rgba(84,95,109,0.75);
  position: relative;
  background-color: #c5cfd8; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2M1Y2ZkOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM5Y2E4YjEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);  background-image: -moz-linear-gradient(top,  #c5cfd8 0%, #9ca8b1 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c5cfd8), color-stop(100%,#9ca8b1)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #c5cfd8 0%,#9ca8b1 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #c5cfd8 0%,#9ca8b1 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #c5cfd8 0%,#9ca8b1 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #c5cfd8 0%,#9ca8b1 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c5cfd8', endColorstr='#9ca8b1',GradientType=0 ); /* IE6-8 */
  -webkit-transition: all 0.25s ease-in .0038s;
  -moz-transition: all 0.25s ease-in .0038s;
  -o-transition: all 0.25s ease-in .0038s;
  transition: all 0.25s ease-in .0038s;
}

#nav li:first-child {
  border-left: none;
  border-radius:  5px 0 0 5px;
}
#nav li:last-child {
  border-radius: 0 5px 5px 0;
  border-right: none;
}
#nav li:last-child::after {
  display: none;
}
#nav .sub-menu {
  position: absolute;
  right: 0;
  left: -1px;
  top: 100%;
  border-radius: 0 0 5px 5px;
  box-shadow: 0 1px 0 rgba(84,95,109,0.75),0 2px 0 rgba(84,95,109,0.75),0 3px 0 rgba(84,95,109,0.75);
  background-color: #d9e0e5; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2Q5ZTBlNSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNjNWNkZDMiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);  background-image: -moz-linear-gradient(top,  #d9e0e5 0%, #c5cdd3 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d9e0e5), color-stop(100%,#c5cdd3)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #d9e0e5 0%,#c5cdd3 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #d9e0e5 0%,#c5cdd3 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #d9e0e5 0%,#c5cdd3 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #d9e0e5 0%,#c5cdd3 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d9e0e5', endColorstr='#c5cdd3',GradientType=0 ); /* IE6-8 */
  display: none;
}
#nav > li:hover {
  background-color: #d8dfe4; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIxJSIgc3RvcC1jb2xvcj0iI2Q4ZGZlNCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNkNWRlZTQiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);  background-image: -moz-linear-gradient(top,  #d8dfe4 1%, #d5dee4 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#d8dfe4), color-stop(100%,#d5dee4)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #d8dfe4 1%,#d5dee4 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #d8dfe4 1%,#d5dee4 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #d8dfe4 1%,#d5dee4 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #d8dfe4 1%,#d5dee4 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d8dfe4', endColorstr='#d5dee4',GradientType=0 ); /* IE6-8 */
  position: relative;
  top: 3px;
  border-right-color: #848d95;
  box-shadow: -1px 0 0 #848d95;
  color: #2281cd;
}
#nav li:hover > ul {
  display: block;
}

#nav a {
  display: block;
  float: left;
  padding: 15px 30px;
  font-size: 16px;
  color: #2d2f38;
  text-shadow: 0 1px 0 rgba(225,232,235,0.75);
  -webkit-transition: all 0.25s ease-in .0038s;
  -moz-transition: all 0.25s ease-in .0038s;
  -o-transition: all 0.25s ease-in .0038s;
  transition: all 0.25s ease-in .0038s;
}
#nav a:hover {
  color: #2281cd;
}
#nav .sub-menu a {
  color: #2d2f38;
  font-size: 14px;
  padding: 10px 30px;
  float: none;
}
#nav .sub-menu a:hover {
  background-color: #a4b0ba; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2E0YjBiYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjQlIiBzdG9wLWNvbG9yPSIjZDVkZWU0IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2I1YzBjOSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);  background-image: -moz-linear-gradient(top,  #a4b0ba 0%, #d5dee4 4%, #b5c0c9 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a4b0ba), color-stop(4%,#d5dee4), color-stop(100%,#b5c0c9)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #a4b0ba 0%,#d5dee4 4%,#b5c0c9 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #a4b0ba 0%,#d5dee4 4%,#b5c0c9 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #a4b0ba 0%,#d5dee4 4%,#b5c0c9 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #a4b0ba 0%,#d5dee4 4%,#b5c0c9 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a4b0ba', endColorstr='#b5c0c9',GradientType=0 ); /* IE6-8 */
  box-shadow: 0 1px 0 rgba(255,255,255,0.75),inset 0 2px 6px rgba(69,78,90,0.15);
}
#nav .sub-menu li:last-child a:hover {
  border-radius: 0 0 5px 5px;
}

demodownload

如需转载,烦请注明出处:http://www.w3cplus.com/demo/create-nav-menu-with-css3.html

CSS3质感分析——表面线性渐变

$
0
0

W3cplus有关于CSS3的教程在国内来说算是比较多,也比较全的了,有理论介绍,也有实例分析。但有关于质感这种细节上的分析文章还没有写过。由于自己的美感较差,也不敢班门弄斧,恐怕误人子弟。今天由好友99客串W3cplus,由他向大家介绍一些有关于这方面的知识,希望大家喜欢,更希望这系列文章对大家今后的工作与设计有所帮助。

所谓质感。。。其实我也不知道怎么说,可以叫做 立体感,或者光感吧。。。作为前端,最怕的不是切什么图,其实是要把设计师的设计利用代码css3化表现出来,写过的css3效果也多不胜数了- -最近总结下,如何做类似的“质感”效果。这个系列我准备分析以下几种质感:

表面的颜色微凸感

单层牌匾立体效果

单层外侧盒子立体效果

多层立体效果

表面质感立体效果

光感动画效果

之后的文章,会详细分析网上流行的css3的一些质感效果,让大家不再恐惧Css3,最终可以见到一张图片就可以构思出他的css3实现!文章中主要用的工具:

markman标注神器。hypersnap7截图工具,新版本已经好用到极点了 chrome developer也就是chrome的F12  FB弱爆了..

css3在线渐变http://www.colorzilla.com/gradient-editor/

css3  http://www.css3maker.com/

1.表面渐变的立体感

分析第一张图 ,可以看到白色区域持续了25%左右,之后线性渐变到e6e6e6,(神马,你要问我怎么分析的。。其实在chrome控制台去掉按钮的文字,宽高padding加大就是了- -)

注意 持续,在css3线性渐变可以写作color-stop,之后我们利用生成器生成代码

background: rgb(254,255,255); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(254,255,255,1) 0%, rgba(255,255,255,1) 25%, rgba(230,230,230,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(254,255,255,1)), color-stop(25%,rgba(255,255,255,1)), color-stop(100%,rgba(230,230,230,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(254,255,255,1) 0%,rgba(255,255,255,1) 25%,rgba(230,230,230,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(254,255,255,1) 0%,rgba(255,255,255,1) 25%,rgba(230,230,230,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(254,255,255,1) 0%,rgba(255,255,255,1) 25%,rgba(230,230,230,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(254,255,255,1) 0%,rgba(255,255,255,1) 25%,rgba(230,230,230,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#feffff', endColorstr='#e6e6e6',GradientType=0 ); /* IE6-9 */

这是多么长的一坨啊- -

第二张图其实也很简单的。。虽然这个颜色我不知道,但我不会抄啊。。

  你要问为啥会标出#8f0222 我也不是很清楚- -  查看代码应该是44%左右的渐变,于是我们继续生成一个渐变代码

background: rgb(168,3,41); /* Old browsers */
background: -moz-linear-gradient(top,  rgba(168,3,41,1) 0%, rgba(143,2,34,1) 44%, rgba(109,0,25,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(168,3,41,1)), color-stop(44%,rgba(143,2,34,1)), color-stop(100%,rgba(109,0,25,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  rgba(168,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  rgba(168,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  rgba(168,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); /* IE10+ */
background: linear-gradient(to bottom,  rgba(168,3,41,1) 0%,rgba(143,2,34,1) 44%,rgba(109,0,25,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a80329', endColorstr='#6d0019',GradientType=0 ); /* IE6-9 */

这又是多么长的一坨。。

玻璃效果

这是非常常见跟实用的效果,可以在大部分网站看到,包括苹果等。这类的效果很明显会发现在中间有个颜色突变,一般是50%是渐变色,51% 突变为另一种颜色。一般51%部分的颜色比上面要略深一点

因此我们可以写四个渐变点,仍然是线性渐变。

background: #eec2c7; /* Old browsers */
background: -moz-linear-gradient(top,  #eec2c7 0%, #d24d5c 50%, #ba2737 51%, #ee8894 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#eec2c7), color-stop(50%,#d24d5c), color-stop(51%,#ba2737), color-stop(100%,#ee8894)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #eec2c7 0%,#d24d5c 50%,#ba2737 51%,#ee8894 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #eec2c7 0%,#d24d5c 50%,#ba2737 51%,#ee8894 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #eec2c7 0%,#d24d5c 50%,#ba2737 51%,#ee8894 100%); /* IE10+ */
background: linear-gradient(to bottom,  #eec2c7 0%,#d24d5c 50%,#ba2737 51%,#ee8894 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eec2c7', endColorstr='#ee8894',GradientType=0 ); /* IE6-9 */

中间高光

这一类也是线性渐变的典型。我们要写五个渐变点,他的中间区域是高光区域。其实注意到1e589b跟1e589a两个颜色,这两个其实是无所谓的,跟边角相似即可,甚至相同也可以。生成了个类似代码,不用纠结里面的颜色。  这个渐变设计的要点是  中间的颜色要亮,并且不要一直过渡过去,前面20% 80%左右要有个缓冲。

background: #1e5799; /* Old browsers */
background: -moz-linear-gradient(top,  #1e5799 20%, #2989d8 50%, #1e5799 80%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(20%,#1e5799), color-stop(50%,#2989d8), color-stop(80%,#1e5799)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #1e5799 20%,#2989d8 50%,#1e5799 80%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #1e5799 20%,#2989d8 50%,#1e5799 80%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #1e5799 20%,#2989d8 50%,#1e5799 80%); /* IE10+ */
background: linear-gradient(to bottom,  #1e5799 20%,#2989d8 50%,#1e5799 80%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#1e5799', endColorstr='#1e5799',GradientType=0 ); /* IE6-9 */

大家可以尝试做做以下的效果,利用上面的知识即可搞定~

Click on this image to see a DEMO

总结  表面渐变颜色的取值是开始写表面质感的朋友最纠结的地方,其实完全可以不用太在意颜色,只要思路对了,渐变拐点打好了,可以轻松作出各种表面的质感效果

注意貌似有不少人对生成的渐变不太理解,我给个公式吧,来转换rgb颜色 rgb(255,255,255,0.6)与hex颜色 。之前的博客有讲过颜色转换  http://99jty.com/?p=573

下面是透明度+颜色

/*
* StartColorStr 和 EndColorStr:
* #4c000000 是 30% 透明度的 #000000 的意思
* 组成: # + 透明度 + 颜色
* 算法: Math.floor(0.6 * 255).toString(16);
*/
background:rgba(0, 0, 0, 0.65);
filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr='#99000000', EndColorStr='#99000000

特别声明,这篇文章是由我的好友99写的,特别放到W3cplus与大家分享他的学习心得,希望大家能在文章中有所收获。您也可以点击原文阅读。W3cplus后续会持续发布相关文章,喜欢的同学请观注w3cplus的有关更新。

如需转载烦请注明出处:http://www.w3cplus.com/css3/surface-linear-gradient-with-css3-part1.html 同时注明作者:http://99jty.com/?p=763

CSS3质感分析——牌匾与盒子

$
0
0

99在《CSS3质感分析——表面线性渐变》主要介绍了CSS3中渐变对设计的影响。今天99为大家接着介绍有关于光源对设计上的影响,详细的请继续往下阅读:

css3质感系列会详细分析网上流行的css3的一些质感效果,让大家不再恐惧Css3,最终可以见到一张图片就可以构思出他的css3实现!

注:文章中主要用的工具:markman  标注神器。   hypersnap7  截图工具,新版本已经好用到极点了    chrome developer  也就是chrome的F12  FB弱爆了..

css3在线渐变http://www.colorzilla.com/gradient-editor/

css3  http://www.css3maker.com/

今天主要讲解以下效果:

金属盒子阴影

盒子阴影是非常常见的质感效果,实现方法也比较多。在这里介绍两种常用的方法:边框+box-shadow Y轴阴影法。

首先复习下box-shadow:

box-shadow的四个参数:x-offset(x轴偏移)、y-offset(y轴偏移)、blur (模糊值)、color of shadow(阴影颜色)和sqaure (阴影扩展半径)。

详细的介绍可以参阅:《CSS3 box-shadow》一文

要写类似效果,这个需要熟练背诵的。首先我们建立一个盒子:

.box{
	width:100px;
	height:100px;
	background-color: #3BB3E0;
	border-radius:5px;
	border:1px solid #000;
}

拿到一个带边框的盒子。注意,我们要记录下盒子内部的颜色大背景颜色。两者缺一不可!!

之后,我们利用 box-shadow的多重设置功能,配合Y轴,设置上边的内侧阴影,及下边的外侧阴影

box-shadow: inset 0px 1px 0px #96E4FF, 0px 1px 0px #696363;

 注意,第一个inset的颜色要浅于内部盒子的颜色。第二个外层阴影也要浅于外层背景的颜色。注意我把 Y轴设置为1px,其他参数都不要设置。(其实设置了也没啥不好的,会造成干扰,但是可能会得到意想不到的效果。)

效果不解释了。。

再找个栗子。。。

其实等于

box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.14),0 1px 1px rgba(255, 255, 255, 0.15);

你可能要问,卧槽,0.14跟0.15是尼玛啥啊。。。其实是唬人的东西,其实就是个白色,这样调节可以透明度降低,变相等于把颜色调浅了。不信,我们改成1

是不是比他以前写的更加碉堡了!!所以,不要迷信代码,要理解自己写出来的东西。

第二种更加简单一些。

可以先思考下怎么做的。。。。。。

这下明白了吧。。。代码不用解释了,哈哈。。

border-bottom: 1px solid #333;
border-left: 1px solid black;
border-right: 1px solid #333;
border-top: 1px solid black;

再来几个,大家可以体会下

border-bottom: 1px solid black;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.13),inset 0 1px 0 rgba(255, 255, 255, 0.13);

注意最外层的圆角边框是属于父级的。 最内层也不要被 0.13之类的值忽悠了。

实质还是:黑色边框+Y轴的box-shadow 内外层叠加

再来个例子

box-shadow: inset 0px 1px 1px #909193, 0px 1px 0px white;

99在上面简单明了的为大家介绍了一些有关于光源对设计的影响,不知道大家理解了多少。个人建议,要想掌握真功夫,还得下多下苦功夫。只有自己动手一试才知道是怎么回事。

特别注明一下,上面使用的例子,大家可以参考:W3cplus的案例

有关于“牌匾与盒子”方面介绍,99就为大空介绍到这里,期待他的下回讲解。再次感谢99给我们带来这么好的心得分享。

如需转载烦请注明出处:http://www.w3cplus.com/css3/surface-linear-gradient-with-css3-part2.html 同时注明作者:http://99jty.com/?p=781

5个简单,但非常有用的属性

$
0
0

Webdesignerwall.com逛时,看到一篇文章《5 Simple, But Useful CSS Properties 》一文,细看以之后真的很有用,这几个属性大家都有见过,也很常用,但有几个人会认为他很有用呢?不信,我们来一起看看。

5 Simple, But Useful CSS Properties 》原文是这么描述的

“这篇文章是关于5个用的CSS属性,你应该非常的熟悉,但很有机能你很少在使用。我不是在讨论CSS3的新属性,我所指的是CSS2中的老属性:clip,min-height,white-space,cursor和display。这些属性都得到浏览器的广泛支持。所以,不要错过这篇文章,因为你可能会惊讶的发现这5个属性是多么的有用。“

我看了之后也觉得很惊讶,很有意思,属性虽然简单,但有时候我们往往忽略这些简单属性的运用,于是今天我借花献佛,将这篇文章简单的译成中文,放在w3cplus上,希望对同学们有所帮助。

1、clip

clip属性就像一个朦板一样,它允许你的让元素的内容在这一个矩形的图形中。使用clip属性时你需要注意两点:第一将元素设置为“position:absolute”;第二指定元素的定位值“top,right,bottom,left”,如图所示:

接下来看两个实例:

图片剪切(DEMO

这个实例是用clip来制作一个图片剪切的效果,首先你要在图片的父元素,例如“<div>”上定义属性“position:relative”,接下来在“<img>”上定义“position:absolute”,并使用rect的属性值,如:

具体代码如下所示:

.clip {
  position: relative;
  height: 130px;
  width: 200px;
  border: solid 1px #ccc;
}
.clip img {
  position: absolute;
  clip: rect(30px 165px 100px 30px);
}

上面效果是直接剪切图片,但有时候我们还想让图片进行比例的剪切,那么只需要在上面的案例基础上做一下调整,具体看下面的案例

图片缩放与剪切(DEMO

在这个DEMO中,缩放显示图片,首先默认图片是一张矩形图片,并在这个基础上实现50%的缩放。因此在这处图片设置了一个“width”和“height”值,并使用clip属性进行剪切,如:

对应代码如下:

.gallery li {
  float: left;
  margin: 0 10px 0 0;
  position: relative;
  width: 70px;
  height: 70px;
  border: solid 1px #000;
}
.gallery img {
  width: 100px;
  height: 70px;
  position: absolute;
  clip: rect(0 85px 70px 15px);
  left: -15px;
}

注意,在IE8以及其以下的版本,在使用clip属性时需要注意语法:

clip (top,right,bottom,left);

用逗号将其分开才会有效。

有关于图片的缩放效果,早期w3cplus在《纯CSS制作缩略图片》也做过详细介绍,其中一种方法就是使用今天介绍的clip制作的,有兴趣的同学可以看看。

2、最小高度min-height(DEMO)

“min-height”属性可以让你确定一个元素的最小高度(IE6下需要另外处理),这个属性在制作布局中是非常有用的,比如说当你主内容区内容不够撑高容器与侧栏相同或者比侧栏高时,这个最小高度就很有用处,如:

代码很简单:

.with_minheight {
  min-height: 550px;
}

由于IE6不支持min-height属性,所以在IE6下我们需要做一定的处理:

.with_minheight {
  min-height:550px;
  height:auto !important;
  height:550px;
}

详细的可以参考最小高度兼容代码,min-height

3、white-space(DEMO)

"white-space"属性主要用来控制元素的文本,例如,指定"white-space:nowrap"让你的文本不换行,如下面的示例图:

代码示例:

em {
  white-space: nowrap;
}

有关于更详细的介绍,大家可以点我

4、cursor(DEMO)

如果你对一个按钮改变了操作行为,最好也将鼠标形状也做一定的修改。例如,当你的按钮处理“禁用”时,你就应该将默认的鼠标变成不可点击(箭头)。如:

一起看一个简单的示例代码:

.disabled {
  cursor: default;
}

.busy {
  cursor: wait;
}

.clickable:hover {
  cursor: pointer;
}

5、display inline/block(DEMO)

“display”属性大家应该常用,我们可以使用这个属性,改变元素的显示风格,比如说通过“display”的“inline”将块元素变为行内元素,也可以通过“display”的“block”将行内元素变成块元素,如

示例代码如下所示:

.block em {
  display: block;
}

.inline h4, .inline p {
  display: inline;
}

这五个属性是不是很简单,你有经常使用吗?或者说你会这么用吗?要是还没有,赶快动手吧。

英文地址:http://webdesignerwall.com/tutorials/5-simple-but-useful-css-properties

如需转载,烦请注明:http://www.w3cplus.com/css/5-simple-but-useful-css-properties.html


藤藤每日一练——CSS3制作登录表单

$
0
0
藤藤每日一练——CSS3制作登录表单

W3cplus从今天刚开推出藤藤练习的CSS3系列。出这个系列主要是为了让同样有着CSS3兴趣的同学更有动力,在这个系列中都是由W3cplus美女成员藤藤每天根据国外搜集的有关psd设计图,然后将设计图通过css3的代码转换成DEMO案例。一是为了自己提高,二是与其他有同样爱好的同学一起分享。如果你喜欢,那就持续关注w3cplus的有关更新。

这个案例主要制作的是一个登录表单,在这个案例中使用了box-shadow、gradient,transform和transition等属性,其中最难的地方是输入框被咬的那部分,原本使用纯CSS3的渐变配合多背景制作,但受限于阴影,最终改变使用base的64位图像处理。详细的参考代码吧:

demodownload

HTML 结构:

<div class="box">
  <form action="#" method="get">
    <ul>
      <li>
        <label for="username">Email:</label><input type="text" id="username"  class="username" placeholder="john.smith@strategysoft.com"/>
      </li>
      <li>
        <label for="password">Password:</label><input type="password" id="password" class="password" placeholder="******"/>
      </li>
     </ul>
     <a href="javascript:;" class="button"/><i class="icon-arrow-right"></i></a>
  </form>
</div>

CSS代码:

body,ul{ 
	margin: 0; 
	padding: 0
}
a {
	color: rgb(1, 124, 185);
	text-decoration: none;
}
input:focus {
	outline: none 0;
}
body{ 
	color: #b5b5b5; 
	font: 14px 'Arial';
}
body,
li:first-child:after,
li:last-child:after{
	background-image: url(data:image/png;base64,...);/**/
}
.box{ 
	position: relative; 
	width: 384px; 
	height: 140px; 
	margin: 50px auto;
}
.box li{ 
	list-style-type: none; 
	margin-bottom: 10px; 
	border-radius: 5px; 
	overflow: hidden; 
	position: relative; 
	height: 42px;
}
.box li input{
	box-shadow:inset 0 0 5px rgba(0,0,0,.5),-1px 1px 0 rgba(255,255,255,.05); 
	border:0 none; 
	padding:8px 5px 5px;  
	border-radius: 5px; 
	width:300px;  
	height: 28px;
	-webkit-box-sizing: content-box;
	-moz-box-sizing: content-box;
	-o-box-sizing: content-box;
	-ms-box-sizing: content-box;
	box-sizing: content-box;
	background: rgba(0,0,0,.1); 
	color: #fff;
} 

.box li:first-child:after,
.box li:last-child:after{ 
	position: absolute;
	width: 50px; 
	height: 50px; 
	content: ""; 
	border-radius: 25px;
	z-index: 2; 
	right: -23px;
	box-shadow: 0 0 8px rgba(0,0,0,.5);
}
::-webkit-input-placeholder { 
	color:#fff; 
	font-weight: bold;
}
.box li:first-child:after{
	top: 15px;
}
.box li:last-child:after{
	bottom:15px;
}
.box label{ 
	width: 70px; 
	display: inline-block; 
	text-align: right;
}
.box span{ 
	display: block; 
	color: #6296b4; 
	padding-left: 75px;
}
.button{ 
	position: absolute; 
	top: 24px; 
	right: -30px; 
	width: 44px; 
	height: 44px; 
	border-radius: 22px; 
	border:1px solid #00a1d2; 
	background: -webkit-linear-gradient(top,#029ecd,#0d7796); 
	color: #fff; 
	text-shadow:1px 1px 0 #666; 
	box-shadow:0 0 0 5px #2c2c2c; 
	z-index: 3; 
	text-align: center; 
	line-height: 46px;
	-webkit-transition: all 0.28s ease-in;
	-moz--transition: all 0.28s ease-in;
}
.button:hover{ 
	-webkit-transform:rotate(90deg); 
}
@font-face {
  font-family: 'FontAwesome';
  src: url('font/fontawesome-webfont.eot');
  src: url('font/fontawesome-webfont.eot?#iefix') format('embedded-opentype'), 
			 url('font/fontawesome-webfont.woff') format('woff'), 
			 url('font/fontawesome-webfont.ttf') format('truetype'), 
			 url('font/fontawesome-webfont.svg#FontAwesome') format('svg');
  font-weight: normal;
  font-style: normal;
}
.icon-arrow-right:before {
  font-family: FontAwesome;
  font-weight: normal;
  font-size: 26px;
  font-style: normal;
  display: inline-block;
  text-decoration: inherit;
  content: "\f061";
}

demodownload

如需转载,烦请注明出处:http://www.w3cplus.com/demo/css3-login-form.html

css3字体图标集合

$
0
0
css3字体图标集合

css3 @font-face制作的图标,因为具备良好的颜色,大小等方面的控制而火热流行。对于我们来说,每次找一个比较合适的图标都是比较纠结的问题,那么现在我们收集一批@font-face制作的图标,积攥下来,以后需要的时候就随便牵个出来使唤使唤。如果你对@font-face还不熟悉,那么可以参阅本站的css3 @font-face教程

1. Foundation Icon Fonts 2 (Free)

Foundation Icons Fonts

2. Font Awesome (Free)

Font Awesome

3. Pictos ($49)

Pictos Icon Font

4. Symbolset ($30)

Symbolset

5. Fontello (Free)

Fontello

6. IcoMoon (Free)

IcoMoon

7. Entypo (Free)

Entypo

8. Iconic (Free)

Iconic

9. Raphaël Icon-Set (Free)

Raphael

10. Fico (€19)

Fico

11. Tipogram ($18)

Tipogram

12. Modern Pictograms (Free)

Modern Pictograms

持续更新ing

更多资料: 12 Icon Font Sets Perfect for Replacing Images

css3导航集合

$
0
0
css3导航集合

从来导航就是网站必不可少的。这么个重大角色的导航,当然少不了css3来增色天香啊。css3导航一般可以应用gradient,box-shadow,border-radius,text-shadow,@font-face,transition,transform等技术。

CSS3制作凤凰网导航

CSS3制作凤凰网导航

CSS3 Menu

CSS3 Nav Menu

CSS3 dropdown menu

CSS3 dropdown menu

Smooth Two Level Css3 Navgation Menu

Smooth Two Level Css3 Navgation Menu

Creating A CSS3 Animated Menu

Creating A CSS3 Animated Menu

Making a CSS3 Animated Menu

Making a CSS3 Animated Menu

Awesome Menu Bar

Awesome Menu Bar

CSS3 Dropdown Menu

CSS3 Dropdown Menu

How to Create a CSS3 Dropdown Menu

How to Create a CSS3 Dropdown Menu

Two Level Superfishy Menu

Two Level Superfishy Menu

Large Pressable CSS3 Navigation

Large Pressable CSS3 Navigation

CSS3 Scroll Drop Down Menu

CSS3 Scroll Drop Down Menu

css3树形导航

css3树形导航

css3导航设计1

css3导航设计1

纯css3 lavalamp 菜单效果

纯css3 lavalamp 菜单效果

CSS3制作下拉菜单

CSS3制作下拉菜单

持续更新ing……

CSS3制作W3cplus的关注面板

$
0
0
CSS3制作W3cplus的关注面板

W3cplus第三版本皮肤更新好长一段时间了,早就想把站点上的一些CSS3效果分割成单独的案例出来,与大家分享,但受限于时间,今天抽空把页面底部面板效果整理出来了。首先这个效果是有原因的,因为这个效果是当初自己左拼右拼出来的一个效果,后来自我感觉还能接受。上线后也有很多同学问我是图片制作的吗?其实不是的,他是一个CSS3制作的效果。在这个效果中,不要使用了渐变,“:before”,“box-shadow”,“transition”几个属性。

demodownload

HTML 结构

<div class="region">
  <div class="block">
    <h2>关注我们</h2>
    <div class="content">
      <ul class="nav-ms" id="nav-ms">
        <li data-alt="新浪微博"><a class="ms-sina" href="http://weibo.com/w3cplus" target="_blank" title="新浪微博">新浪微博</a></li>
        <li data-alt="腾讯微博"><a class="ms-tq" href="http://t.qq.com/airenliao" target="_blank" title="腾讯微博">腾讯微博</a></li>
        <li data-alt="Facebook"><a class="ms-facebook" href="https://www.facebook.com/w3cplus" target="_blank" titlte="Facebook">Facebook</a></li>
        <li data-alt="Twitter"><a class="ms-twitter" href="https://twitter.com/w3cplus" target="_blank" title="Twitter">Twitter</a></li>
        <li data-alt="订阅RSS"><a class="ms-rss" href="http://www.w3cplus.com/rss.xml" target="_blank" title="订阅RSS">订阅RSS</a></li>
        <li data-alt="Google+"><a class="ms-google" href="https://plus.google.com/106423935018507337793" target="_blank" title="Google+">Google+</a></li>
        <li data-alt="Github"><a class="ms-github" href="https://github.com/airen" target="_blank" title="GitHub">Github</a></li>
      </ul>  
    </div>
  </div>
</div>

CSS 代码

body {
  background-color: rgb(35, 35, 35);
  text-align: center;
  padding: 30px;
}
.region {
  width: 255px;
  padding: 0 10px;
  margin: 50px auto;
  color:rgba(255, 255, 255, 0.65);
}
.block {
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25),inset 0 0 0 150px rgba(150, 155, 150, 0.06);
  padding: 10px;
  position: relative;
  z-index: 0;
  margin: 0;
  text-align:left;
}
.block::before {
  content: "";
  position: absolute;
  z-index: -1;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  top: 3px;
  bottom: 3px;
  left: 3px;
  right: 3px;
  box-shadow: 0 0 1px rgba(255, 255, 255, 0.25);
  border-radius: 3px;
}
.block h2 {
  width: 237px;
  height: 35px;
  line-height: 35px;
  margin: 0 auto 10px -6px;
  position: relative;
  overflow: hidden;
  background: rgba(150, 155, 150, 0.3);
  background: -moz-linear-gradient(left, rgba(150, 155, 150, 0.3) 55%,rgba(155, 180, 150, 0.08) 85%);
  background: -webkit-gradient(linear, left center, right center, color-stop(55%,rgba(150, 155, 150, 0.3)), color-stop(85%,rgba(155, 180, 150, 0.08)));
  background: -webkit-linear-gradient(left, rgba(150, 155, 150, 0.3) 55%,rgba(155, 180, 150, 0.08) 85%);
  background: -o-linear-gradient(left, rgba(150, 155, 150, 0.3) 55%,rgba(155, 180, 150, 0.08) 85%);
  background: -ms-linear-gradient(left, rgba(150, 155, 150, 0.3) 55%,rgba(155, 180, 150, 0.08) 85%);
  background: linear-gradient(left, rgba(150, 155, 150, 0.3) 55%,rgba(155, 180, 150, 0.08) 85%);
  z-index:0;
  box-shadow: inset 5px 0px 10px 0px rgba(0, 0, 0, 0.3), inset 0 0 20px 0 rgba(0, 0, 0, 0.13),0 5px 3px -3px rgba(0,0,0,0.35);
  padding-left: 10px;
}
.block h2::before {
  content: "";
  display: block;
  border-top: 1px dashed rgba(255, 255, 255, 0.25);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.25);
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  right: 0;
  box-shadow: inset 5px 0px 10px 0px rgba(0,0,0,0.3);
}
 .block h2::after {
  content:"";
  display: block;
  border: 17px solid #292929;
  border-color: transparent  #292929 transparent transparent;
  width: 0;
  height: 0;
  position: absolute;
  top: 0;
  right: 0;
}
/*follow us*/
#nav-ms li {
  cursor: pointer;
  height: 38px;
  position: relative;
  margin-bottom: 19px !important;
  list-style: none outside none;
  margin-left: 0;
}
#nav-ms a{
  background: #d91e76 url('http://www.w3cplus.com/sites/all/themes/marvin/images/ms-icon.png') 3px 0 no-repeat;
  background-color: rgba(217,30,118, .42);
  border-radius: 19px;
  display: block;
  color: #fcfcfc;
  color:rgba(255, 255, 255, 0.8);
  width: 38px;
  font-size:16px;
  font-family:"SimHei";
  float: none;
  height: 38px;
  line-height: 38px;
  margin: 10px 0 0;
  text-align: left;
  text-indent: 50px;
  text-shadow: #333 0 1px 0;
  text-decoration: none;
  white-space: nowrap;
  z-index: 5;
  -webkit-transition:all .25s ease-in-out;
  -moz-transition:all .25s ease-in-out;
  -ms-transition:all .25s ease-in-out;
  -o-transition:all .25s ease-in-out;
  transition:all .25s ease-in-out;
  box-shadow: rgba(0,0,0, .28) 0 2px 3px;	
}
#nav-ms .icon {
  color: #fafafa;
  overflow: hidden;
}
#nav-ms .ms-sina { 
  background-color: rgba(249,13,20, .42); 
  background-position: 0px 4px; 
}
#nav-ms .ms-tq  { 
  background-color: rgba(11,142,185, .42); 
  background-position: 2px -38px; 
}
#nav-ms .ms-facebook  { 
  background-color: rgba(56,93,148, .42); 
  background-position: -3px -171px; 
}
#nav-ms .ms-twitter{ 
  background-color: rgba(74,183,225, .42); 
  background-position: 2px -83px; 
}
#nav-ms .ms-rss { 
  background-color: rgba(255, 109, 0, .42); 
  background-position: 3px -215px; 
}
#nav-ms .ms-google { 
  background-color: rgba(10,164, 53, .42); 
  background-position: 3px -260px; 
}
#nav-ms .ms-github { 
  background-color: rgba(253,190, 156, .42); 
  background-position: 1px -126px; 
}
#nav-ms li:hover a{
  text-decoration: none;
  color: #fff;
  width: 230px;
  background-color: #d91e76; 
}
#nav-ms li:hover .ms-sina { 
  background-color: rgba(249,13,20, 1); 
}
#nav-ms li:hover .ms-tq { 
  background-color: rgba(11,142,185, 1); 
}
#nav-ms li:hover .ms-facebook  { 
  background-color: rgba(56,93,148, 1); 
}
#nav-ms li:hover .ms-twitter { 
  background-color: rgba(74,183,225, 1); 
}
#nav-ms li:hover .ms-rss { 
  background-color: rgba(255, 109, 0, 1); 
}
#nav-ms li:hover .ms-google  { 
  background-color: rgba(10,164, 53, 1); 
}
#nav-ms li:hover .ms-github { 
  background-color: rgba(253,190, 156, 1);  
}

demodownload

如需转载,烦请注明出处:http://www.w3cplus.com/demo/css3-create-control-panel.html

藤藤每日一练——CSS3制作价格标牌

$
0
0
藤藤每日一练——CSS3制作价格标牌

今天藤藤给大家带来一个使用CSS3制作价格标牌的例子,这个例子相对来比较简单,最主要的关键点是如何使用border-radius来制作圆形的效果。同时这个例子中还运用了CSS3的渐变,阴影。

demodownload

HTML 结构

<div class="box">
  <div class="round red">
    <span><b class="sup">$</b>99</span>
    <span>*Premium</span>
  </div>
  <div class="round blue">
    <span>FREE</span>
    <span>*Trial Only</span>
  </div>
</div>

CSS代码

html{
  background-image: url(data:image/jpeg;base64,...;}
body{ 
  color:#fff; 
  background:-webkit-radial-gradient(circle,rgba(255,255,255,.1),rgba(255,255,255,0)); 
  background:-moz-radial-gradient(circle,rgba(255,255,255,.1),rgba(255,255,255,0)); 
  background:-o-radial-gradient(circle,rgba(255,255,255,.1),rgba(255,255,255,0)); 
  background:-ms-radial-gradient(circle,rgba(255,255,255,.1),rgba(255,255,255,0)); 
  background:radial-gradient(circle,rgba(255,255,255,.1),rgba(255,255,255,0)); 
  height: 100%; 
  padding: 50px;
}
.box{ 
  width: 350px; 
  text-align:center; 
  margin:50px auto; 
}
.round{ 
  width: 130px; 
  height: 140px; 
  background: #fff; 
  border-radius: 65px 0 65px 65px;  
  float: left;
  margin-right: 20px;
}
.red{ 
  background: -webkit-linear-gradient(top,#f9443e,#c93532); 
  background: -moz-linear-gradient(top,#f9443e,#c93532); 
  background: -o-linear-gradient(top,#f9443e,#c93532); 
  background: -ms-linear-gradient(top,#f9443e,#c93532); 
  background: linear-gradient(top,#f9443e,#c93532); 
  border:1px solid #c8544f;
}
.blue{ 
  background: -webkit-linear-gradient(top,#64e7fe,#1ac7eb); 
  background: -moz-linear-gradient(top,#64e7fe,#1ac7eb); 
  background: -o-linear-gradient(top,#64e7fe,#1ac7eb); 
  background: -ms-linear-gradient(top,#64e7fe,#1ac7eb); 
  background: linear-gradient(top,#64e7fe,#1ac7eb); 
  border:1px solid #1dadd3;
}
.sup { 
  vertical-align:super; 
  font-size: 20px;
}
.round span:first-child{
  display:block; 
  padding-top: 20px; 
  height: 55px;
  font:50px bold "Impact";
}
.round span:last-child{ 
  height: 18px; 
  font:italic normal 13px "arial"; 
  color:#ffdc7c;
}

.red span:first-child{ 
  margin-bottom: 5px; 
  padding-bottom:5px; 
  text-shadow:0 1px 1px #000; 
  border-bottom: 1px solid #b03130; 
  box-shadow: 0 1px 0 #dd5a59;
}
.blue span:first-child{ 
  color:rgba(0,160,206,.8); 
  text-shadow:0 1px 2px #7ee5f5, 0 0 0 #026e97;
}
.blue span:last-child{
  color:#fff;
}

demodownload

如需转载,烦请注明出处:http://www.w3cplus.com/demo/css3-price-tag.html

Viewing all 1557 articles
Browse latest View live