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

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

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

今天藤藤给大家带来的是一个CSS3制作的登录表单效果,这个效果有两上亮点,第一是渐变制作内凹圆角效果,第二个就是渐变制作花边效果。可以说这两个效果的实现都有一定的难度,如果你对css3的渐变属性gradient和CSS3的多背景不了解的话,你是无法实现的。如果你对这个效果感兴趣,那就自己动手一试吧。

demodownload

HTML 结构

<div class="box">
  <form>
    <div class="tag">SIGN IN</div>
    <div>Log in to your account or sign up to create one.</div>
    <div>
      <input type="text" id="inputName"  placeholder="Name:">
    </div>
    <div>
      <input type="password" id="inputPassword"  placeholder="Password:">
    </div>
    <div>
      <button type="submit" class="btn">SUBMIT</button>
    </div>
  </form>
</div>

CSS 代码

body{
  padding: 30px;
  background-image: url(data:image/png;base64,...==);} 
a{ 
  color:#000;
}
ul{ 
  list-style-type: none;
  margin-top: -20px;
}
.box{ 
  position: relative;
  z-index: 1;
  width: 456px;
  height: 380px; 
  margin:50px auto 0;
  text-align: center;
  color:#fff;
  text-shadow:0 1px 0 #333; 
  background:
    -webkit-radial-gradient(0 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -webkit-radial-gradient(100% 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -webkit-radial-gradient(100% 0, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -webkit-radial-gradient(0 0, circle, rgba(204,0,0,0) 29px, #d05353 29px);
  background:
    -moz-radial-gradient(0 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -moz-radial-gradient(100% 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -moz-radial-gradient(100% 0, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -moz-radial-gradient(0 0, circle, rgba(204,0,0,0) 29px, #d05353 29px);
  background:
    -o-radial-gradient(0 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -o-radial-gradient(100% 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -o-radial-gradient(100% 0, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -o-radial-gradient(0 0, circle, rgba(204,0,0,0) 29px, #d05353 29px);	
  background:
    -ms-radial-gradient(0 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -ms-radial-gradient(100% 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -ms-radial-gradient(100% 0, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    -ms-radial-gradient(0 0, circle, rgba(204,0,0,0) 29px, #d05353 29px);	
  background:
    radial-gradient(0 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    radial-gradient(100% 100%, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    radial-gradient(100% 0, circle, rgba(204,0,0,0) 29px, #d05353 29px),
    radial-gradient(0 0, circle, rgba(204,0,0,0) 29px, #d05353 29px);	
  background-position: bottom left, bottom right, top right, top left;
  background-size: 50% 50%;
  background-repeat: no-repeat;
}
.tag{ 
  position: relative; 
  top: -5px; 
  left: 50%; 
  margin-left: -92px; 
  width: 184px; 
  height: 87px;
  color:#fff; 
  font-size: 36px; 
  font-weight: bold; 
  line-height: 87px; 
  text-shadow:0 -1px 0 rgba(0,0,0,.2);
  background-color: #b5ae63;
  background-size: 2px 2px;
  background-image: -webkit-linear-gradient(45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a), 
    -webkit-linear-gradient(-45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a);
  background-image: -moz-linear-gradient(45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a), 
    -moz-linear-gradient(-45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a);
  background-image: -o-linear-gradient(45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a), 
    -o-linear-gradient(-45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a);
  background-image: -ms-linear-gradient(45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a), 
    -ms-linear-gradient(-45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a);
  background-image: linear-gradient(45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a), 
   linear-gradient(-45deg, #c0b96a 25%, transparent 25%, transparent 75%, #c0b96a 75%, #c0b96a);		
}
.tag:after,
.tag:before{
  position:absolute;
  left:0; 
  content: ""; 
  width: 100%; 
  z-index: 8
}
.tag:after{
  height: 30px; 
  top: 0px; 
  background: -webkit-linear-gradient(top,rgba(226,217,124,0) 0%,rgba(226,217,124,1) 40%,rgba(226,217,124,1) 60%,rgba(226,217,124,0) 100%);
  background: -moz-linear-gradient(top,rgba(226,217,124,0) 0%,rgba(226,217,124,1) 40%,rgba(226,217,124,1) 60%,rgba(226,217,124,0) 100%);
  background: -o-linear-gradient(top,rgba(226,217,124,0) 0%,rgba(226,217,124,1) 40%,rgba(226,217,124,1) 60%,rgba(226,217,124,0) 100%);
  background: -ms-linear-gradient(top,rgba(226,217,124,0) 0%,rgba(226,217,124,1) 40%,rgba(226,217,124,1) 60%,rgba(226,217,124,0) 100%);
  background: linear-gradient(top,rgba(226,217,124,0) 0%,rgba(226,217,124,1) 40%,rgba(226,217,124,1) 60%,rgba(226,217,124,0) 100%);
}
.tag:before{ 
  height:8px; 
  bottom: -5px; 
  z-index: -1;  
  background: -webkit-radial-gradient(ellipse closest-side, #b8b165, #b8b165 0%, #b8b165 70%,#732e2e 99%, transparent);
  background: -moz-radial-gradient(ellipse closest-side, #b8b165, #b8b165 0%, #b8b165 70%,#732e2e 99%, transparent);
  background: -o-radial-gradient(ellipse closest-side, #b8b165, #b8b165 0%, #b8b165 70%,#732e2e 99%, transparent);
  background: -ms-radial-gradient(ellipse closest-side, #b8b165, #b8b165 0%, #b8b165 70%,#732e2e 99%, transparent);
  background: radial-gradient(ellipse closest-side, #b8b165, #b8b165 0%, #b8b165 70%,#732e2e 99%, transparent);
  background-size:8px 8px;
}
form div:nth-of-type(3):before,
form div:nth-of-type(5):before{ 
  content: ""; 
  display: block;    
  width: 100%; 
  height: 5px;
  border:1px solid #c9938a;
  border-color:#c9938a transparent;
}
form{ 
  margin: 0 20px;
  line-height: 30px;
}
form input:not([type="checkbox"]){ 
  background: #aa3e3e; 
  box-shadow:inset 0 0 5px rgba(0,0,0,.5),0 1px 1px #da6262; 
  border: none; 
  height: 30px; 
  width: 100%; 
  padding-left: 5px; 
  padding-right: -5px; 
  margin:20px 0;
  -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
  -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
  -o-transition: border linear 0.2s, box-shadow linear 0.2s;
  -ms-transition: border linear 0.2s, box-shadow linear 0.2s;
  transition: border linear 0.2s, box-shadow linear 0.2s;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  -o-box-sizing: border-box;
  -ms-box-sizing: border-box;
  box-sizing: border-box;
}
form input:not([type="checkbox"]):focus{
  outline: 0 none;
  box-shadow: inset 0 1px 3px rgba(255,255,255,0.1), 0 0 8px rgba(255,255,255, 0.6);
}
::-webkit-input-placeholder {
  color:#d6aaaa;
  font-weight: bold;
}
form .btn{ 
  position: relative;
  top: 0;	
  border: none; 
  width: 112px; 
  height: 44px; 
  font-weight: bold;
  color: #b74242;
  text-shadow:0 -1px 0 #000; 
  border-radius: 3px; 
  box-shadow: 0 -1px 0 #feeae7,0 1px 0 #976159; 
  background: -webkit-linear-gradient(top,#f8d3cf,#dfafa8); 
  background: -moz-linear-gradient(top,#f8d3cf,#dfafa8); 
  background: -o-linear-gradient(top,#f8d3cf,#dfafa8); 
  background: -ms-linear-gradient(top,#f8d3cf,#dfafa8); 
  background: linear-gradient(top,#f8d3cf,#dfafa8); 
  margin-top: 20px;
  -webkit-transition: all 0.25s ease-out 0.05s;
  -moz-transition: all 0.25s ease-out 0.05s;
  -o-transition: all 0.25s ease-out 0.05s;
  -ms-transition: all 0.25s ease-out 0.05s;
  transition: all 0.25s ease-out 0.05s;
}
form .btn:hover{
  top: 1px;
  box-shadow: 0 -1px 0 #feeae7,0 2px 0 #976159; 
  background: -webkit-linear-gradient(top,#dfafa9,#e1b2ac); 	
  background: -moz-linear-gradient(top,#dfafa9,#e1b2ac); 	
  background: -o-linear-gradient(top,#dfafa9,#e1b2ac); 	
  background: -ms-linear-gradient(top,#dfafa9,#e1b2ac); 	
  background: linear-gradient(top,#dfafa9,#e1b2ac); 	
}

demodownload

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


CSS3制作登录表单

$
0
0
CSS3制作登录表单

站上已经放了多个CSS3制作的表单效果了,但为增强大家的视野,继续跟大家分享一个CSS3制作的登录表单。这个案例其实很简单,主要使用box-shadow做了分层纸张效果,使用gradient制作渐变按钮效果,然后就是@font-face制作的icon效果。其实这些理论方面的知识在站上都能找到,如果你是第一次接触这些,不仿试着查找一下。

demodownload

HTML结构

<div id="login" class="clearfix">
  <h1>Login</h1>
  <form class="form-horizontal" id="signupForm" method="post" action="" >
    <fieldset>
      <div class="control-group">
        <input id="loginName" name="loginName"  type="text"  required="required" placeholder="User ID">
      </div>
      <div class="control-group">
        <input id="password" name="password" type="password"  required="required" placeholder="Password">
      </div>
      <div class="form-actions">
	<button class="btn btn-primary submit" type="submit" id="signup">Login</button>
	<button class="btn" type="button" onclick="remind();" id="pwd-btn">Signup</button>
      </div>
    </fieldset>
  </form>
</div>

CSS 代码:

@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;
}
body {
  background: url(data:image/jpeg;base64,/9..;
  padding-top: 120px;
  padding-bottom: 100px;
	font-family: 'Damion', cursive;
}
	/*login*/
#login {
  width: 540px;
  margin: 50px auto;
}

#login h1 {
  float: left;
  width: 135px;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-width: 0 0 1px 1px;
  border-radius: 10px 0 0 10px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 1), 0 2px 0 rgba(0, 0, 0, 0.35), 0 3px 0 rgba(255, 255, 255, 1), 0 4px 0 rgba(0, 0, 0, 0.35);
  position: relative;
  z-index: 10;
  background: #fff;
	font-size: 50px;
line-height: 55px;
text-shadow: 0 1px 0 rgba(0, 0, 0, 0.8),0 2px 0 rgba(0, 0, 0, 0.7),0 4px 0 rgba(0, 0, 0, 0.6),0 5px 0 rgba(0, 0, 0, 0.5),0 6px 1px rgba(0, 0, 0, 0.4),0 7px 2px rgba(0, 0, 0, 0.3),0 8px 3px rgba(0, 0, 0, 0.2),0 8px 4px rgba(0, 0, 0, 0.1);
}

#signupForm {
  padding: 50px;
  border: 1px solid rgba(0, 0, 0, 0.35);
  border-top: none;
  margin-left: 155px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 1), 0 2px 0 rgba(0, 0, 0, 0.35), 0 3px 0 rgba(255, 255, 255, 1), 0 4px 0 rgba(0, 0, 0, 0.35);
  border-radius: 0 10px 10px 10px;
  position: relative;
  z-index: 2;
  background: #fff;
}
fieldset {
padding: 0;
margin: 0;
border: 0;
}


input {
  display: inline-block;
  width: 210px;
  margin-bottom: 9px;
  line-height: 18px;
  background-color: #ffffff;
  border: 1px solid #cccccc;
  border-radius: 3px;
  -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
     -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
      -ms-transition: border linear 0.2s, box-shadow linear 0.2s;
       -o-transition: border linear 0.2s, box-shadow linear 0.2s;
          transition: border linear 0.2s, box-shadow linear 0.2s;
}

input:focus {
  border-color: rgba(82, 168, 236, 0.8);
  outline: 0;
  outline: thin dotted \9;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6);
}


.btn:focus {
  outline: thin dotted #333;
  outline: 5px auto -webkit-focus-ring-color;
  outline-offset: -2px;
}

.btn.active,
.btn:active {
}
#signupForm input[type="text"],
#signupForm input[type="password"] {
  -webkit-box-sizing: content-box;
  -moz-box-sizing: content-box;
  -o-box-sizing: content-box;
  -ms-box-sizing: content-box;
  box-sizing: content-box;
  height: 28px;
  box-shadow: 0 1px 0 rgba(255,255,255,0.75),inset 0 0 5px rgba(0,0,0,0.3);
  color: #7b8b9a;
  font-size: 14px;
  padding: 5px 8px;
  position: relative;
	
}
#signupForm input[type="text"]:focus,
#signupForm input[type="password"]:focus {
  border-color:rgba(0,153,204,1);
  box-shadow: 0 0 6px rgba(0,153,204,0.8);
}
#signupForm .control-group {
  position: relative;
	margin-bottom: 18px;
}
#signupForm .control-group:nth-child(1):before,
#signupForm .control-group:nth-child(2):before{
  display: block;
  content: "";
  position: absolute;
  cursor: pointer;
  right: 0;
  top:0;
  width: 38px;
  height: 38px;
  z-index: 20;
  font-family: 'fontello';
  text-align: center;
  font-size: 20px;
  line-height: 38px;
  border: 1px solid;
  border-radius: 3px;
  text-shadow: 0 1px 1px rgba(255,255,255,0.4);
  box-shadow: inset 0 -2px 1px rgba(0,0,0,0.75),0 1px 0 rgba(255,255,255,0.1);
}
#signupForm .control-group:nth-child(1):before {
  content: '\1f464';
  border-color: #e71a1a #770808 #770808 #e71a1a;
  color: #631009;
  background-color: #c34012; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2MzNDAxMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM4YTA2MDciIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
  background-image: -moz-linear-gradient(top,  #c34012 0%, #8a0607 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c34012), color-stop(100%,#8a0607)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #c34012 0%,#8a0607 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #c34012 0%,#8a0607 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #c34012 0%,#8a0607 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #c34012 0%,#8a0607 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c34012', endColorstr='#8a0607',GradientType=0 ); /* IE6-8 */
}
#signupForm .control-group:nth-child(2):before {
  content: '\1f512';
  border-color: #86a3be #7094b6 #7094b6 #86a3be;
  color: #163451;
  background-color: #759dc3; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzc1OWRjMyIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM1ODdkYTEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
  background-image: -moz-linear-gradient(top,  #759dc3 0%, #587da1 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#759dc3), color-stop(100%,#587da1)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #759dc3 0%,#587da1 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #759dc3 0%,#587da1 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #759dc3 0%,#587da1 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #759dc3 0%,#587da1 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#759dc3', endColorstr='#587da1',GradientType=0 ); /* IE6-8 */
}
#signupForm .form-actions {
  padding: 0;
  text-align: center;
  background: none;
  border-top: none;
  margin-bottom: 0;
}
#signupForm .btn {
	display: inline-block;
  *display: inline;
  line-height: 18px;
  *line-height: 20px;
  text-align: center;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
  vertical-align: middle;
  cursor: pointer;
  background-repeat: repeat-x;
  border: 1px solid #cccccc;
  border-radius: 4px;
  *zoom: 1;
  border-color: #f07719 #974a15 #974a15 #f07719;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.5);
  background-color: #ff8920; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmODkyMCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNiZjNlMDQiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
  background-image: -moz-linear-gradient(top,  #ff8920 0%, #bf3e04 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ff8920), color-stop(100%,#bf3e04)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #ff8920 0%,#bf3e04 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #ff8920 0%,#bf3e04 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #ff8920 0%,#bf3e04 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #ff8920 0%,#bf3e04 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ff8920', endColorstr='#bf3e04',GradientType=0 ); /* IE6-8 */
  font-size: 14px;
  color: #fafafa;
  padding: 8px 15px;
  margin: 5px
}
#signupForm .btn:hover {
  color: #333333;
  text-decoration: none;
  background-color: #e6e6e6;
  *background-color: #d9d9d9;
  /* Buttons in IE7 don't get borders, so darken on hover */

  background-position: 0 -15px;
  -webkit-transition: background-position 0.1s linear;
     -moz-transition: background-position 0.1s linear;
      -ms-transition: background-position 0.1s linear;
       -o-transition: background-position 0.1s linear;
          transition: background-position 0.1s linear;
}
#signupForm .btn:hover,
#signupForm .btn:active {
  background-color: #bf3e04;
	color: #fff;
}
#signupForm .btn:active {
  outline: 0;
  position: relative;
  top: 1px;
  box-shadow: inset 0 2px 1px #bf3e04,0 1px 2px rgba(0,0,0,0.5);
}
#signupForm label.error {
  padding: 5px 10px;
  background: #202020;
  color: #fff;
  margin-top: 15px;
  position: absolute;
  top: 5px;
  left: 105%;
  white-space: nowrap;
  margin: 0;
  border-radius: 3px;
}
#signupForm label.error:before {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border: 5px solid #202020;
  border-color: transparent #202020 transparent transparent ;
  position: absolute;
  right: 100%;
  top: 50%;
  margin-top: -5px;
}

demodownload

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

CSS3制作卷角菜单

$
0
0
CSS3制作卷角菜单

这个案例是由@猫仔同学提供的。最大的亮点就是使用了CSS3制作了卷边效果,配上js的移动效果,真是与众不同。在这个demo中主要运用了border-radius制作卷边效果,使用gradient实现了导航的渐变效果,而且还使用了border绘制了向上的箭头,同时给箭头配上了一个css3的动画效果。真的不错哟。

demodownload

HTML 结构

<div class="notice"><div class="arrow"></div>拖动书角看看 *^_^*</div>
 <div class="form" id="form">
 <div class="corner" id="corner"></div>
  <ul class="button">
    <li><a href="">W3cplus</a></li>
    <li><a href="">Blog</a></li>
    <li class="navcurrent"><a href="">About Us</a></li>
    <li class="borderno"><a href="">Contact</a></li>
  </ul>
</div>	

CSS代码:

ul,li{
  list-style-type:none;
  padding:0;
}
.form{
  width:405px;
  height:200px;
  background:#2f2f2f;
  position:relative;
  overflow:hidden;
  margin:30px auto;
}
.corner{
  background: -webkit-linear-gradient(45deg, #2e2e2e 24%, #5F5F5F 40%,#6f6f6f 43%,#5F5F5F 46%,#2F2F2F 50%,#fff 50%,#fff);
  background: -moz-linear-gradient(45deg, #2e2e2e 24%, #5F5F5F 40%,#6f6f6f 43%,#5F5F5F 46%,#2F2F2F 50%,#fff 50%,#fff);height: 90px;
  background: -o-linear-gradient(45deg, #2e2e2e 24%, #5F5F5F 40%,#6f6f6f 43%,#5F5F5F 46%,#2F2F2F 50%,#fff 50%,#fff);height: 90px;
  background: -ms-linear-gradient(45deg, #2e2e2e 24%, #5F5F5F 40%,#6f6f6f 43%,#5F5F5F 46%,#2F2F2F 50%,#fff 50%,#fff);height: 90px;
  background: linear-gradient(45deg, #2e2e2e 24%, #5F5F5F 40%,#6f6f6f 43%,#5F5F5F 46%,#2F2F2F 50%,#fff 50%,#fff);height: 90px;
  width: 90px;
  height:90px;
  border-radius: 0 0 0px 90px / 0 0 0 30px;
  -webkit-transform: rotate(-90deg);
  -moz-transform: rotate(-90deg);
  -o-transform: rotate(-90deg);
  -ms-transform: rotate(-90deg);
  transform: rotate(-90deg);
  position: absolute;
  left:-4px;
  top: -4px;
  box-shadow: 5px 2px 8px black; 
  overflow:hidden;
  -webkit-transition:all 0.3s linear 0s;
  -moz-transition:all 0.3s linear 0s;
  -o-transition:all 0.3s linear 0s;
  -ms-transition:all 0.3s linear 0s;
  transition:all 0.3s linear 0s;
}

.corner:after{
  height:100%;
  width:100%;
  position: absolute;
  content: "";
  top: -15px;
  left: -82px;
  border-radius: 90px 90px 0px 0 / 40px 40px 0 0;
  z-index: 1;
  background: #2F2F2F;
  -webkit-transform: rotate(77deg);
  -moz-transform: rotate(77deg);
  -o-transform: rotate(77deg);
  -ms-transform: rotate(77deg);
  transform: rotate(77deg);
  box-shadow: 0px 0px 8px black inset;
}
.button{
  float: left;
  height:40px;
  margin:20px 20px;
  border-radius:30px;
  border:1px solid #151515;
  box-shadow:0px 2px 2px rgba(0,0,0,0.6);
  overflow:hidden;
 }
.button li {
  float: left;
}  
.button li a{
  float:left;
  display:block;
  text-decoration:none;
  padding: 0 20px;
  height:40px;
  line-height:36px;
  font-size:14px;
  color:#eee;
  text-align:center;
  border-right:1px solid #151515;
  box-shadow:-1px 0px 0px rgba(255,255,255,0.1) inset,inset 0px -1px 1px rgba(200,200,200,0.1),inset 0px 1px 2px rgba(255,255,255,0.1);
  text-shadow:0px -1px 0px #000;
  background:-webkit-linear-gradient(top,rgba(200,200,200,0.1) 0%,rgba(200,200,200,0.1) 50%,#222 50%,#222);
  background:-moz-linear-gradient(top,rgba(200,200,200,0.1) 0%,rgba(200,200,200,0.1) 50%,#222 50%,#222);
  background:-o-linear-gradient(top,rgba(200,200,200,0.1) 0%,rgba(200,200,200,0.1) 50%,#222 50%,#222);
  background:-ms-linear-gradient(top,rgba(200,200,200,0.1) 0%,rgba(200,200,200,0.1) 50%,#222 50%,#222);
  background:linear-gradient(top,rgba(200,200,200,0.1) 0%,rgba(200,200,200,0.1) 50%,#222 50%,#222);
}
.button li:first-child a{
  border-radius:30px 0 0 30px;
}
.button li:last-child a{
  border-radius:0px 30px 30px 0;
  border-right: none;
}
.button li a:hover{
  cursor:pointer;
  background:-webkit-linear-gradient(top,rgba(50,50,50,0.4) 20%,rgba(100,100,100,0.3));
  background:-moz-linear-gradient(top,rgba(50,50,50,0.4) 20%,rgba(100,100,100,0.3));
  background:-o-linear-gradient(top,rgba(50,50,50,0.4) 20%,rgba(100,100,100,0.3));
  background:-ms-linear-gradient(top,rgba(50,50,50,0.4) 20%,rgba(100,100,100,0.3));
  background:linear-gradient(top,rgba(50,50,50,0.4) 20%,rgba(100,100,100,0.3));
  box-shadow:0px 2px 4px rgba(0,0,0,0.8) inset;
  color:#b7def5;
  text-shadow:0px 0px 8px rgba(0,162,255,0.8);
}

.notice{
  position:relative;
  padding:10px 0 0 25px;
  margin: 20px auto;
  width: 120px;
}
.arrow{
  width:13px;
  height:20px;
  background:#FC9;
  position:absolute;
  top:0px;
  left:0px;
  -webkit-animation:notices linear 0.8s infinite ;
  -moz-animation:notices linear 0.8s infinite ;
  -o-animation:notices linear 0.8s infinite ;
  -ms-animation:notices linear 0.8s infinite ;
  animation:notices linear 0.8s infinite ;
}
.arrow:after{
  width:0;
  height:0;
  border-width:12px;
  border-style:solid dashed dashed dashed;
  border-color:#FC9 transparent transparent transparent;
  position:absolute;
  bottom:-22px;
  left:-5px;
  display:block;
  content:"";
}
@-webkit-keyframes notices{
  0%{top:0px;}
  50%{top:10px;}
  100%{top:0px;}
}
@-moz-keyframes notices{
  0%{top:0px;}
  50%{top:10px;}
  100%{top:0px;}
}
@-o-keyframes notices{
  0%{top:0px;}
  50%{top:10px;}
  100%{top:0px;}
}
@-ms-keyframes notices{
  0%{top:0px;}
  50%{top:10px;}
  100%{top:0px;}
}  
@keyframes notices{
  0%{top:0px;}
  50%{top:10px;}
  100%{top:0px;}
}  

JavaScript代码

(function(){
	var form=document.getElementById("form");
	var corner=document.getElementById("corner")
	var ftop=form.offsetTop;
	var fleft=form.offsetLeft;
	var switchopen=0;
	corner.onmousedown=function(e){
		e.preventDefault(); 
        form.style.cursor="move";
		switchopen=1;
		}
	form.onmousemove=function(e){
		if(switchopen==1){
			if(e.pageX-fleft>90 ||e.pageY-ftop>90){
				corner.style.width=corner.style.height=90+"px";
				corner.style.left=corner.style.top=-4+"px"
				}
			else{
				corner.style.width=corner.style.height=e.pageY-ftop+"px";
				
				}
		}
	}
	form.onmouseup=function(){
		switchopen=0;
                this.style.cursor="default";
		}
	})()

demodownload

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

CSS3制作立体导航

$
0
0
CSS3制作立体导航

首先非常感谢verycd@不点同学提供案例。这个案例是使用CSS3制作的一个多颜色3D立体导航。在这个案例中有两个关键之处,其一使用box-shadow制作导航立体效果,其二使用gradient配合:before选择器制作导航项之间的分隔线。详细请参阅代码。

demodownload

HTML结构

<ul class="nav black">
  <li><a href="">Home</a></li>
  <li><a href="">About Me</a></li>
  <li><a href="">Portfolio</a></li>
  <li><a href="">Blog</a></li>
  <li><a href="">Resources</a></li>
  <li><a href="">Contact Me</a></li>
</ul>

CSS3代码

body{
  background: #ebebeb;
}
.nav{
  width:560px;
  height: 50px;
  font:bold 0/50px Arial;
  text-align:center;
  margin:40px auto 0;
  border-radius: 8px;
}
.nav a{display: inline-block;
  -webkit-transition: all 0.2s ease-in;
  -moz-transition: all 0.2s ease-in;
  -o-transition: all 0.2s ease-in;
  -ms-transition: all 0.2s ease-in;
  transition: all 0.2s ease-in;
}
.nav a:hover{
  -webkit-transform:rotate(10deg);
  -moz-transform:rotate(10deg);
  -o-transform:rotate(10deg);
  -ms-transform:rotate(10deg);
  transform:rotate(10deg);
}
.black{
  background: #2c2c2c;
  box-shadow: 0 7px 0 #0b0b0b;
}
.red{
  background: #f65f57;
  box-shadow: 0 7px 0 #ba4a45;
}
.blue{
  background: #36b7e5;
  box-shadow: 0 7px 0 #3595b8;
}
.green{
  background: #9cd564;
  box-shadow: 0 7px 0 #86b65b;
}
.nav li{
  position:relative;
  display:inline-block;
  padding:0 16px;
  font-size: 13px;
  text-shadow:1px 2px 4px rgba(0,0,0,.5);
  list-style: none outside none;
}
   
.nav li::before,
.nav li::after{
  content:"";
  position:absolute;
  top:14px;
  height: 25px;
  width: 1px;
}
.nav li::after{
  right: 0;
  background: -moz-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
  background: -webkit-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
  background: -o-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
  background: -ms-linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
  background: linear-gradient(top, rgba(255,255,255,0), rgba(255,255,255,.2) 50%, rgba(255,255,255,0));
}
.black li::before{
  left: 0;
  background: -moz-linear-gradient(top, #2c2c2c, #000 50%, #2c2c2c);
  background: -webkit-linear-gradient(top, #2c2c2c, #000 50%, #2c2c2c);
  background: -o-linear-gradient(top, #2c2c2c, #000 50%, #2c2c2c);
  background: -ms-linear-gradient(top, #2c2c2c, #000 50%, #2c2c2c);
  background: linear-gradient(top, #2c2c2c, #000 50%, #2c2c2c);
}
.red li::before{
  left: 0;
  background: -moz-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
  background: -webkit-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
  background: -o-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
  background: -ms-linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
  background: linear-gradient(top, #ff625a, #9e3e3a 50%, #ff625a);
}
.blue li::before{
  left: 0;
  background: -moz-linear-gradient(top, #34b0dc, #237a99 50%, #34b0dc);
  background: -webkit-linear-gradient(top, #34b0dc, #237a99 50%, #34b0dc);
  background: -o-linear-gradient(top, #34b0dc, #237a99 50%, #34b0dc);
  background: -ms-linear-gradient(top, #34b0dc, #237a99 50%, #34b0dc);
  background: linear-gradient(top, #34b0dc, #237a99 50%, #34b0dc);
}
.green li::before{
  left: 0;
  background: -moz-linear-gradient(top, #9cd564, #7aa450 50%, #9cd564);
  background: -webkit-linear-gradient(top, #9cd564, #7aa450 50%, #9cd564);
  background: -o-linear-gradient(top, #9cd564, #7aa450 50%, #9cd564);
  background: -ms-linear-gradient(top, #9cd564, #7aa450 50%, #9cd564);
  background: linear-gradient(top, #9cd564, #7aa450 50%, #9cd564);
}
.nav li:first-child::before{
  background: none;
}
.nav li:last-child::after{
  background: none;
}

.nav a,
.nav a:hover{
  color:#fff;
  text-decoration: none;
}

demodownload

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

藤藤每日一练——CSS3制作3D表单

$
0
0
藤藤每日一练——CSS3制作3D表单

藤藤今天给大家带来一款使用CSS3制作的3D立体表单效果。在这个案例中主要使用了CSS3的渐变制作了body的背景;使用box-shadow制作的3D立体input框和3D立体按钮;使用@font-face制作的icon图标。

demodownload

HTML 结构

<div class="box">
  <form>
    <div>secure login</div>
    <div class="input_control">
        <input type="text" id="inputName"  placeholder="Your Name">
        <label for="inputName"></label>
    </div>
    <div class="input_control">
        <input type="text" id="inputEmail"  placeholder="Your Email">
        <label for="inputName"></label>
    </div>
    <div class="input_control">
        <input type="password" id="inputPassword"  placeholder="******">
        <label for="inputName"></label>
    </div>
    <div>
      <button type="submit" class="btn">LOGIN</button>
    </div>
    <p><a href="#">Lost Your Password?</a></p>
  </form>
</div>

CSS代码

body{
  background-color:#f7f0da;
  background-image: -webkit-linear-gradient(180deg,transparent 90%,#eae4cf 10%);
  background-image: -moz-linear-gradient(180deg,transparent 90%,#eae4cf 10%);
  background-image: -o-linear-gradient(180deg,transparent 90%,#eae4cf 10%);
  background-image: -ms-linear-gradient(180deg,transparent 90%,#eae4cf 10%);
  background-image: linear-gradient(180deg,transparent 90%,#eae4cf 10%);
  background-size: 5px 50px;
}
.box{ 
  margin:20px auto; 
  width:560px;
  text-align:center;
  font-weight:bold;
}
.box div:first-child{ 
  font-size:60px;
  margin-bottom:20px;
  text-shadow:0 2px 0 #c0c0c0,0 3px #979385;
}
.box .input_control{	
  position:relative;
  height:100px;
}
.box input{ 
  position:relative;
  font-size:18px;
  height:56px;
  width:100%;
  padding-left:10px;
  border:12px solid #fff;
  border-radius:3px;
  box-shadow:inset 0 0 0 1px #c0c0c0,inset 1px 2px 0 #e6e6e6,1px 2px 0 #c0c0c0,-1px 2px 0 #c0c0c0,2px 3px 0 #c0c0c0,-2px 3px 0 #c0c0c0,2px 12px 0 #c0c0c0,-2px 12px 0 #c0c0c0,0 2px 0 3px #979797,0 10px 0 3px #979797,-2px 15px 10px rgba(0,0,0,.6);
  -webkit-box-sizing:border-box;
  -moz-box-sizing:border-box;
  -o-box-sizing:border-box;
  -ms-box-sizing:border-box;
  box-sizing:border-box;
  -webkit-transition: all 0.1s ease-in;
  -moz-transition: all 0.1s ease-in;
  -ms-transition: all 0.1s ease-in;
  -o-transition: all 0.1s ease-in;
  transition: all 0.1s ease-in;
}
.box label{ 
  position:absolute;
  top:-2px; 
  right:50px; 
  width:74px; 
  height: 56px;
  color:#f3f2f1;
  text-shadow:0 3px 1px #9e2719;
  border:1px solid #dd684f;
  background:-webkit-linear-gradient(top,#e78d7b 0,#dd684f 72px);
  background:-moz-linear-gradient(top,#e78d7b 0,#dd684f 72px);
  background:-o-linear-gradient(top,#e78d7b 0,#dd684f 72px);
  background:-ms-linear-gradient(top,#e78d7b 0,#dd684f 72px);
  background:linear-gradient(top,#e78d7b 0,#dd684f 72px);
  box-shadow:0 14px 0 #9c2912,0 0 5px rgba(0,0,0,.3);
  -webkit-transition: all 0.1s ease-in;
  -moz-transition: all 0.1s ease-in;
  -o-transition: all 0.1s ease-in;
  -ms-transition: all 0.1s ease-in;
  transition: all 0.1s ease-in;
}
.box label:after{
  position:absolute;
  display:block;
  width: 74px;
  text-align: center;
  font: normal normal 30px/56px  'icomoon';
  speak: none;
  -webkit-font-smoothing: antialiased;
  -moz-font-smoothing: antialiased;
  -o-font-smoothing: antialiased;
  -ms-font-smoothing: antialiased;
  font-smoothing: antialiased;
}
.input_control:nth-of-type(2) label:after{
  content:"\21";
}
.input_control:nth-of-type(3) label:after{
  content:"\22";
}
.input_control:nth-of-type(4) label:after{
  content:"\23";
}
.box input:focus{
  outline: 0 none;
  top:2px; 
  box-shadow:inset 0 0 0 1px #c0c0c0,inset 1px 2px 0 #e6e6e6,1px 2px 0 #c0c0c0,-1px 2px 0 #c0c0c0,1px 3px 0 #c0c0c0,-2px 3px 0 #c0c0c0,2px 12px 0 #c0c0c0,-2px 12px 0 #c0c0c0,0 2px 0 3px #979797,0 10px 0 3px #979797,-2px 15px 10px rgba(0,0,0,.6);
}
.box input:focus + label{
  top:0; 
}
::-webkit-input-placeholder {
  color:#d94a2d;
  font-style:italic;
}
.box .btn{
  position:relative; 
  width:210px; 
  height:60px;
  color:#4c6e03;
  font:bold 35px  "Impact";
  text-indent:10px;
  letter-spacing:3px;
  text-align:left;
  margin-bottom:20px;
  border:none;
  border-radius:6px;
  text-shadow:-1px 2px 0 #c4e184;
  box-shadow:1px 2px 0 #5f8214,-1px 2px 0 #5f8214,2px 3px 0 #5f8214,-2px 3px 0 #5f8214,2px 12px 0 #5f8214,-2px 12px 0 #5f8214,0 2px 0 3px #304601,0 10px 0 3px #304601,-2px 15px 10px rgba(0,0,0,.6);
  background:-webkit-linear-gradient(top,#c5e185,#a5c65c);
  -webkit-transition: all 0.1s ease-in;
  -moz-transition: all 0.1s ease-in;
  -o-transition: all 0.1s ease-in;
  -ms-transition: all 0.1s ease-in;
  transition: all 0.1s ease-in;
}
.box .btn:after{ 
  position:absolute;
  display:block; 
  content:"\25"; 
  width:36px; 
  height:36px; 
  border-radius:18px; 
  background:#5f8214; 
  top:10px; 
  right:20px;
  text-indent:5px;
  text-align:center; 
  color:#b3d36e;
  text-shadow:0 3px 0 #325207;
  box-shadow:inset 0 6px 0 #325207;
  font: normal normal 18px/40px  'icomoon';
  speak: none;
  -webkit-font-smoothing: antialiased;
  -moz-font-smoothing: antialiased;
  -o-font-smoothing: antialiased;
  -ms-font-smoothing: antialiased;
  font-smoothing: antialiased;
}
.box .btn:hover{ 
  background:-webkit-linear-gradient(top,#a2c452,#a5c65c);
  background:-moz-linear-gradient(top,#a2c452,#a5c65c);
  background:-ms-linear-gradient(top,#a2c452,#a5c65c);
  background:-o-linear-gradient(top,#a2c452,#a5c65c);
  background:linear-gradient(top,#a2c452,#a5c65c);
}
.box .btn:active{
  top:2px; 
  box-shadow:1px 2px 0 #a5c65c,-1px 2px 0 #a5c65c,1px 3px 0 #a5c65c,-2px 3px 0 #5f8214,2px 12px 0 #5f8214,-2px 12px 0 #5f8214,0 2px 0 3px #5f8214,0 10px 0 3px #304601,-2px 15px 10px rgba(0,0,0,.6);
}
.box p a{
  color:#d94a2d; 
  line-height:30px;
  font-size:14px;
}
@font-face {
  font-family: 'icomoon';
  src:url('fonts/icomoon.eot');
  src:url('fonts/icomoon.eot?#iefix') format('embedded-opentype'),
      url('fonts/icomoon.svg#icomoon') format('svg'),
      url('fonts/icomoon.woff') format('woff'),
      url('fonts/icomoon.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

demodownload

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

渐进增强版html

$
0
0
<!DOCTYPE HTML>
<!--[if !IE]><!--><html lang="zh-cn"><!--<![endif]-->
<!--[if gt IE 9]><html class="ie10" lang="zh-cn"><![endif]-->
<!--[if IE 9]><html class="ie9 lte9" lang="zh-cn"><![endif]-->
<!--[if IE 8]><html class="ie8 lte9 no-css3" lang="zh-cn"><![endif]-->
<!--[if IE 7]><html class="ie7 lte9 lte7 no-css3" lang="zh-cn"><![endif]-->
<!--[if lte IE 6]><html class="ie6 lte9 lte7 no-css3" lang="zh-cn"><![endif]-->
<head>
  <meta charset="UTF-8">
  <title></title>
</head>
<body>
  
</body>
</html>

这个其实有好几种不同的版本,按个人的需求来定吧,本人在不同阶段也使用了不同的版本,最终确认为这个版本。其中.no-css3用来表示ie6-8不支持css3的样式,对于渐进增加方面,可以高级浏览器使用css3,ie6-8使用.no-css3这个class来定位使用背景图片,而对于ie8支持的:before和:after生成的三角,则可以使用.lt7来表示ie7及ie6使用背景图片。

藤藤每日一练——CSS3制作Twitter信息框

$
0
0
藤藤每日一练——CSS3制作Twitter信息框

今天与大家分享一款使用CSS3制作的Twitter信息分享框。在这个DEMO中,使用的CSS3属性还是那么几个,css3的渐变gradient,盒子阴影box-shadow,css3的选择器等,不过在这个案例中两个特色之处,一个是使用了":before"配合gradient制作了内凹圆角效果,类似于chrome浏览器上的tabs效果,这个效果可有点难度(思路来自于Tabs with Round Out Borders),还有一个亮点就是使用gradient制作了渐变的线条。想一探究竟的同学,看下面的代码吧。

demodownload

HTML结构

<div class="box">
  <ul class="menu">
    <li><i>Share it!</i></li>
    <li>WHAT ARE YOU DOING?</li>
    <li>@SPICYEPPER</li>
    <li>DIRECT MESSAGES</li>
  </ul>
  <dl class="list">
    <dt><img alt="" src="data:image/... /></dt>
    <dd>I’m about to jump off a building.</dd>
  </dl>
</div>

CSS代码

body{ 
  background: #273648;
}
.box{ 
  width: 655px; 
  margin: 100px auto 0;
}
.menu{ 
  list-style-type: none; 
  font-size: 0;
}
.menu li{ 
  position: relative;
  display: inline-block; 
  line-height: 30px;
  padding: 0 20px; 
  font-size: 14px; 
}
.menu i{ 
  color: #405b7a;
}
.menu li:not(:first-child){ 
  background:-webkit-linear-gradient(top,#508ed5,#356ba8); 
  background:-moz-linear-gradient(top,#508ed5,#356ba8); 
  background:-o-linear-gradient(top,#508ed5,#356ba8); 
  background:-ms-linear-gradient(top,#508ed5,#356ba8); 
  background:linear-gradient(top,#508ed5,#356ba8); 
  color:#fff;
}
.menu li:last-child{ 
  border-radius:0 10px 0 0;
}
.menu li:last-child:after,
.menu li:last-child:before{ 
  position: absolute; 
  top: 0;
  display: block; 
  content: ""; 
  height: 30px; 
  width: 1px;
}
.menu li:last-child:after{ 
  background: -webkit-linear-gradient(top,#356ca9 0%, #356ca9 50%, rgba(56,109,107,0) 90%);
  background: -moz-linear-gradient(top,#356ca9 0%, #356ca9 50%, rgba(56,109,107,0) 90%);
  background: -o-linear-gradient(top,#356ca9 0%, #356ca9 50%, rgba(56,109,107,0) 90%);
  background: -ms-linear-gradient(top,#356ca9 0%, #356ca9 50%, rgba(56,109,107,0) 90%);
  background: linear-gradient(top,#356ca9 0%, #356ca9 50%, rgba(56,109,107,0) 90%);
  left: 0;
}
.menu li:last-child:before{ 
  background: -webkit-linear-gradient(top,#9bc1ec 0%, #9bc1ec 50%, rgba(56,109,107,0) 90%);
  background: -moz-linear-gradient(top,#9bc1ec 0%, #9bc1ec 50%, rgba(56,109,107,0) 90%);
  background: -o-linear-gradient(top,#9bc1ec 0%, #9bc1ec 50%, rgba(56,109,107,0) 90%);
  background: -ms-linear-gradient(top,#9bc1ec 0%, #9bc1ec 50%, rgba(56,109,107,0) 90%);
  background: linear-gradient(top,#9bc1ec 0%, #9bc1ec 50%, rgba(56,109,107,0) 90%);
  left: 1px;
}
.menu li:nth-of-type(3){ 
  margin-left: -10px; 
  padding-left:30px;
}
.menu li:nth-of-type(2){ 
  z-index: 99;
  top: 1px;
  border-radius:10px 10px 0 0; 
  background: -webkit-linear-gradient(top,#90d0ff,#7ab4f3); 
  background: -moz-linear-gradient(top,#90d0ff,#7ab4f3); 
  background: -o-linear-gradient(top,#90d0ff,#7ab4f3); 
  background: -ms-linear-gradient(top,#90d0ff,#7ab4f3); 
  background: linear-gradient(top,#90d0ff,#7ab4f3); 
  text-shadow:0 1px 0 #999;
  padding-top: 1px;
  box-shadow:inset 0 1px 0 #b2deff,1px -1px 1px rgba(23,34,47,.4),-1px -1px 1px rgba(23,34,47,1);
}
.menu li:nth-of-type(2):after,
.menu li:nth-of-type(2):before{
  position: absolute;
  display: block;
  content: "";z-index: 99;
}
.menu li:nth-of-type(2):after{
  bottom: 1px; 
  left: -9px;
  width:20px;
  height:20px;
  background: -webkit-radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background: -moz-radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background: -o-radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background: -ms-radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background: radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background-position:bottom right;
  background-size: 50% 50%;
  background-repeat: no-repeat;
  -webkit-transform:rotate(90deg);
  -moz-transform:rotate(90deg);
  -o-transform:rotate(90deg);
  -ms-transform:rotate(90deg);
  transform:rotate(90deg);
}
.menu li:nth-of-type(2):before{
  bottom: 1px; 
  right: -10px;
  width:20px;
  height:20px;
  background: -webkit-radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background: -moz-radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background: -o-radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background: -ms-radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background: radial-gradient(0 100%, circle, rgba(23,34,47,0) 60%,rgba(23,34,47,.4) 65%,#9fc8f7 75%, #7ab4f3 80%);
  background-position:top left;
  background-size: 50% 50%;
  background-repeat: no-repeat;
  -webkit-transform:rotate(180deg);
  -moz-transform:rotate(180deg);
  -o-transform:rotate(180deg);
  -ms-transform:rotate(180deg);
  transform:rotate(180deg);
}
.list{
  position: relative; 
  width: 625px; 
  height: 60px; 
  margin:0;
  padding:15px;
  border-radius: 10px;
  box-shadow:0 -1px 0 #305783, 0 0 3px rgba(23,34,47,1); 
  background: -webkit-linear-gradient(top,#7ab4f3,#4f80b5 34px,#4f80b5 54px,#305783); 
  background: -moz-linear-gradient(top,#7ab4f3,#4f80b5 34px,#4f80b5 54px,#305783); 
  background: -o-linear-gradient(top,#7ab4f3,#4f80b5 34px,#4f80b5 54px,#305783); 
  background: -ms-linear-gradient(top,#7ab4f3,#4f80b5 34px,#4f80b5 54px,#305783); 
  background: linear-gradient(top,#7ab4f3,#4f80b5 34px,#4f80b5 54px,#305783); 
}
.list dt{ 
  position: absolute; 
  height: 60px; 
  width: 60px; 
  box-shadow: 0 0 0 1px #697c90,0 0 0 2px #2c435b,0 3px 0 #719ed0; 
  background: -webkit-linear-gradient(top,#85b9f5,#4c749c);
  background: -moz-linear-gradient(top,#85b9f5,#4c749c);
  background: -o-linear-gradient(top,#85b9f5,#4c749c);
  background: -ms-linear-gradient(top,#85b9f5,#4c749c);
  background: linear-gradient(top,#85b9f5,#4c749c);
}
.list dt img{ 
  width: 60px; 
  height: 60px;
}
.list dd{ 
  position: relative; 
  color:#fff;
  font-size: 16px;
  font-weight:bold;
  margin-left: 75px;
  padding-left:30px; 
  line-height: 60px;
  text-shadow:0 0 0 1px #999;
  border-radius:10px;
  box-shadow:inset 0 0 8px #10161d,0 1px #719ed0;
  background: -webkit-linear-gradient(top,#243546,#111920);  
  background: -moz-linear-gradient(top,#243546,#111920);  
  background: -o-linear-gradient(top,#243546,#111920);  
  background: -ms-linear-gradient(top,#243546,#111920);  
  background: linear-gradient(top,#243546,#111920);  
}
.list dd:before,
.list dd:after{ 
  position: absolute; 
  display: block;  
  content: ""; 
  width: 0; 
  height: 0;
}
.list dd:before{
  top:50%;
  left:0;
  margin-top: -14px;
  border:10px solid #fff;
  border-color: transparent transparent transparent #9fc8f7;
}
.list dd:after{
  top:50%;
  left:0;
  margin-top: -13px;
  border:10px solid #fff;
  border-color: transparent transparent transparent #4f80b5;
}

demodownload

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

Tabs with Round Out Borders

$
0
0
Tabs with Round Out Borders

这个效果和前面藤藤制作的CSS3制作Twitter信息框是一样的,不过比她的效果简单一些,再次放上来的目的是写了一篇《Tabs with Round Out Borders》博文,主要针对的就是这种效果的制作思路与细节。在这个效果中主要运用的是元素的“:after”和“:before”来制作tabs的底部内凹圆角效果。

demodownload

HTML结构:

<ul class="nav nav-tabs" id="myTab">
  <li class="active"><a href="#home">Home</a></li>
  <li><a href="#profile">Profile</a></li>
  <li><a href="#messages">Messages</a></li>
  <li><a href="#settings">Settings</a></li>
</ul>
 
<div class="tab-content">
  <div class="tab-pane active" id="home">...</div>
  <div class="tab-pane" id="profile">...</div>
  <div class="tab-pane" id="messages">...</div>
  <div class="tab-pane" id="settings">...</div>
</div>

CSS代码

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
  margin-left: 20px;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}
.nav .active {
  z-index: 3;/*当前项在最顶端*/
}
.nav li:before,
.nav li:after,
.nav  a:before,
.nav  a:after {
  content:"";
  position: absolute;
  bottom:0;

}
.nav li:before,
.nav li:after {
  background: rgb(10, 41, 30);
  width: 10px;
  height: 10px;
}
.nav li:before {
  left: -10px;
}
.nav li:after {
  right: -10px;
}
.nav a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
  border-radius: 10px 10px 0 0;
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

.nav  a:before,
.nav  a:after {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgb(10, 41, 30);
  z-index: 2;/*圆形在矩形上面*/
}
.nav .active a:before,
.nav .active a:after {
  background: rgb(10, 41, 30);
}
.nav  a:before {
  left:-20px; 
}
.nav  a:after {
  right: -20px;
}
/*当前项的:after和:before的z-index值为1*/
.nav .active:before,
.nav .active:after {
  z-index: 1;/*当前项的矩形在圆形下面*/
  background: rgb(220, 225, 233);
}
/*第一个选项卡的:before和最后一个选项卡的:after背景色不一样*/
.nav li:first-child a:before,
.nav li:last-child a:after {
  background-color: #fff;
}
.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}
.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

jQuery代码:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="bootstrap-tab.js"></script>
<script type="text/javascript">
  $(function(){
    $('#myTab a').click(function (e) {
      e.preventDefault();
      $(this).tab('show');
    })
  });
</script>

demodownload

详细介绍请参阅:《Tabs with Round Out Borders》一文。

如需转载,烦请注明出处:http://www.w3cplus.com/demo/tabs-with-round-out-border.html


Tabs with Round Out Borders

$
0
0

前几天藤藤在每一练中写了一个《CSS3制作Twitter信息框》效果,酷似Chrome浏览器的tabs效果:

藤藤每日一练——CSS3制作Twitter信息框

从上面的效果图上来看,似乎有点棘手,特别是tabs底部的内凹圆角之处的处理。当初转这个设计图的时候,我们一起都没有思路,后来在css-tricks中找到了一篇类似于这种设计的教程,仔细阅读后才知道其原理。今天稍有空闲,将其教程Tabs with Round Out Borders介绍的方法转译成中文与大家分享。直接不来,只好转述其文章中的思想精髓,希望对大家有所帮助。

CSS3的border-radius出现,让广大Web前端人员制作圆角不在像以前那样苦逼,直接一个属性就能搞定了。但话说回来,border-radius制作一些普通圆角是方便,但制作类似于前面截图所示的圆角效果(这里称为内凹圆角)还是有一定难度的。用来一个更具形像的图来解释,要比我说的更清楚:

HTML Markup

在网站制作过程中,什么样的视觉效果都有可能出现,当然你可以使用图片来制作这一切效果。但在这里不考虑任何图片来实现,而且还想创造一个尽可能简洁的结构(为得是尽可能的更新快,至于会不会比图片快,我也不知道,没测试过),因此需要先创建一个模板:

<ul class="nav nav-tabs" id="myTab">
  <li class="active"><a href="#home">Home</a></li>
  <li><a href="#profile">Profile</a></li>
  <li><a href="#messages">Messages</a></li>
  <li><a href="#settings">Settings</a></li>
</ul>
 
<div class="tab-content">
  <div class="tab-pane active" id="home">...</div>
  <div class="tab-pane" id="profile">...</div>
  <div class="tab-pane" id="messages">...</div>
  <div class="tab-pane" id="settings">...</div>
</div>

这是一个典型的tabs的结构,上面的结构代码来自于Bootstrap中的Tabs部分,如果你还不了解Bootstrap,你可以先点击了解一下。

如何制作底部的内凹圆角效果?

前面也说了,制作前面DEMO所示效果最棘手的问题是如何制作tabs菜单底部的内凹圆角效果,原因是我们无法直接使用border-radius来实现,需要使用别的形状贴出来。为了保证结构的整洁,这里考虑不添加额外的标签,而直接使用元素的伪元素(或者伪类选择器)。如果您还是第一次听说这两个概念,你可以点击这里或者这里进行了解。从本质上说,可以添加额外的标签,通过样式来实现,但是每个元素都可以有“:after”(或“::after”)和“:before”(或“::before”),因此在这里选择了他们而没有添加额外的标签,在四个选项卡中,使用了“<li>”和“<a>”两个元素的“:after”与“:before”。

接下来我们一步一步来看实现的过程:

1、默认状态

默认状态下,li是块状,a是行内元素,为了更好的显示效果,在这两个元素上先暂时添加了border样式:

2、li浮动

将li进行左浮动,列表项相互依靠在旁边,并且缩小了与内部a标签的间距:

3、相同尺寸

如果li内没有任何margin和padding值,那么li和a元素将具有相同尺寸大小

先给以上几步加上一个简单的样式:

.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
}
.nav li {
  list-style: none outside none;
  float: left;
}
.nav li a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}
.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

4、焦点放在一个列表项上

这个时候,我们将列表项放在一个焦点之上,然后来看tabs底部内凹圆角的实现:

5、添加圆

接下来利用a的“:after”和“:before”给每个选项卡添加两个圆,先集中在一个选项卡上看效果:

这里两上圆是直接使用border-radius绘制的圆形(详细的制作方法可以点击这里)。

接下来看实际代码带来的效果:

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}
.nav li a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

/*制作圆角*/
.nav li a:before,
.nav li a:after {
  content:"";
  position: absolute;
  bottom: 0;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: red;
}
.nav li a:before {
  left:-20px; 
}
.nav li a:after {
  right: -20px;
}

.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

此时每个列表项的前与后添加了一个圆形:

为了更好的看清楚新添加的圆,暂时在li上添加一个margin样式

接下来将圆形的颜色换成和选项卡颜色一样,并且把当前项的颜色也换回来:

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}
.nav li a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

.nav li a:before,
.nav li a:after {
  content:"";
  position: absolute;
  bottom: 0;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgb(10, 41, 30);
}

/*设置当前选项卡的圆形背景色*/
.nav .active a:before,
.nav .active a:after {
  background: rgb(220, 225, 233);
}

.nav li a:before {
  left:-20px; 
}
.nav li a:after {
  right: -20px;
}

.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

6、添加距形

接下来利用li的“:after”和“:before”给每个选项卡添加两个距形,先集中在一个选项卡上看效果:

同样的,将这效果应用 到每个列表项上:

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}

/*添加正方形*/
.nav li:before,
.nav li:after {
  content:"";
  position: absolute;
  bottom:0;
  background: red;
  width: 10px;
  height: 10px;
}
.nav li:before {
  left: -10px;
}
.nav li:after {
  right: -10px;
}

.nav li a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

.nav li a:before,
.nav li a:after {
  content:"";
  position: absolute;
  bottom: 0;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgb(10, 41, 30);
}
.nav .active a:before,
.nav .active a:after {
  background: rgb(220, 225, 233);
}
.nav li a:before {
  left:-20px; 
}
.nav li a:after {
  right: -20px;
}

.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

这个时候的效如下所示:

从上面的效果图中可以看出,此时的圆形和正方形层级关系并不正确,接下来,我们需要使用z-index来改变他们的层级关系:

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}

.nav .active {
  z-index: 3;/*当前项在最顶端*/
}

.nav li:before,
.nav li:after {
  content:"";
  position: absolute;
  bottom:0;
  background: red;
  width: 10px;
  height: 10px;
}
.nav li:before {
  left: -10px;
}
.nav li:after {
  right: -10px;
}
.nav li a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

.nav li a:before,
.nav li a:after {
  content:"";
  position: absolute;
  bottom: 0;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgb(10, 41, 30);
  z-index: 2;/*圆形在矩形上面*/
}
.nav .active a:before,
.nav .active a:after {
  background: rgb(220, 225, 233);
}
.nav li a:before {
  left:-20px; 
}
.nav li a:after {
  right: -20px;
}

/*当前项的:after和:before的z-index值为1*/
.nav .active:before,
.nav .active:after {
  z-index: 1;/*当前项的矩形在圆形下面*/
}

.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

将颜色换正:

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}
.nav .active {
  z-index: 3;/*当前项在最顶端*/
}
.nav li:before,
.nav li:after {
  content:"";
  position: absolute;
  bottom:0;
  background: rgb(10, 41, 30);
  width: 10px;
  height: 10px;
}
.nav li:before {
  left: -10px;
}
.nav li:after {
  right: -10px;
}
.nav li a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

.nav li a:before,
.nav li a:after {
  content:"";
  position: absolute;
  bottom: 0;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgb(10, 41, 30);
  z-index: 2;/*圆形在矩形上面*/
}
.nav .active a:before,
.nav .active a:after {
  background: rgb(220, 225, 233);
}
.nav li a:before {
  left:-20px; 
}
.nav li a:after {
  right: -20px;
}
/*当前项的:after和:before的z-index值为1*/
.nav .active:before,
.nav .active:after {
  z-index: 1;/*当前项的矩形在圆形下面*/
  background: rgb(220, 225, 233);
}
.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

此时的效果就越来越接近我们需要了:

上面的效果离我们最终效果仅仅就差那么一顶点,效果图明显告诉我们,当前项的圆形背景色不能与相邻的其它选项容合,那么这一点很好办,我们只要将其背景色换成相邻选项卡的背景色一样就Ok了:

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}
.nav .active {
  z-index: 3;/*当前项在最顶端*/
}
.nav li:before,
.nav li:after {
  content:"";
  position: absolute;
  bottom:0;
  background: rgb(10, 41, 30);
  width: 10px;
  height: 10px;
}
.nav li:before {
  left: -10px;
}
.nav li:after {
  right: -10px;
}
.nav li a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

.nav li a:before,
.nav li a:after {
  content:"";
  position: absolute;
  bottom: 0;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgb(10, 41, 30);
  z-index: 2;/*圆形在矩形上面*/
}
.nav .active a:before,
.nav .active a:after {
  background: rgb(10, 41, 30);
}
.nav li a:before {
  left:-20px; 
}
.nav li a:after {
  right: -20px;
}
/*当前项的:after和:before的z-index值为1*/
.nav .active:before,
.nav .active:after {
  z-index: 1;/*当前项的矩形在圆形下面*/
  background: rgb(220, 225, 233);
}
.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

还有一个明显的问题,那就是第一个选 项卡和最后一个选项卡,圆形背景色没有处理,那么我们按同样的方法将其处理。

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}
.nav .active {
  z-index: 3;/*当前项在最顶端*/
}
.nav li:before,
.nav li:after {
  content:"";
  position: absolute;
  bottom:0;
  background: rgb(10, 41, 30);
  width: 10px;
  height: 10px;
}
.nav li:before {
  left: -10px;
}
.nav li:after {
  right: -10px;
}
.nav li a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

.nav li a:before,
.nav li a:after {
  content:"";
  position: absolute;
  bottom: 0;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgb(10, 41, 30);
  z-index: 2;/*圆形在矩形上面*/
}
.nav .active a:before,
.nav .active a:after {
  background: rgb(10, 41, 30);
}
.nav li a:before {
  left:-20px; 
}
.nav li a:after {
  right: -20px;
}
/*当前项的:after和:before的z-index值为1*/
.nav .active:before,
.nav .active:after {
  z-index: 1;/*当前项的矩形在圆形下面*/
  background: rgb(220, 225, 233);
}

/*第一个选项卡的:before和最后一个选项卡的:after背景色不一样*/
.nav li:first-child a:before,
.nav li:last-child a:after {
  background-color: #fff;
}

.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

底部内凹圆角效果,可算是完成了,为了让效果更佳完美,给每个选项卡顶部加上圆角效果,并且将选项卡向右移动些许px:

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
  margin-left: 20px;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}
.nav .active {
  z-index: 3;/*当前项在最顶端*/
}
.nav li:before,
.nav li:after {
  content:"";
  position: absolute;
  bottom:0;
  background: rgb(10, 41, 30);
  width: 10px;
  height: 10px;
}
.nav li:before {
  left: -10px;
}
.nav li:after {
  right: -10px;
}
.nav li a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
  border-radius: 10px 10px 0 0;/*给选项卡顶部添加圆角效果*/
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

.nav li a:before,
.nav li a:after {
  content:"";
  position: absolute;
  bottom: 0;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgb(10, 41, 30);
  z-index: 2;/*圆形在矩形上面*/
}
.nav .active a:before,
.nav .active a:after {
  background: rgb(10, 41, 30);
}
.nav li a:before {
  left:-20px; 
}
.nav li a:after {
  right: -20px;
}
/*当前项的:after和:before的z-index值为1*/
.nav .active:before,
.nav .active:after {
  z-index: 1;/*当前项的矩形在圆形下面*/
  background: rgb(220, 225, 233);
}
/*第一个选项卡的:before和最后一个选项卡的:after背景色不一样*/
.nav li:first-child a:before,
.nav li:last-child a:after {
  background-color: #fff;
}
.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

此时的效果就完美了:

最终css代码:

.demo {
  width: 660px;
  margin: 20px auto;
} 
.nav:after,
.nav:before {
  content:"";
  display: table;
} 
.nav:after {
  clear:both;
  overflow:hidden;
}
.nav {
  zoom: 1;
  margin-left: 20px;
}
.nav li {
  list-style: none outside none;
  float: left;
  position: relative;/*这个很重要*/
}
.nav .active {
  z-index: 3;/*当前项在最顶端*/
}
.nav li:before,
.nav li:after,
.nav  a:before,
.nav  a:after {
  content:"";
  position: absolute;
  bottom:0;

}
.nav li:before,
.nav li:after {
  background: rgb(10, 41, 30);
  width: 10px;
  height: 10px;
}
.nav li:before {
  left: -10px;
}
.nav li:after {
  right: -10px;
}
.nav a {
  float: left;
  padding: 10px 40px;
  text-decoration: none;
  color: rgb(220, 225, 233);
  background: rgb(10, 41, 30);
  border-radius: 10px 10px 0 0;
}
.nav .active a {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
}

.nav  a:before,
.nav  a:after {
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: rgb(10, 41, 30);
  z-index: 2;/*圆形在矩形上面*/
}
.nav .active a:before,
.nav .active a:after {
  background: rgb(10, 41, 30);
}
.nav  a:before {
  left:-20px; 
}
.nav  a:after {
  right: -20px;
}
/*当前项的:after和:before的z-index值为1*/
.nav .active:before,
.nav .active:after {
  z-index: 1;/*当前项的矩形在圆形下面*/
  background: rgb(220, 225, 233);
}
/*第一个选项卡的:before和最后一个选项卡的:after背景色不一样*/
.nav li:first-child a:before,
.nav li:last-child a:after {
  background-color: #fff;
}
.tab-content {
  background: rgb(220, 225, 233);
  color:rgb(10, 41, 30);
  padding: 20px;
}

7、添加JavaScript代码:

为了效果更像tabs选项卡效果,直接将BootstrapTabs效果用上来:

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="bootstrap-tab.js"></script>
<script type="text/javascript">
  $(function(){
    $('#myTab a').click(function (e) {
      e.preventDefault();
      $(this).tab('show');
    })
  });
</script>

同时加上对应的tabs同内容的样式:

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

这样一来,我们就算是大功告成了,最终效果可以点击下面的demo:

那么这个效果制作过程就算是完成了,不知道你有没有整清楚。如果没有整清楚的话不仿动手一试。

特别感谢css-tricks提供的敏捷思路——Tabs with Round Out Borders,不过这个效果还不是最佳效果,离我们最开始截的浏览器窗口效果还略有差别,不过大家放心,后面还有一个完善版本。如果您对这个感兴趣的,请观注本站的相关更新。

如需转载,烦请注明出处:http://www.w3cplus.com/css3/tabs-with-round-out-borders.html

CSS3重构百度图片首页中图片展示效果

$
0
0
CSS3重构百度图片首页中图片展示效果

今天使用百度图片搜索图片时,无意之中看到首页的图片展示效果具有旋转、阴影等效果。好奇之下查看其源码,使用了一些CSS3属性制作,但不知道出与什么原因,在制作这个效果中并不什么完美(我个人认为),于是动手自己整了一个,放上来与大家分享,希望大家喜欢

demodownload

HTML结构

<div id="index_tags">
  <a href="#">
    <img width="115" height="115" src="http://list.image.baidu.com/t/image/w_meinv.jpg">
    <p>美女</p>
  </a>
	...
	<a href="#">
    <img width="115" height="115" src="http://list.image.baidu.com/t/image/w_meinv.jpg">
    <p>美女</p>
  </a>
</div>

CSS代码:

body{
  background:none repeat scroll 0 0 #fff;
  font:12px arial;
  text-align:center;
  position:relative
}
body,p,form,ul{
  margin:0;
  padding:0
}
img{
  border:0
}
td,p,div{
  font-size:12px
}
p{
  width:600px;
  margin:0;
  padding:0
}
a{
  color:#00c
}
a:active{
  color:#f60
}
/*图片效果*/
#index_tags{
  width:625px;
  position:relative;
  left:5px;
  margin:30px auto 15px auto;
  font-size:0;
}
#index_tags a{
  display:inline-block;
  width:115px;
  height:115px;
  margin:0 10px 10px 0;
  position:relative;
  text-decoration:none
}
#index_tags a img{
  position:absolute;
  left:0;
  top:0;
  background:#fff;
  width:115px;
  height:115px
}
#index_tags a p{
  position:absolute;
  width:100%;
  bottom:0;
  left:0;
  border-top:1px solid #222;
  height:22px;
  line-height:22px;
  color:#fff;
  filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#99333333', endColorstr='#99333333');
  background:rgba(51,51,51,0.6);
  cursor:pointer
}
#index_tags a:before,
#index_tags a:after {
  content:"";
  display: block;
  width: 116px;
  height: 116px;
  left:-5px;
  top:-5px;
  border: 4px solid #fff;
  background:#666;
  visibility:hidden;
  -webkit-background-clip: padding-box;
  -moz-background-clip: padding-box;
  -o-background-clip: padding-box;
  -ms-background-clip: padding-box;
  background-clip: padding-box;
  box-shadow: 0 0 1px #aaa,0 0 2px #aaa;
  -webkit-transition:-webkit-transform 0s ease-in;
  -moz-transition:-moz-transform 0s ease-in;
  -o-transition:-o-transform 0s ease-in;
  transition:transform 0s ease-in;
  position:absolute;
}

#index_tags a:link,
#index_tags a:visited{
  text-decoration:none
}
#index_tags a:hover{
  zoom:1;
  z-index:20;
  text-decoration:underline
  position:relative;
}
#index_tags a:hover:before,
#index_tags a:hover:after{
  visibility:visible;
}
#index_tags a:hover:before{
  -webkit-transform:rotate(8deg) translate(6px,-1px);
  -moz-transform:rotate(8deg) translate(6px,-1px);
  -o-transform:rotate(8deg) translate(6px,-1px);
  -ms-transform:rotate(8deg) translate(6px,-1px);
  transform:rotate(8deg) translate(6px,-1px);
  z-index:2;
}
#index_tags a:hover:after{
  -webkit-transform:rotate(-8deg) translate(-5px,1px);
  -moz-transform:rotate(-8deg) translate(-5px,1px);
  -o-transform:rotate(-8deg) translate(-5px,1px);
  -ms-transform:rotate(-8deg) translate(-5px,1px);
  transform:rotate(-8deg) translate(-5px,1px);
  z-index:1;
}
#index_tags a:hover img{
  left:-5px;
  top:-5px;
  padding:4px;
  border:1px solid #aaa;
  -moz-box-shadow:1px 1px 3px #888;
  -webkit-box-shadow:1px 1px 3px #888;
  box-shadow:1px 1px 3px #888;
  z-index:3;
}
#index_tags a:hover p{
  text-decoration:underline;
  z-index: 4;
}

demodownload

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

细说百度图片栏目——图片展示效果

$
0
0

今天写个DEMO效果时,无意之中在Baidu图片中发现其图片列表使用了CSS3的transform,transition,box-shadow等属性。这是不是可以说百度在开始引领国内的CSSer开始使用CSS3相关属性呢?如果是的话,那这对于前端开发人员来说是一件福事。毕竟百度是国内互联网中大企业之一,他的一些举动都将有很多前端人员跟随着。这些都是我个人的猜想,仅供参考,因为我就是一个CSS3的爱好者,今天我想拿这个效果来说说自己的想法。如有不对还请谅解。

首先百度图片首页,有一个图片展示的效果,在这个效果中使用了CSS3的transformtransitionbox-shadow等属性,制作了鼠标悬浮时,图片有一个背景的旋转效果:

细看了一下样式源码,其在以下几个地方使用了CSS3效果:

1、标题透明效果——opacity

每张图片标题上使用了opacity属性制作了透明背景效果:

2、平滑过渡动画——transition

为了让鼠标悬浮时,图片背景卡片旋转有一个平滑效果,在这里使用了transition的效果

3、背景卡面旋转——transform

最明显的效果就是在鼠标悬浮时,图片背景卡片有一个旋转效果,这个效果是使用transform的rotate和translate来实现的:

4、图片阴影效果——box-shadow

同时在图片上添加了一个略淡的阴影效果,这个效果是使用box-shadow来实现的:

上面简单的展示了这个效果中使用到的CSS3属性,以及其对应的代码,为了更好的说明这些问题,一起先看看这个效果实现的过程:

HTML结构

同样,先从其结构下手,我们一起来看看其结构:

<div id="index_tags">
  <a href="#">
    <div class="bg_wrapper left"><div></div></div>
    <div class="bg_wrapper right"><div></div></div>
    <img width="115" height="115" src="http://list.image.baidu.com/t/image/w_meinv.jpg">
    <p>美女</p>
  </a>
	...
	<a href="#">
    <div class="bg_wrapper left"><div></div></div>
    <div class="bg_wrapper right"><div></div></div>
    <img width="115" height="115" src="http://list.image.baidu.com/t/image/w_meinv.jpg">
    <p>美女</p>
  </a>
</div>

整体的结构请看下面的截图(来自于:image.baidu.com的源代码)

结构很清晰,简单的来描述一下各个标签所起的作用:

  1. <div id="index_tags"></div>:这个div是整个图片列表的容器,放置了10个图片;
  2. <a href="#"></a>:链接a标签,这个标签包含了图片相关信息,以及包含了制作效果所需的辅助标签;
  3. <div class="bg_wrapper left"><div></div></div>:用来制作图片背景卡片向左旋转效果的辅助标签;
  4. <div class="bg_wrapper right"><div></div></div>:这组标签和上面的一样,只是用来辅助实现右旋转效果;
  5. <div></div>:div.bg_wrapper里面包含了一个div标签,这个标签主要用来模拟灰色背景效果;
  6. <img />:这个大家都清楚了,就是效果中的图片标签;
  7. <p></p>:p标签是制作图片标题信息的容器;

标签一目了然,接下来,我将这个效果的源码扒出来,想和大家一起探讨一下,或者说说我自己的观点:

CSS 代码:

body{
  background:none repeat scroll 0 0 #fff;
	font:12px arial;
	text-align:center;
	position:relative
}
body,p,form,ul{
  margin:0;
	padding:0
}
img{
  border:0
}
td,p,div{
  font-size:12px
}
p{
  width:600px;
	margin:0;
	padding:0
}
a{
  color:#00c
}
a:active{
  color:#f60
}
/*图片效果*/
#index_tags{
	width:625px;
	position:relative;
	left:5px;
	margin:30px auto 15px auto;
	font-size:0;
}
#index_tags a{
	display:inline-block;
	width:115px;
	height:115px;
	margin:0 10px 10px 0;
	position:relative;
	text-decoration:none
}
#index_tags a img{
	position:absolute;
	left:0;
	top:0;
	background:#fff;
	width:115px;
	height:115px
}
#index_tags a p{
	position:absolute;
	width:100%;
	bottom:0;
	left:0;
	background: rgb(51, 51, 51);
	border-top:1px solid #222;
	height:22px;
	line-height:22px;
	color:#fff;
	opacity:0.6;
	filter:alpha(opacity=60);
	cursor:pointer
}
#index_tags a div.bg_wrapper{
	position:absolute;
	left:-5px;
	top:-5px;
	width:125px;
	height:125px;
	border:1px solid #aaa;
	background:#fff;
	visibility:hidden;
	-webkit-transition:-webkit-transform 0s ease-in;
	-moz-transition:-moz-transform 0s ease-in;
	-o-transition:-o-transform 0s ease-in;
	transition:transform 0s ease-in
}
#index_tags a div.bg_wrapper div{
	margin:4px;
	background:#666;
	width:116px;
	height:116px
}
#index_tags a:link,
#index_tags a:visited{
	text-decoration:none
}
#index_tags a:hover{
	zoom:1;
	z-index:20;
	text-decoration:underline
}
#index_tags a:hover div.bg_wrapper{
	visibility:visible;
	*visibility:hidden;
	visibility:hidden \0
}
#index_tags a:hover div.bg_wrapper.left{
	-webkit-transform:rotate(6deg) translate(6px,-1px);
	-moz-transform:rotate(6deg) translate(6px,-1px);
	-o-transform:rotate(6deg) translate(6px,-1px);
	-transform:rotate(6deg) translate(6px,-1px)
}
#index_tags a:hover div.bg_wrapper.right{
	-webkit-transform:rotate(-5deg) translate(-5px,1px);
	-moz-transform:rotate(-5deg) translate(-5px,1px);
	-o-transform:rotate(-5deg) translate(-5px,1px);
	-transform:rotate(-5deg) translate(-5px,1px)
}
#index_tags a:hover img{
	left:-5px;
	top:-5px;
	padding:4px;
	border:1px solid #aaa;
	-moz-box-shadow:1px 1px 3px #888;
	-webkit-box-shadow:1px 1px 3px #888;
	box-shadow:1px 1px 3px #888
}
#index_tags a:hover p{
	text-decoration:underline
}
#index_tags.hover_disable div.bg_wrapper{
	display:none
}

接下来细说一下各部分代码所起的作用,以及存在的问题(我个人觉得不妥的地方,当然其他同学会有更高的见解):

1、基本布局

给容器固定一个总宽度,并且使其水平居中,同时使用“display”的“inline-block”改变链接元素的默认显示样式:

#index_tags{
	width:625px;/*设置容器宽度,容器宽度=(列表项宽度+间距宽度)*列表项个数*/
	position:relative;/*设置相对定位*/
	left:5px;/*容器向右移动5px*/
	margin:30px auto 15px auto;/*元素水平居中*/
}
#index_tags a{
	display:inline-block;/*改变链接默认显示风格,使用元素同一行显示,类似于float效果*/
	width:115px;
	height:115px;
	margin:0 10px 10px 0;
	position:relative;/*这个很重要*/
	text-decoration:none
}
#index_tags a img{
	position:absolute;
	left:0;
	top:0;
	background:#fff;
	width:115px;
	height:115px
}

这里没有采用float布局,而是采用“display:inline-block”实现类似于“float”的效果,但是存在一个问题,断行输写html标签,会增加额外空间,此空间大小由元素的字号决定,这样一来就会出现元素被挤下的效果:

但是百度图片首页的并没有掉下去,我个人猜想其结构上做了一定的修改,没有让a元素换行显示。那么为了解决这样的问题,我在“#index_tags”中简单的加了一个“font-size:0”来处理,详细的处理方法可以点击

2、图片标题透明效果

图片标题透明效果,百度采用的方法是“opacity”来控制:

#index_tags a p{
	position:absolute;
	width:100%;
	bottom:0;
	left:0;
	background: rgb(51, 51, 51);
	border-top:1px solid #222;
	height:22px;
	line-height:22px;
	color:#fff;
	opacity:0.6;
	filter:alpha(opacity=60);
	cursor:pointer
}

如果仅想让背景透明,而不影响文本,我个人觉得这样直接处理的方法并不是十分适当的方法,因为使用“opacity”属性来控制元素的透明度,会影响其子元素的透明程度。如果仅实现背景半透明,我更建议使用“rgba”来处理:

filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#99333333', endColorstr='#99333333');
background:rgba(51,51,51,0.6);

直接在线上修改一下,大家看看他们的对比效果:

此处不明白百度图片的用意,不敢妄加评论,取决由大家。如果你不太了解详细的使用方法,可以点击:,你也可以点击这里查看他的兼容处理方法。

3、图片背景卡片效果

这步的效果是百度图片首页图片展示效果中最复杂的一个效果,从他的代码中可以看出,他为了写这个效果增加了四个额外的“div”标签,用来模仿制作两个背景卡片,同时使用CSS3中的transform属性来制作旋转效果,而且一个左旋转,一个右旋转,详细的来看看这个效果的实现。

背景卡的效果:

#index_tags a div.bg_wrapper{
	position:absolute;
	left:-5px;
	top:-5px;
	width:125px;
	height:125px;
	border:1px solid #aaa;
	background:#fff;
	visibility:hidden;
	-webkit-transition:-webkit-transform 0s ease-in;
	-moz-transition:-moz-transform 0s ease-in;
	-o-transition:-o-transform 0s ease-in;
	transition:transform 0s ease-in
}
#index_tags a div.bg_wrapper div{
	margin:4px;
	background:#666;
	width:116px;
	height:116px
}

默认情况下,背景卡是隐藏不可见的:

#index_tags a:hover div.bg_wrapper{
	visibility:visible;
	*visibility:hidden;
	visibility:hidden \0
}

背景卡旋转效果

#index_tags a:hover div.bg_wrapper.left{
	-webkit-transform:rotate(6deg) translate(6px,-1px);
	-moz-transform:rotate(6deg) translate(6px,-1px);
	-o-transform:rotate(6deg) translate(6px,-1px);
	-transform:rotate(6deg) translate(6px,-1px)
}
#index_tags a:hover div.bg_wrapper.right{
	-webkit-transform:rotate(-5deg) translate(-5px,1px);
	-moz-transform:rotate(-5deg) translate(-5px,1px);
	-o-transform:rotate(-5deg) translate(-5px,1px);
	-transform:rotate(-5deg) translate(-5px,1px)
}

这个效果很意思,使用了css3的transform属性来实现背景卡旋转效果:

效果是实现了,但我认为并不完美,第一点,不知道是程序员有疏忽还是什么原因,语法都有用错:

	-transform:rotate(-5deg) translate(-5px,1px)

上面这种写法不知道是从何而来,有点搞不明白,一开始还以为是最新的写法,但查证后没有这方面的介绍。其他同学不知道有没有知道的。(这不是我挑东西,只是觉得不应该出现这样的问题)。

其二,既然使用了css3为什么不考虑ie9下的效果呢?其实使用css3完全可以达到一致的效果,还有就是采用了渐近增加来做ie6-8的效果,那为何要新增四个额外的标签来做这两个背景卡呢?我觉得有点画蛇添足,完全CSS3就能搞定的事情,下面我做了一下修改:

修改后的结构:

<div id="index_tags">
  <a href="#">
    <img width="115" height="115" src="http://list.image.baidu.com/t/image/w_meinv.jpg">
    <p>美女</p>
  </a>
	...
	<a href="#">
    <img width="115" height="115" src="http://list.image.baidu.com/t/image/w_meinv.jpg">
    <p>美女</p>
  </a>
</div>

纯CSS3制作背景卡片:

#index_tags a:before,
#index_tags a:after {
	content:"";
	display: block;
	width: 116px;
	height: 116px;
	left:-5px;
	top:-5px;
	border: 4px solid #fff;
	background:#666;
	visibility:hidden;
	-webkit-background-clip: padding-box;
	-moz-background-clip: padding-box;
	-o-background-clip: padding-box;
	-ms-background-clip: padding-box;
	background-clip: padding-box;
	box-shadow: 0 0 1px #aaa,0 0 2px #aaa;
	-webkit-transition:-webkit-transform 0s ease-in;
	-moz-transition:-moz-transform 0s ease-in;
	-o-transition:-o-transform 0s ease-in;
	transition:transform 0s ease-in;
	position:absolute;
}

#index_tags a:hover:before,
#index_tags a:hover:after{
	visibility:visible;
}
#index_tags a:hover:before{
	-webkit-transform:rotate(8deg) translate(6px,-1px);
	-moz-transform:rotate(8deg) translate(6px,-1px);
	-o-transform:rotate(8deg) translate(6px,-1px);
	-ms-transform:rotate(8deg) translate(6px,-1px);
	transform:rotate(8deg) translate(6px,-1px);
	z-index:2;
}
#index_tags a:hover:after{
	-webkit-transform:rotate(-8deg) translate(-5px,1px);
	-moz-transform:rotate(-8deg) translate(-5px,1px);
	-o-transform:rotate(-8deg) translate(-5px,1px);
	-ms-transform:rotate(-8deg) translate(-5px,1px);
	transform:rotate(-8deg) translate(-5px,1px);
	z-index:1;
}

采用css3的“:after”和“:before”来制作两个背景卡,当然这里还需要运用到“background-clip”、“box-shadow”等属性,同样离不开“transform”的属性,还有一个关键点,就是他们的层级关系“z-index”,详细的可以参阅后面我写的DEMO(如果你感兴趣的话)。

4、图片阴影效果

鼠标悬浮状态下时,给图片添加了一个阴影效果,这个效果是使用box-shadow来实现的:

#index_tags a:hover img{
	left:-5px;
	top:-5px;
	padding:4px;
	border:1px solid #aaa;
	-moz-box-shadow:1px 1px 3px #888;
	-webkit-box-shadow:1px 1px 3px #888;
	box-shadow:1px 1px 3px #888
}

到这一步,效果就算是出来了,大家可以看看百度图片这个效果在各浏览器下的效果显示:

那么百度图片首页中图片展示效果就扯到这了,下面附上一份我自己修改后的效果:

HTML 结构:

<div id="index_tags">
  <a href="#">
    <img width="115" height="115" src="http://list.image.baidu.com/t/image/w_meinv.jpg">
    <p>美女</p>
  </a>
	...
	<a href="#">
    <img width="115" height="115" src="http://list.image.baidu.com/t/image/w_meinv.jpg">
    <p>美女</p>
  </a>
</div>

CSS代码:

body{
  background:none repeat scroll 0 0 #fff;
	font:12px arial;
	text-align:center;
	position:relative
}
body,p,form,ul{
  margin:0;
	padding:0
}
img{
  border:0
}
td,p,div{
  font-size:12px
}
p{
  width:600px;
	margin:0;
	padding:0
}
a{
  color:#00c
}
a:active{
  color:#f60
}
/*图片效果*/
#index_tags{
	width:625px;
	position:relative;
	left:5px;
	margin:30px auto 15px auto;
	font-size:0;
}
#index_tags a{
	display:inline-block;
	width:115px;
	height:115px;
	margin:0 10px 10px 0;
	position:relative;
	text-decoration:none
}
#index_tags a img{
	position:absolute;
	left:0;
	top:0;
	background:#fff;
	width:115px;
	height:115px
}
#index_tags a p{
	position:absolute;
	width:100%;
	bottom:0;
	left:0;
	border-top:1px solid #222;
	height:22px;
	line-height:22px;
	color:#fff;
	filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#99333333', endColorstr='#99333333');
	background:rgba(51,51,51,0.6);
	cursor:pointer
}
#index_tags a:before,
#index_tags a:after {
	content:"";
	display: block;
	width: 116px;
	height: 116px;
	left:-5px;
	top:-5px;
	border: 4px solid #fff;
	background:#666;
	visibility:hidden;
	-webkit-background-clip: padding-box;
	-moz-background-clip: padding-box;
	-o-background-clip: padding-box;
	-ms-background-clip: padding-box;
	background-clip: padding-box;
	box-shadow: 0 0 1px #aaa,0 0 2px #aaa;
	-webkit-transition:-webkit-transform 0s ease-in;
	-moz-transition:-moz-transform 0s ease-in;
	-o-transition:-o-transform 0s ease-in;
	transition:transform 0s ease-in;
	position:absolute;
}

#index_tags a:link,
#index_tags a:visited{
	text-decoration:none
}
#index_tags a:hover{
	zoom:1;
	z-index:20;
	text-decoration:underline
	position:relative;
}
#index_tags a:hover:before,
#index_tags a:hover:after{
	visibility:visible;
}
#index_tags a:hover:before{
	-webkit-transform:rotate(8deg) translate(6px,-1px);
	-moz-transform:rotate(8deg) translate(6px,-1px);
	-o-transform:rotate(8deg) translate(6px,-1px);
	-ms-transform:rotate(8deg) translate(6px,-1px);
	transform:rotate(8deg) translate(6px,-1px);
	z-index:2;
}
#index_tags a:hover:after{
	-webkit-transform:rotate(-8deg) translate(-5px,1px);
	-moz-transform:rotate(-8deg) translate(-5px,1px);
	-o-transform:rotate(-8deg) translate(-5px,1px);
	-ms-transform:rotate(-8deg) translate(-5px,1px);
	transform:rotate(-8deg) translate(-5px,1px);
	z-index:1;
}
#index_tags a:hover img{
	left:-5px;
	top:-5px;
	padding:4px;
	border:1px solid #aaa;
	-moz-box-shadow:1px 1px 3px #888;
	-webkit-box-shadow:1px 1px 3px #888;
	box-shadow:1px 1px 3px #888;
	z-index:3;
}
#index_tags a:hover p{
	text-decoration:underline;
	z-index: 4;
}

各浏览器下的效果:

再次声明一下,今天拿百度图片来做案例,只是想让自己通过大企业做的东西去思考一些东西,并不是想拿他来说事情,何况我也没有这样的能力。在这个案例中告诉我两点:其一,CSS3并不像大家平时讨论的那样,在中国将是遥遥无期,最起码百度这样的大公司在开始用了,他可是行内的风向标,这让我们前端从业人员是不是对CSS3有点曙光了。其二,想表达的是,大公司做的东西不一定就是最好的,只能借来学习,知道一个方向,实质性的东西还是要自己去动手写的。(^_^)想说的就这些了,希望写这份博客不会得罪人,更希望这篇博文能给同学们带来些许帮助。

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

藤藤每日一练——CSS3制作Freebie标签

$
0
0
藤藤每日一练——CSS3制作Freebie标签

这个案例主要使用css3来制作标签,不过使用的的属性还是常见的那几种,可是要实现还是有一定的难度。其中最有亮点的是使用css3来实现斜线背景以及方格背景,然后就是使用@font-face来制作icon图标。原理简单,重要的是思路,以及这两种背景实现的细节。感兴趣的同学直接看源码。

demodownload

HTML标签

<div class="box">
  <ul class="nostyle">
    <li></li>
    <li></li>
    <li></li>
    <li></li>
    <li></li>
  </ul>
</div>

CSS代码

body{
  background-color: #f2f2f2;
  background-size:20px 20px,20px 20px,6px 6px,6px 6px;
  background-position:-2px -2px, -2px -2px,0 0, 3px 3px;
  background-image: -webkit-linear-gradient(white 2px, transparent 2px),
    -webkit-linear-gradient(0, white 2px, transparent 2px),
    -webkit-linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6),
    -webkit-linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6);
background-image: -moz-linear-gradient(white 2px, transparent 2px), 
    -moz-linear-gradient(0deg, white 2px, transparent 2px),
    -moz-linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6),
    -moz-linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6);
background-image: -ms-linear-gradient(white 2px, transparent 2px),
    -ms-linear-gradient(0, white 2px, transparent 2px),
    -ms-linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6),
    -ms-linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6);
background-image: -o-linear-gradient(white 2px, transparent 2px),
    -o-linear-gradient(0, white 2px, transparent 2px),
    -o-linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6),
    -o-linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6);                  
background-image: linear-gradient(white 2px, transparent 2px),
    linear-gradient(0, white 2px, transparent 2px),
    linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6),
    linear-gradient(45deg, #e6e6e6 25%, transparent 25%, transparent 75%, #e6e6e6 75%, #e6e6e6);
}
.box ul{
  margin-top: 100px;
  letter-spacing: -4px;
  word-spacing: -4px;
  font-size: 0;
  height:75px;
  text-align: center;
  box-shadow:0 -2px 3px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.05);
  background:#fff; 
}
.box li{
  letter-spacing: normal;
  word-spacing: normal;
  display:inline-block;
  *display: inline;
  zoom:1;
  position:relative;
  top:-5px;
  width:39px;
  height:48px;
  margin-right:40px;
  border-top:1px solid #66991f;
  border-left:1px solid #66991f;
  border-right:1px solid #66991f;
  overflow: hidden;
  background-color: #79b023;
  background-size:3px 3px;
  background-position: 0 0, 1px 1px;
  background-image: -webkit-linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e), 
    -webkit-linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e);
  background-image: -moz-linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e),
    -moz-linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e);
  background-image: -ms-linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e),
    -ms-linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e);
  background-image: -o-linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e),
    -o-linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e);                  
  background-image: linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e),
    linear-gradient(45deg, #91c32e 25%, transparent 25%, transparent 75%, #91c32e 75%, #91c32e);
}
.box li:last-child{ margin-right: 0;}
.box li:after,.box li:before{
  position:absolute;
  display:block;	
}
.box li:before{
  top:5px;
  left: 5px;
  content: "";
  width: 28px;
  height: 0;
  line-height: 30px;
  color:rgba(69,124,12,.5);
  border-top: 1px dashed #5d8c1c;
  border-bottom: 1px dashed #b4d969;
  font-size: 18px;
  font-family: 'icomoon';
  font-style: normal;
  speak: none;
  font-weight: normal;
  -webkit-font-smoothing: antialiased;
  -moz-font-smoothing: antialiased;
  -o-font-smoothing: antialiased;
  -ms-font-smoothing: antialiased;
  font-smoothing: antialiased;
}
.box li:after{ 
content:"";
  left:-1px;
  top:38px;
  width:38px;
  height:35px;
  box-shadow:1px 0 3px rgba(0,0,0,.3),0 -1px 3px rgba(0,0,0,.3);
  background:#fff;
  -webkit-transform:rotate(-45deg) skew(18deg,20deg);
  -moz-transform:rotate(-45deg) skew(18deg,20deg);
  -o-transform:rotate(-45deg) skew(18deg,20deg);
  -ms-transform:rotate(-45deg) skew(18deg,20deg);
  transform:rotate(-45deg) skew(18deg,20deg);
}
.box li:nth-child(1):before{
  content: "\21";
}
.box li:nth-child(2):before{
  content: "\25";
}
.box li:nth-child(3):before{
  content: "\24";
}
.box li:nth-child(4):before{
  content: "\22";
}
.box li:nth-child(5):before{
  content: "\26";
}
@font-face {
  font-family: 'icomoon';
  src:url('fonts/icomoon.eot');
  src:url('fonts/icomoon.eot?#iefix') format('embedded-opentype'),
   url('fonts/icomoon.svg#icomoon') format('svg'),
   url('fonts/icomoon.woff') format('woff'),
   url('fonts/icomoon.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

demodownload

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

藤藤每日一练——CSS3 Chunky Button Pack

$
0
0
藤藤每日一练——CSS3 Chunky Button Pack

这是一个CSS3使用gradient、box-shadow制作的按钮集合,在w3cplus有关于按钮方面的实例不少,随便搜索css3 button就会有大把相关介绍。今天老调重谈,还是使用按钮的制作,不过这里想给大家呈现的一种思想是,只要你敢想,就有实现的方法,在这里一共展示了15种不同颜色的按钮,而且在":hover"和“:active”下都有不同的效果。制作方法是一样,但配色,特别是gradient实现渐变色还是需要一定的功底的,不信你就试试吧,我可是信了,因为我也做不到。(^_^)

demodownload

HTML结构

<button type="button" class="btn">Click Me</button>

CSS代码

body{ 
  background: #dcdcdc;
}
.box{ 
  width: 550px; 
  text-align: center;
  line-height: 46px; 
  margin:40px auto; 
}
.btn{ 
  position: relative;
  font-weight:bold;
  width: 124px; 
  height: 44px; 
  border-radius: 3px; 
  border: 1px solid #c0c0c0; 
  margin:0 50px 40px 0; 
}
.btn:nth-child(3n){
  margin-right: 0;
}
.btn:nth-child(1){
  color: #8c3e4a;
  border-color: #ed7989;  
  box-shadow:inset 0 1px 0 #f9a1b1,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#f78297,#f56c7e); 
  background:-moz-linear-gradient(top,#f78297,#f56c7e); 
  background:-o-linear-gradient(top,#f78297,#f56c7e); 
  background:-ms-linear-gradient(top,#f78297,#f56c7e); 
  background:linear-gradient(top,#f78297,#f56c7e); 
}
.btn:nth-child(1):hover{
  background:-webkit-linear-gradient(top,#fbacbb,#f4798f); 
  background:-moz-linear-gradient(top,#fbacbb,#f4798f); 
  background:-o-linear-gradient(top,#fbacbb,#f4798f); 
  background:-ms-linear-gradient(top,#fbacbb,#f4798f); 
  background:linear-gradient(top,#fbacbb,#f4798f); 
}
.btn:nth-child(1):active{
  top:4px;
  box-shadow:inset 0 1px 3px #aa2c3d;
  background:-webkit-linear-gradient(top,#e15c6d,#e15c6d); 
  background:-moz-linear-gradient(top,#e15c6d,#e15c6d); 
  background:-o-linear-gradient(top,#e15c6d,#e15c6d); 
  background:-ms-linear-gradient(top,#e15c6d,#e15c6d); 
  background:linear-gradient(top,#e15c6d,#e15c6d); 
}
.btn:nth-child(2){ 
  color: #a67ea0; 
  border-color: #e6addf; 
  box-shadow:inset 0 1px 0 #ffdcfb,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#ffd0f9,#ffc2f7); 
  background:-moz-linear-gradient(top,#ffd0f9,#ffc2f7); 
  background:-o-linear-gradient(top,#ffd0f9,#ffc2f7); 
  background:-ms-linear-gradient(top,#ffd0f9,#ffc2f7); 
  background:linear-gradient(top,#ffd0f9,#ffc2f7); 
}
.btn:nth-child(2):hover{
  background:-webkit-linear-gradient(top,#ffdefb,#fdc7f6); 
  background:-moz-linear-gradient(top,#ffdefb,#fdc7f6); 
  background:-o-linear-gradient(top,#ffdefb,#ffc2f7); 
  background:-ms-linear-gradient(top,#ffdefb,#ffc2f7); 
  background:linear-gradient(top,#ffdefb,#ffc2f7); 
}
.btn:nth-child(2):active{
  top:4px;
  box-shadow:inset 0 1px 3px #be27aa;
  background:-webkit-linear-gradient(top,#f3b0ea,#f3b0ea); 
  background:-moz-linear-gradient(top,#f3b0ea,#f3b0ea); 
  background:-o-linear-gradient(top,#f3b0ea,#f3b0ea); 
  background:-ms-linear-gradient(top,#f3b0ea,#f3b0ea); 
  background:linear-gradient(top,#f3b0ea,#f3b0ea); 
}
.btn:nth-child(3){
  color: #923e3e; 
  border-color: #b74545; 
  box-shadow:inset 0 1px 0 #fe8585,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#fd5c5c,#fd4a4a); 
  background:-moz-linear-gradient(top,#fd5c5c,#fd4a4a); 
  background:-ms-linear-gradient(top,#fd5c5c,#fd4a4a); 
  background:-o-linear-gradient(top,#fd5c5c,#fd4a4a); 
  background:linear-gradient(top,#fd5c5c,#fd4a4a); 
}
.btn:nth-child(3):hover{
  background:-webkit-linear-gradient(top,#fd8d8d,#ff6161); 
  background:-moz-linear-gradient(top,#fd8d8d,#ff6161); 
  background:-o-linear-gradient(top,#fd8d8d,#ff6161); 
  background:-ms-linear-gradient(top,#fd8d8d,#ff6161); 
  background:linear-gradient(top,#fd8d8d,#ff6161); 
}
.btn:nth-child(3):active{
  top:4px;
  box-shadow:inset 0 1px 3px #a31818;
  background:-webkit-linear-gradient(top,#d43535,#d43535); 
  background:-moz-linear-gradient(top,#d43535,#d43535); 
  background:-ms-linear-gradient(top,#d43535,#d43535); 
  background:-o-linear-gradient(top,#d43535,#d43535); 
  background:linear-gradient(top,#d43535,#d43535); 
}
.btn:nth-child(4){ 
  color: #7f7f7f;
  border-color: #c8c8c8;  
  box-shadow:inset 0 1px 0 #e0e0e0,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#d7d7d7,#b7b7b7); 
  background:-moz-linear-gradient(top,#d7d7d7,#b7b7b7); 
  background:-o-linear-gradient(top,#d7d7d7,#b7b7b7); 
  background:-ms-linear-gradient(top,#d7d7d7,#b7b7b7); 
  background:linear-gradient(top,#d7d7d7,#b7b7b7); 
}
.btn:nth-child(4):hover{
  background:-webkit-linear-gradient(top,#e3e3e3,#c2c0c0); 
  background:-moz-linear-gradient(top,#e3e3e3,#c2c0c0); 
  background:-o-linear-gradient(top,#e3e3e3,#c2c0c0); 
  background:-ms-linear-gradient(top,#e3e3e3,#c2c0c0); 
  background:linear-gradient(top,#e3e3e3,#c2c0c0); 
}
.btn:nth-child(4):active{
  top:4px;
  box-shadow:inset 0 1px 3px #555;
  background:-webkit-linear-gradient(top,#a2a2a2,#a2a2a2); 
  background:-moz-linear-gradient(top,#a2a2a2,#a2a2a2); 
  background:-ms-linear-gradient(top,#a2a2a2,#a2a2a2); 
  background:-o-linear-gradient(top,#a2a2a2,#a2a2a2); 
  background:linear-gradient(top,#a2a2a2,#a2a2a2); 
}
.btn:nth-child(5){ 
  color: #3295a4; 
  border-color: #62d4e5; 
  box-shadow:inset 0 1px 0 #92f3fe,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#71effe,#4be2fe); 
  background:-moz-linear-gradient(top,#71effe,#4be2fe); 
  background:-o-linear-gradient(top,#71effe,#4be2fe); 
  background:-ms-linear-gradient(top,#71effe,#4be2fe); 
  background:linear-gradient(top,#71effe,#4be2fe); 
}
.btn:nth-child(5):hover{
  background:-webkit-linear-gradient(top,#9df5ff,#6ce6fc); 
  background:-moz-linear-gradient(top,#9df5ff,#6ce6fc); 
  background:-o-linear-gradient(top,#9df5ff,#6ce6fc); 
  background:-ms-linear-gradient(top,#9df5ff,#6ce6fc); 
  background:linear-gradient(top,#9df5ff,#6ce6fc); 
}
.btn:nth-child(5):active{
  top:4px;
  box-shadow:inset 0 1px 3px #1d8194;
  background:-webkit-linear-gradient(top,#2bbed9,#2bbed9); 
  background:-moz-linear-gradient(top,#2bbed9,#2bbed9); 
  background:-o-linear-gradient(top,#2bbed9,#2bbed9); 
  background:-ms-linear-gradient(top,#2bbed9,#2bbed9); 
  background:linear-gradient(top,#2bbed9,#2bbed9); 
}
.btn:nth-child(6){ 
  color: #a9a056;
  border-color: #ddcc52;  
  box-shadow:inset 0 1px 0 #fff48f,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#fff16d,#ffe647);
  background:-moz-linear-gradient(top,#fff16d,#ffe647);
  background:-ms-linear-gradient(top,#fff16d,#ffe647); 
  background:-o-linear-gradient(top,#fff16d,#ffe647); 
  background:linear-gradient(top,#fff16d,#ffe647); 
}
.btn:nth-child(6):hover{
  background:-webkit-linear-gradient(top,#fff69f,#ffea61); 
  background:-moz-linear-gradient(top,#fff69f,#ffea61); 
  background:-o-linear-gradient(top,#fff69f,#ffea61); 
  background:-ms-linear-gradient(top,#fff69f,#ffea61); 
  background:linear-gradient(top,#fff69f,#ffea61); 
}
.btn:nth-child(6):active{
  top:4px;
  box-shadow:inset 0 1px 3px #bbac23;
  background:-webkit-linear-gradient(top,#e2d12c,#e2d12c); 
  background:-moz-linear-gradient(top,#e2d12c,#e2d12c); 
  background:-o-linear-gradient(top,#e2d12c,#e2d12c); 
  background:-ms-linear-gradient(top,#e2d12c,#e2d12c); 
  background:linear-gradient(top,#e2d12c,#e2d12c); 
}
.btn:nth-child(7){ 
  color: #8f7031;
  border-color: #f1c462;  
  box-shadow:inset 0 1px 0 #fee392,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#feda71,#f6be53);
  background:-moz-linear-gradient(top,#feda71,#f6be53);
  background:-ms-linear-gradient(top,#feda71,#f6be53); 
  background:-o-linear-gradient(top,#feda71,#f6be53); 
  background:linear-gradient(top,#feda71,#f6be53); 
}
.btn:nth-child(7):hover{
  background:-webkit-linear-gradient(top,#ffe28e,#f6c463); 
  background:-moz-linear-gradient(top,#ffe28e,#f6c463); 
  background:-ms-linear-gradient(top,#ffe28e,#f6c463); 
  background:-o-linear-gradient(top,#ffe28e,#f6c463); 
  background:linear-gradient(top,#ffe28e,#f6c463); 
}
.btn:nth-child(7):active{
  top:4px;
  box-shadow:inset 0 1px 3px #b78421;
  background:-webkit-linear-gradient(top,#e4ab3d,#e4ab3d); 
  background:-moz-linear-gradient(top,#e4ab3d,#e4ab3d); 
  background:-o-linear-gradient(top,#e4ab3d,#e4ab3d); 
  background:-ms-linear-gradient(top,#e4ab3d,#e4ab3d); 
  background:linear-gradient(top,#e4ab3d,#e4ab3d); 
}
.btn:nth-child(8){ 
  color: #678333;
  border-color: #a7c570;  
  box-shadow:inset 0 1px 0 #d5e89f,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#cae285,#9cc15c);
  background:-moz-linear-gradient(top,#cae285,#9cc15c);
  background:-ms-linear-gradient(top,#cae285,#9cc15c); 
  background:-o-linear-gradient(top,#cae285,#9cc15c); 
  background:linear-gradient(top,#cae285,#9cc15c); 
}
.btn:nth-child(8):hover{
  background:-webkit-linear-gradient(top,#d8ed9b,#acce70); 
  background:-moz-linear-gradient(top,#d8ed9b,#acce70); 
  background:-o-linear-gradient(top,#d8ed9b,#acce70); 
  background:-ms-linear-gradient(top,#d8ed9b,#acce70); 
  background:linear-gradient(top,#d8ed9b,#acce70); 
}
.btn:nth-child(8):active{
  top:4px;
  box-shadow:inset 0 1px 3px #5a7d1e;
  background:-webkit-linear-gradient(top,#84ad3e,#84ad3e); 
  background:-moz-linear-gradient(top,#84ad3e,#84ad3e); 
  background:-ms-linear-gradient(top,#84ad3e,#84ad3e); 
  background:-o-linear-gradient(top,#84ad3e,#84ad3e); 
  background:linear-gradient(top,#84ad3e,#84ad3e); 
}
.btn:nth-child(9){ 
  color: #2d2d2d;
  border-color: #555555; 
  box-shadow:inset 0 1px 0 #7a7a7a,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#595959,#464646); 
  background:-moz-linear-gradient(top,#595959,#464646); 
  background:-o-linear-gradient(top,#595959,#464646); 
  background:-ms-linear-gradient(top,#595959,#464646); 
  background:linear-gradient(top,#595959,#464646); 
}
.btn:nth-child(9):hover{
  background:-webkit-linear-gradient(top,#7a7a7a,#5d5c5c); 
  background:-moz-linear-gradient(top,#7a7a7a,#5d5c5c); 
  background:-o-linear-gradient(top,#7a7a7a,#5d5c5c); 
  background:-ms-linear-gradient(top,#7a7a7a,#5d5c5c); 
  background:linear-gradient(top,#7a7a7a,#5d5c5c); 
}
.btn:nth-child(9):active{
  top:4px;
  box-shadow:inset 0 1px 3px #222; 
  background:-webkit-linear-gradient(top,#444343,#444343); 
  background:-moz-linear-gradient(top,#444343,#444343); 
  background:-o-linear-gradient(top,#444343,#444343); 
  background:-ms-linear-gradient(top,#444343,#444343); 
  background:linear-gradient(top,#444343,#444343); 
}
.btn:nth-child(10){ 
  color: #368eb0; 
  border-color: #88cde7; 
  box-shadow:inset 0 1px 0 #bce9f9,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#abe4f8,#70c6e7);
  background:-moz-linear-gradient(top,#abe4f8,#70c6e7);
  background:-ms-linear-gradient(top,#abe4f8,#70c6e7); 
  background:-o-linear-gradient(top,#abe4f8,#70c6e7); 
  background:linear-gradient(top,#abe4f8,#70c6e7); 
}
.btn:nth-child(10):hover{
  background:-webkit-linear-gradient(top,#c2ecfb,#8cd6f2); 
  background:-moz-linear-gradient(top,#c2ecfb,#8cd6f2); 
  background:-o-linear-gradient(top,#c2ecfb,#8cd6f2); 
  background:-ms-linear-gradient(top,#c2ecfb,#8cd6f2); 
  background:linear-gradient(top,#c2ecfb,#8cd6f2); 
}
.btn:nth-child(10):active{
  top:4px;
  box-shadow:inset 0 1px 3px #257797;
  background:-webkit-linear-gradient(top,#5eacc9,#5eacc9); 
  background:-moz-linear-gradient(top,#5eacc9,#5eacc9); 
  background:-ms-linear-gradient(top,#5eacc9,#5eacc9); 
  background:-o-linear-gradient(top,#5eacc9,#5eacc9); 
  background:linear-gradient(top,#5eacc9,#5eacc9); 
}
.btn:nth-child(11){
  color: #46678b;
  border-color: #7ea4cf; 
  box-shadow:inset 0 1px 0 #a9cded,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#94c1e9,#6ea1e1);
  background:-moz-linear-gradient(top,#94c1e9,#6ea1e1);
  background:-ms-linear-gradient(top,#94c1e9,#6ea1e1); 
  background:-o-linear-gradient(top,#94c1e9,#6ea1e1); 
  background:linear-gradient(top,#94c1e9,#6ea1e1); 
}
.btn:nth-child(11):hover{
  background:-webkit-linear-gradient(top,#a7d1f7,#79aae9); 
  background:-moz-linear-gradient(top,#a7d1f7,#79aae9); 
  background:-ms-linear-gradient(top,#a7d1f7,#79aae9); 
  background:-o-linear-gradient(top,#a7d1f7,#79aae9); 
  background:linear-gradient(top,#a7d1f7,#79aae9); 
}
.btn:nth-child(11):active{
  top:4px;
  box-shadow:inset 0 1px 3px #205aa2;
  background:-webkit-linear-gradient(top,#6391cb,#6391cb); 
  background:-moz-linear-gradient(top,#6391cb,#6391cb); 
  background:-ms-linear-gradient(top,#6391cb,#6391cb); 
  background:-o-linear-gradient(top,#6391cb,#6391cb); 
  background:linear-gradient(top,#6391cb,#6391cb); 
}
.btn:nth-child(12){
  color: #784e6a;
  border-color: #c681af; 
  box-shadow:inset 0 1px 0 #ebadd5,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#e699cb,#d677b8); 
  background:-moz-linear-gradient(top,#e699cb,#d677b8); 
  background:-ms-linear-gradient(top,#e699cb,#d677b8); 
  background:-o-linear-gradient(top,#e699cb,#d677b8); 
  background:linear-gradient(top,#e699cb,#d677b8); 
}
.btn:nth-child(12):hover{
  background:-webkit-linear-gradient(top,#f4b5de,#e082c2); 
  background:-moz-linear-gradient(top,#f4b5de,#e082c2); 
  background:-o-linear-gradient(top,#f4b5de,#e082c2); 
  background:-ms-linear-gradient(top,#f4b5de,#e082c2); 
  background:linear-gradient(top,#f4b5de,#e082c2); 
}
.btn:nth-child(12):active{
  top:4px;
  box-shadow:inset 0 1px 3px #9a2073;
  background:-webkit-linear-gradient(top,#cc6dae,#cc6dae); 
  background:-moz-linear-gradient(top,#cc6dae,#cc6dae); 
  background:-ms-linear-gradient(top,#cc6dae,#cc6dae); 
  background:-o-linear-gradient(top,#cc6dae,#cc6dae); 
  background:linear-gradient(top,#cc6dae,#cc6dae); 
}
.btn:nth-child(13){ 
  color: #b27171;
  border-color: #efb1b1;  
  box-shadow:inset 0 1px 0 #ffd1d1,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#ffc5c5,#ff9595); 
  background:-moz-linear-gradient(top,#ffc5c5,#ff9595); 
  background:-o-linear-gradient(top,#ffc5c5,#ff9595); 
  background:-ms-linear-gradient(top,#ffc5c5,#ff9595); 
  background:linear-gradient(top,#ffc5c5,#ff9595); 
}
.btn:nth-child(13):hover{
  background:-webkit-linear-gradient(top,#ffd5d5,#fd9a9a); 
  background:-moz-linear-gradient(top,#ffd5d5,#fd9a9a); 
  background:-o-linear-gradient(top,#ffd5d5,#fd9a9a); 
  background:-ms-linear-gradient(top,#ffd5d5,#fd9a9a); 
  background:linear-gradient(top,#ffd5d5,#fd9a9a); 
}
.btn:nth-child(13):active{
  top:4px;
  box-shadow:inset 0 1px 3px #c94b4b;
  background:-webkit-linear-gradient(top,#e99292,#e99292); 
  background:-moz-linear-gradient(top,#e99292,#e99292); 
  background:-ms-linear-gradient(top,#e99292,#e99292); 
  background:-o-linear-gradient(top,#e99292,#e99292); 
  background:linear-gradient(top,#e99292,#e99292); 
}
.btn:nth-child(14){ 
  color: #848484;
  border-color: #cecece;  
  box-shadow:inset 0 1px 0 #ececec,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#e5e5e5,#d5d5d5);
  background:-moz-linear-gradient(top,#e5e5e5,#d5d5d5);
  background:-o-linear-gradient(top,#e5e5e5,#d5d5d5);
  background:-ms-linear-gradient(top,#e5e5e5,#d5d5d5);
  background:linear-gradient(top,#e5e5e5,#d5d5d5);
}
.btn:nth-child(14):hover{
  background:-webkit-linear-gradient(top,#f0f0f0,#dedddd); 
  background:-moz-linear-gradient(top,#f0f0f0,#dedddd); 
  background:-o-linear-gradient(top,#f0f0f0,#dedddd); 
  background:-ms-linear-gradient(top,#f0f0f0,#dedddd); 
  background:linear-gradient(top,#f0f0f0,#dedddd); 
}
.btn:nth-child(14):active{
  top:4px;
  box-shadow:inset 0 1px 3px #acacac;
  background:-webkit-linear-gradient(top,#c6c6c6,#c6c6c6); 
  background:-moz-linear-gradient(top,#c6c6c6,#c6c6c6); 
  background:-o-linear-gradient(top,#c6c6c6,#c6c6c6); 
  background:-ms-linear-gradient(top,#c6c6c6,#c6c6c6); 
  background:linear-gradient(top,#c6c6c6,#c6c6c6); 
}
.btn:nth-child(15){ 
  color: #21729d; 
  border-color: #2b9fd9; 
  box-shadow:inset 0 1px 0 #6accf6,0 1px 0 rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#38bbf3,#2ca2e3);
  background:-moz-linear-gradient(top,#38bbf3,#2ca2e3);
  background:linear-gradient(top,#38bbf3,#2ca2e3);
}
.btn:nth-child(15):hover{
  background:-webkit-linear-gradient(top,#6ad2ff,#3fafed); 
  background:-moz-linear-gradient(top,#6ad2ff,#3fafed); 
  background:-ms-linear-gradient(top,#6ad2ff,#3fafed); 
  background:-o-linear-gradient(top,#6ad2ff,#3fafed); 
  background:linear-gradient(top,#6ad2ff,#3fafed); 
}
.btn:nth-child(15):active{
  top:4px;
  box-shadow:inset 0 1px 3px #298cc3;
  background:-webkit-linear-gradient(top,#4ea5d5,#4ea5d5); 
  background:-moz-linear-gradient(top,#4ea5d5,#4ea5d5); 
  background:-o-linear-gradient(top,#4ea5d5,#4ea5d5); 
  background:-ms-linear-gradient(top,#4ea5d5,#4ea5d5); 
  background:linear-gradient(top,#4ea5d5,#4ea5d5); 
}
.btn:before,
.btn:after{
  position: absolute;
  content: "";
  height: 50%;
  border-radius: 50%;
  z-index: -1;
}
.btn:before {
  width: 90%;
  left: 5%;
  top:12%;
  box-shadow: 0 -7px 4px rgba(0,0,0,0.3);
}
.btn:active:before {
  width: 90%;
  left: 5%;
  top:12%;
  box-shadow: 0 0 2px rgba(0,0,0,0.3);
}
.btn:after {
  width: 80%;
  left: 10%;
  bottom: 9%;
  box-shadow: 0 7px 4px rgba(0,0,0,0.4);
}
.btn:active:after {
  width: 80%;
  left: 10%;
  bottom: 9%;
  box-shadow: 0 0 0 rgba(0,0,0,0.4);
}

demodownload

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

12个优秀的Responsive LightBox特效

$
0
0
12个优秀的Responsive LightBox特效

Responsive(响应式) Design现在互联网上有关于这个的介绍到处可见,也是一种流行的布局设计。但是LightBox呢?他是一个常见的媒体展示效果,让你的图片或视频,点击后能在整个屏幕展示其效果。如果你的网站是一个Responsive布局,你当然希望Web中运用的LightBox特效也具有Responsive的功能。那怎么办呢?在《12 Responsive Lightbox Options for Website Developers》一文中整理了12个这方面的效果。我想你需要的时候能用得上

1. JackBox

JackBox - Responsive Lightbox

最近发布的具有完全的Responsive Design功能的lightbox插件,并已建成的一个可选择扩展,应该会让你感到满意。

2. Flare

 Flare Responsive Mobile-Optimized Lightbox Plugin

Flare是一款超爽的Responsive Lightbox插件。

3. MetroBox

 MetroBox - Responsive LightBox

MetroBox是一款基于评论的Responsive LightBox插件

4. Foobox

100% Mobile Responsive, Socially Integrated jQuery Image Lightboxes

Foobox是一款灵活的Responsive LightBox插件,提供多个选择参数,而且能看接当作wordpress的模块插件使用。

5. Shadowbox

shadowbox responsive lightbox

你可以使用shadowbox适应浏览器窗口的handleOversize参数。

6. fancyBox 1

fancybox download

你可以使原来的fancyBox适合浏览器窗口的fitToView参数

7. fancyBox 2

responsive fancybox2

fancyBox2,是真正的响应式设计和适应你的屏幕大小。

8. YoxView

YoxView jQuery image viewer plugin

YoxView响应的lightbox选项是非常灵活的。

9. Colorbox

colorbox responsive lightbox

Colorbox使用scalePhotos参数调整图像。

10. rlightbox

lightbox responsive lightbox

rlightbox是另一个Responsive LightBox插件。

11. Fresco

fresco responsive jquery modal

Fresco是一款超强的Responsive LightBox插件。

12. Yootheme

Widgetkit Lightbox

Yootheme是另一款Responsive LightBox插件

以上插件都配有对应的DEMO效果,以备所需。

特别声明:以上资源由提供,来自于《12 Responsive Lightbox Options for Website Developers

如需转载,烦请注明出处:http://www.w3cplus.com/source/responsive-image-lightboxes-websites.html

20款Responsive Menu教程

$
0
0
20款Responsive Menu教程

Responsive设计就不说是什么了?如果你不太了解,可以先点击这里做一定的了解,也可以点击这里查看一些有关于Responsive的案例。今天要跟大家说的是有关于Responsive导航的制作。

众所周知,导航对于一个网站来说是非常重要的,特别是一个响应式布局的网站,如何让导航也具有响应式就显得更重要了,特别是在移动端设备上显示,这个响应式菜单就更显重要,他帮助访问者更容易的找到你的网站内容。如果该网站有很多部分或者很多页面,在移动端上就变得更具挑战性,这个时候你不可以选择一个类型的菜单来适应你的移动端布局。

说和直白点,就是使用css或者jQuery插件创建一个简单的响应式菜单,该方案将帮助我们解决任何浏览器固定屏幕下的效果。现在许多网站已应用这一效果。在移动端设备上,将导航固定在任何页面的顶部,方便移动端用户选择任何页面,而在别的屏幕分辨率下又采用别同的导航布局效果。那么这样的响应式菜单要怎么制作呢?今天我为大家搜索了一些这方面的教程,希望对您有所帮助。

1. Responsive Menu with CSS3 Tutorial

Responsive Menu

demodownload

2. Drop Down Responsive Menu with CSS3 and jQuery

Drop Down Responsive Menu

demodownload

3. CSS3 Responsive Menu with Icon

CSS3 Responsive Menu

demodownload

4. Responsive Mobile-First Navigation Menu

Responsive Mobile Menu

demodownload

5. Responsive Select Menu plugin

Responsive Select Menu

demodownload

6. Create a Simple Responsive Navigation

Simple Responsive Navigation

demodownload

7. Responsive Navigation Menu  by Joshua

Responsive Navigation

demodownload

8. TinyNav Responsive Navigation Menu

TinyNav

demodownload

9. HorizontalNav

HorizontalNav

demodownload

10. Mobile Navigation Design

Mobile Navigation

demo

11. A Simple, Responsive, Mobile First Navigation

Mobile First Navigation

demodownload

12. Big Menus, Small Screens: Responsive

Big Menus

demodownload

13. Responsive Select Menu Plugin

Responsive Select Menu Plugin

demodownload

14. A Flexible Approach to Responsive Navigation

A Flexible Approach to Responsive Navigation

15. Progressive And Responsive Navigation

Progressive And Responsive Navigation

download

16. Responsive Drop Down Navigation Menu

Responsive Drop Down Navigation Menu

demodownload

17. SelectNav.js

SelectNav.js

demodownload

18. Convert a Menu to a Dropdown for Small Screens

Convert a Menu to a Dropdown for Small Screens

demodownload

19. Simple Responsive Menu

Simple Responsive Menu

demodownload

20. Meta Q how to: Responsive toggle menus

Meta Q how to: Responsive toggle menus

上面搜索了20款不同方法实现Responsive的导航制作教程以及相关案例,希望对大家有所帮助。

如需转载,烦请注明出处:http://www.w3cplus.com/source/20-useful-responsive-menu-navigation-tutorials.html


藤藤每日一练——CSS3制作分步注册表单

$
0
0
CSS3制作分步注册表单

这个DEMO是使用CSS3制作的一个分步注册表单,每个input对应的是每一步,在表单得到焦点时,对应的step也会进行对应的改变。不过这个效果是使用js代码来实现,但整个表单的外观是由CSS3来完成的,整个案例中使用了:@font-face来制作icon图标,使用gradient来制作渐变的按钮效果,使用text-shadow来制作文字阴影效果等等,方便简单点,但细节与创意才是最重要的,喜欢的同学可以看看是怎么实现的吧。

demodownload

HTML结构

<div class="login" class="clearfix">
  <h2>Sign Up Form</h2>
  <p>with steps</p>
  <form method="post" action="" id="form-control" >
    <div class="control-round" id="control-round">
      <label for="email" class="active">1</label>
      <label for="password">2</label>
      <label for="vpassword">3</label>
    </div>
    <div class="control-group">
      <input  type="text"  name="loginName" id="email"  placeholder="Email Address">
    </div>
    <div class="control-group">
      <input  type="password"  name="loginName" id="password" placeholder="Password">
    </div>
    <div class="control-group">
      <input  type="password"  name="loginName" id="vpassword" placeholder="Verify Password">
    </div>
    <div class="form-actions">
      <button class="btn" type="submit" >Sign Up</button>
      <button class="btn" type="button" >Clear</button>
    </div>
  </form>
</div>	

CSS代码

body{
  background:#1e1f20;
  font-size:18px;
}
.login{ 
  width: 330px; 
  margin: 40px auto 0;
  text-align: center;
}
.login h2{
  font:italic 32px/40px "Impact";
  letter-spacing:1px;
  color:rgba(0,0,0,0);
  background: -webkit-linear-gradient(top,#ffcf6b,#ffc54c 10%,#ffb320 40%,#c16e05);
  background: -moz-linear-gradient(top,#ffcf6b,#ffc54c 10%,#ffb320 40%,#c16e05);
  background: -o-linear-gradient(top,#ffcf6b,#ffc54c 10%,#ffb320 40%,#c16e05);
  background: -ms-linear-gradient(top,#ffcf6b,#ffc54c 10%,#ffb320 40%,#c16e05);
  background: linear-gradient(top,#ffcf6b,#ffc54c 10%,#ffb320 40%,#c16e05);
  -webkit-background-clip:text;
  /*-webkit-text-stroke: 2px #000;*/
}
.login p{ 
  color:#070606;
  font-size:28px;
  font-style:italic;
  font-weight:bold;
  text-shadow:1px 1px 0 rgba(255,255,255,.2),-1px -1px 0 rgba(255,255,255,.2);
}
.control-round{ 
  position:relative; 
  list-style:none;
  height:5px;
  border:1px solid #222222;
  background:#101010;
  margin:50px 0 40px;
}
.control-round label{
  position:absolute; 
  top:-18px;
  font-family:"Impact";
  width:36px;
  color:#151515;
  line-height:36px;
  text-shadow:-1px -1px 1px #666,1px 1px 1px #666;
  border-radius:18px;
  border:1px solid #686868;
  box-shadow:0 0 2px 2px rgba(0,0,0,.2);
  background:-webkit-linear-gradient(top,#656565,#393939);
  background:-moz-linear-gradient(top,#656565,#393939);
  background:-o-linear-gradient(top,#656565,#393939);
  background:-ms-linear-gradient(top,#656565,#393939);
  background:linear-gradient(top,#656565,#393939);
}
.control-round label.active{	
  text-shadow:0 1px 0 #f5b738;
  border:1px solid #c4883b;
  background:-webkit-linear-gradient(top,#f6ae1b,#b46001);
  background:-moz-linear-gradient(top,#f6ae1b,#b46001);
  background:-o-linear-gradient(top,#f6ae1b,#b46001);
  background:-ms-linear-gradient(top,#f6ae1b,#b46001);
  background:linear-gradient(top,#f6ae1b,#b46001);
}
.control-round label.active:after,
.control-round label.active:before{
  position:absolute; 
  display:block; 
  content:"";
  border-style:solid;
  left:50%;
  top:40px;
}
.control-round label.active:after{
  margin:5px 0 0 -6px;
  border-width:6px;
  border-color:#dc8e0f transparent transparent transparent;
  z-index:3;
}
.control-round label.active:before{
  margin:4px 0 0 -7px;	
  border-width:7px;
  border-color:#000 transparent transparent transparent;
  z-index:2;
}
.control-round label:nth-child(1){
  left:0;
}
.control-round label:nth-child(2){
  left:50%;
  margin-left:-18px;
}
.control-round label:nth-child(3){
  right:0;
}
.control-group{
  position:relative;
  margin:20px 0;
}
.control-group:after{
  position:absolute;
  display:block;
  top:10px;
  left:12px;
  width:25px;
  color:rgba(255,255,255,.6);
  text-align:center;
  font-size:16px;
  content: "\21";
  font-family: 'icomoon';
  font-style: normal;
  speak: none;
  font-weight: normal;
  -webkit-font-smoothing: antialiased;
}
.control-group:nth-child(2):after{
  content: "\22";
}
.control-group input{
  padding-left:40px;
  width:100%; 
  height:44px; 
  border-radius:22px;
  border:1px solid #2b2b2b;
  box-shadow:inset 0 0 10px rgba(0,0,0,1);
  background:#151515;
  color:#fefefe;
  -webkit-transition: border linear 0.2s, box-shadow linear 0.2s;
  -moz-transition: border linear 0.2s, box-shadow linear 0.2s;
  -o-transition: border linear 0.2s, box-shadow linear 0.2s;
  -ms-transition: border linear 0.2s, box-shadow linear 0.2s;
  transition: border linear 0.2s, box-shadow linear 0.2s;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  -o-box-sizing: border-box;
  -ms-box-sizing: border-box;
  box-sizing: border-box;
}
.control-group input:focus{
  box-shadow: inset 0 1px 3px rgba(255,255,255,0.1), 0 0 8px rgba(255,255,255, 0.6);
}
.form-actions{
  text-align:right;
}
.form-actions .btn{
  position:relative;
  padding:0 20px;
  margin-left:5px;
  height:35px;
  line-height:35px;
  color:#000;
  text-shadow:0 1px 0 #7f7f7f;	
  border-radius:17px;
  border:1px solid #4f4f4f;
  box-shadow:0 0 3px #000;
  background:-webkit-linear-gradient(top,#666666,#414141);
  background:-moz-linear-gradient(top,#666666,#414141);
  background:-o-linear-gradient(top,#666666,#414141);
  background:-ms-linear-gradient(top,#666666,#414141);
  background:linear-gradient(top,#666666,#414141);
}
.form-actions .btn:hover{
  background:-webkit-linear-gradient(top,#757575,#4e4e4e);
  background:-moz-linear-gradient(top,#757575,#4e4e4e);
  background:-o-linear-gradient(top,#757575,#4e4e4e);
  background:-ms-linear-gradient(top,#757575,#4e4e4e);
  background:linear-gradient(top,#757575,#4e4e4e);
}
.form-actions .btn:active{
  top:1px;
  border:1px solid #111;
  box-shadow:0 1px 1px #111 inset;
  background:-webkit-linear-gradient(top,#4e4e4e,#4e4e4e);
  background:-moz-linear-gradient(top,#4e4e4e,#4e4e4e);
  background:-o-linear-gradient(top,#4e4e4e,#4e4e4e);
  background:-ms-linear-gradient(top,#4e4e4e,#4e4e4e);
  background:linear-gradient(top,#4e4e4e,#4e4e4e);
}
.form-actions .btn[type=submit]{
  border:1px solid #c36e0e;
  text-shadow:0 1px 0 #f4a922;	
  background:-webkit-linear-gradient(top,#f6ab15,#b46001);	
  background:-moz-linear-gradient(top,#f6ab15,#b46001);
  background:-o-linear-gradient(top,#f6ab15,#b46001);
  background:-ms-linear-gradient(top,#f6ab15,#b46001);
  background:linear-gradient(top,#f6ab15,#b46001);
}
.form-actions .btn[type=submit]:hover{
  background:-webkit-linear-gradient(top,#ffc145,#c26905);
  background:-moz-linear-gradient(top,#ffc145,#c26905);
  background:-o-linear-gradient(top,#ffc145,#c26905);
  background:-ms-linear-gradient(top,#ffc145,#c26905);
  background:linear-gradient(top,#ffc145,#c26905);
}
.form-actions .btn[type=submit]:active{
  border:1px solid #492700;
  box-shadow:0 1px 2px #492700 inset;
  background:-webkit-linear-gradient(top,#c16e05,#c16e05);
  background:-moz-linear-gradient(top,#c16e05,#c16e05);
  background:-o-linear-gradient(top,#c16e05,#c16e05);
  background:-ms-linear-gradient(top,#c16e05,#c16e05);
  background:linear-gradient(top,#c16e05,#c16e05);
}
@font-face {
  font-family: 'icomoon';
  src:url('fonts/icomoon.eot');
  src:url('fonts/icomoon.eot?#iefix') format('embedded-opentype'),
      url('fonts/icomoon.svg#icomoon') format('svg'),
      url('fonts/icomoon.woff') format('woff'),
      url('fonts/icomoon.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

JavaScript代码

window.onload=function(){
  var oForm=document.getElementById('form-control');
  var aLabel=oForm.getElementsByTagName('label');
  var aInput=oForm.getElementsByTagName('input')
  for(var i=0;i<aLabel.length;i++){
    aInput[i].index=i;
    aLabel[i].onclick=function(){
       for(var i=0;i<aLabel.length;i++){
         aLabel[i].className='';	
       }
    this.className='active';
  }
  aInput[i].onclick=function(){
    for(var i=0;i<aLabel.length;i++){
      aLabel[i].className='';	
    }
    aLabel[this.index].className='active';
   }
  }
}

其实当前Step的状态可以使用“:target”来制作,有兴趣的同学不仿一试。

demodownload

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

2012年优秀jQuery插件连载(九)

$
0
0
2012年优秀jQuery插件连载(九)

今天继续为大家推荐十款jQuery插件,这十款插件包含以下几种类型,表单自定义样控件,比如说checkbox,radio,file等;Responsiv布局的Media Queries的javascript库;等高插件;自定义滚动条插件;媒体分享等插件,详细的大家请阅读下面的详细内容。

1、Ideal Forms

Ideal Forms

Ideal Forms是一款终极的响应式设计的HTML5表单,自定义了radios、checkbox、select和file表单元素,但IE8以下浏览器不支持。

2、enquire.js

enquire.js

一款处理Media Queries的javascript库

3、Infinity.js – A UITableView for the web

Infinity.js – A UITableView for the web

∞ is a UITableView for the web: it speeds up scrolling through long lists and keeps your infinite feeds smooth and stable for your users.

4、jQuery coreUISelect

Infinity.js – A UITableView for the web

jQuery coreUISelect是一个跨浏览器,使用jQuery和CSS自定义表单select元素的插件。需要jQuery 1.6或更高版本库支持。

5、equalize.js

equalize.js

让元素具有相同的宽度和高度。

6、jQuery custom content scroller

jQuery custom content scroller

jQuery自定义滚动条。

7、jQuery prettyCheckable

jQuery prettyCheckable

美化复选框、单选按钮。

8、floatShare

floatShare

分享按钮插件。

9、Grrrid – jQuery Equal Height Grid Plugin

Grrrid – jQuery Equal Height Grid Plugin

jQuery制作等高效果的一款插件。

10、File Style Plugin for jQuery

File Style Plugin for jQuery

一款自定义表单file的jQuery插件。

如果您对这些插件有意思,或者说你还想了解更多的插件效果,你可以点击w3cplus前段时间为大家推荐的70款jQuery插件:

  1. 2012年优秀jQuery插件连载(一)
  2. 2012年优秀jQuery插件连载(二)
  3. 2012年优秀jQuery插件连载(三)
  4. 2012年优秀jQuery插件连载(四)
  5. 2012年优秀jQuery插件连载(五)
  6. 2012年优秀jQuery插件连载(六)
  7. 2012年优秀jQuery插件连载(七)
  8. 2012年优秀jQuery插件连载(八)

如需转载,烦请注明出处:http://www.w3cplus.com/source/best-jquery-plus-2012-part9.html

15个Responsive设计的测试工具

$
0
0
15个Responsive设计的测试工具

有很多工具和技术,能创建一个完美的网站,针对于不同的用户群体。同时,网页设计已经不在单纯是一个简单的布局,相对来说比以前复杂的多。因为许多不同的浏览器分辨率和设备的出现,传纺的网页展示风格并不适合所有的设备,这样就要求Web页面出来要适应于不同的屏幕分辨率和不同的终端设备,比如说移动终端设备。值得庆幸的是,Responsive设计可以实现各种分辨率和移动终端的效果。而且有很多工具来创建创建这种技术,可以让你的网站外观在不同设备显示不同效果。今天为大家搜集了responsive设计的测试工具,希望大家在工作中能运用得上。

1、Responsive

15 Best Responsive Design Tools to test Responsive Design

这是一个测试工具,可以让你看到测试网站在在同一个屏幕上看到不同的分辨率下的效果,不需要切换到不同的模式。

2、Screenfly

15 Best Responsive Design Tools to test Responsive Design

Screenfly测试网页在各种移动设备和平板电脑下的渲染效果。它还可以测试电视和各种桌面分辨率的页面显示效果

3、Protofluid

15 Best Responsive Design Tools to test Responsive Design

Protofluid工具需要购买,提供了近100种效果,可以快速制作的液体布局,自适应CSS和响应性设计。

4、RWD Demonstration

15 Best Responsive Design Tools to test Responsive Design

可以测试web页面在iPhone、iPad和桌面下效果。

5、Resize My Browser

15 Best Responsive Design Tools to test Responsive Design

调整浏览器大小的一个在线工具,可以让你改变你的当前的浏览器设置和自定义的预设。它显示的屏幕分辨率为15个不同的设备和大小不同的设备。而且你还可以随时自定义你需要的分辨率,来改变你显示器的设置。

6、Responsinator

15 Best Responsive Design Tools to test Responsive Design

Responsinator是一种快速、简单的方法,看看你的网站在Kindle,iPhone、iPad和Android设备下的外观。它不需要下载,只是键入网站地址就OK。

7、Resizer

15 Best Responsive Design Tools to test Responsive Design

Resizer是一个工具,您可以添加到你的书签栏。它包括尺寸不同的平板电脑,桌面和移动设备,并可作为一个Chrome扩展。

8、Bricss

15 Best Responsive Design Tools to test Responsive Design

您可以选择6预定义的设备大小和添加尽可能多的自定义大小。你测试网站的结果显示在一个页面上。

9、Screenqueri.es

15 Best Responsive Design Tools to test Responsive Design

Screenqueri.es是一个更全面的工具,显示了一个网站在特定的设备接口视图。超过25个设备出现,还有一个工具来拍下一个快照,以便你可以解决问题

10、ResponsivePX

15 Best Responsive Design Tools to test Responsive Design

ResponsivePX允许您快速测试一个网站在不同的宽度和高度,您可以定制

11、Adobe Shadow

15-responsive-design-testing-tools-01-adobe-shadow

12、Aptus

15-responsive-design-testing-tools-02-aptus

13、Opera Mobile Emulator

15-responsive-design-testing-tools-04-opera-mobile-emu

14、Responsive Design Bookmarklet

15-responsive-design-testing-tools-06-responsive-design-bookmarklet

15、Responsive.is

15-responsive-design-testing-tools-07-responsive-is

如需转载,烦请注明出处:http://www.w3cplus.com/source/15-responsive-design-testing-tools.html

css重置

$
0
0

本css重置参考了normalize.cssbootstrap等,然后根据自己多年的经验进行了一些简单的整理并修改,以更适合自己目前的使用及一些大型项目的使用。

总的来说本css重置包括了三大部分,第一部分是常用的东西(包括常用元素及表单元素),第二部分是html5&css3,第三部分属于非常用标签,如果你对本css重置感兴趣的话,也可以根据你自己的项目需要对第二部分和第三部分进行删除。下面我再说下本重置的一些特色。

第一,标题部分采用的是line-height来实现标题于文字的间距,根据中英文有别,一般我们在实际项目中h2的大小为14px,高度为30px的居多。而如bootstrapnormalize.css面对的都是英文字体,所以他们默认设置的字体比中文的要大,且间距也比较大。

第二,根据我们常用的需求给ul添加了两个class样式,一个为has-style,顾名思义是拥有列表样式,因为我们在一开始重置了没有样式,但是偶尔有些时候我们又确实需要那个前面的小圆点,所以就有了这个class来还原;另一个为inline-style,即li浮动,不过一般和clearfix结合使用以清除浮动。

第三,对于normalize.css不支持的ie6,我们添加了class以支持。因为ie6不支持属性选择器,所以form表单元素的一些重置,我们在normalize.css基础上添加了class以支持。

第四,你可以根据自己的需要把你用不到的html5&css3或非常用标签的那部分直接删掉,以精简。

当然有些喜欢鱼,而有些人更喜欢渔,如果你是后者,那么可以看看normalize.css,那里有更多的代码注释给你明确的说明。

download

@charset "utf-8";
/* -------------------------------------------------
 * reset css
 * copyright: www.w3cplus.com 
 * author: 为之
 * -------------------------------------------------
*/
html{
    height:100%;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
	-webkit-font-smoothing:antialiased;
}
body,button,input,select,textarea{
    font:12px/1.5 tahoma,arial;
}
body{
	margin:0;
	padding:0;
	background-color:#fff;
	min-height:100%;
	height:auto !important;
	height:100%;
	text-align:center;
	color:#404040;
}
h1,h2,h3,h4,h5,h6,p,figure,form{
    margin:0;
}
table{
	border-collapse:collapse;
	border-spacing:0;
}
img{
	border:0;
    vertical-align:middle;
    -ms-interpolation-mode: bicubic;
}
a{
	text-decoration:none;
	color:#29B4F0;
}
a:focus {
    outline: thin dotted;
}
a:hover{
    color:#017CB9;
	text-decoration:underline;
}
/* hn */
h1{
	font-size:16px;
	line-height:36px;
}
h2{
	font-size:14px;
	line-height:30px;
}
h3{
	line-height:24px;
}
h3,h4,h5,h6{
	font-size:12px;
}
/* ul ol dl */
ul,li,ol{
    margin: 0;
	padding:0;
	list-style: none outside none;
}
ul.has-style li,ol li{
	margin-left:25px;
}
ul.has-style li{
    list-style:disc;
}
ol li{
	list-style:decimal;
}
ul.inline-style li{
	float:left;
	display:inline;
}
dl{
    margin-bottom: 18px;
}
dt{
    font-weight: bold;
}
dd{
    margin:0 0 0 9px;
	padding:0;
}
svg:not(:root) {
    overflow: hidden;
}
/* clearfix */
.clearfix:before, .clearfix:after {
    content:"";
    display:table;
}
.clearfix:after{
	clear:both;
	overflow:hidden;
}
.clearfix{
    zoom:1;
}
/* -------------------------------------------------
 * form
 * -------------------------------------------------
*/
button,input,select,textarea{
    margin: 0;
	outline: 0 none;
    vertical-align: baseline;
    *vertical-align: middle;
}
textarea{
    overflow: auto;
    vertical-align: top; 
	resize:none;
}
button,input{
    line-height: normal;
}
button,
html input[type="button"], 
input[type="reset"],
input[type="submit"],
.submit-btn{
    -webkit-appearance: button; 
    cursor: pointer; 
    *overflow: visible;
}
button[disabled],
input[disabled],
.disable{
    cursor: default;
}
input[type="checkbox"],
input[type="radio"],
.form-radio,
.form-checkbox{
    box-sizing: border-box;
    padding: 0;
    *height: 13px;
    *width: 13px;
}
fieldset{
    border: 1px solid #c0c0c0;
    margin: 0 2px 18px;
    padding: 0.35em 0.625em 0.75em;
}
legend{
    border: 0;
    padding: 0;
    white-space: normal;
    *margin-left: -7px;
}
button::-moz-focus-inner,
input::-moz-focus-inner{
    border: 0;
    padding: 0;
}
/* -------------------------------------------------
 * css3 & html5
 * -------------------------------------------------
*/
/* html5 */
article,aside,details,figcaption,figure,footer,header,hgroup,nav,section,summary{
    display: block;
}
audio,canvas,video{
    display: inline-block;
    *display: inline;
    *zoom: 1;
}
audio:not([controls]){
    display: none;
    height: 0;
}
nav ul,
nav ol {
    list-style: none;
    list-style-image: none;
}
input[type="search"]{
    -webkit-appearance: textfield;
    -moz-box-sizing: content-box;
    -webkit-box-sizing: content-box;
    box-sizing: content-box;
}
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration{
    -webkit-appearance: none;
}
:-moz-placeholder,
::-webkit-input-placeholder{
  color: #999;
}
/* -------------------------------------------------
 * 非常见标签
 * -------------------------------------------------
*/
abbr[title]{
    border-bottom: 1px dotted;
}
b,strong{
    font-weight: bold;
}
blockquote{
    margin: 1em 40px;
}
dfn{
    font-style: italic;
}
mark{
    background: #ff0;
    color: #444;
}
code,kbd,pre,samp{
    font-family: monospace, serif;
    _font-family: 'courier new', monospace;
    font-size: 1em;
}
pre{
    margin: 1em 0;
	white-space: pre;
    white-space: pre-wrap;
    word-wrap: break-word;
}
q{
    quotes: none;
}
q:before,
q:after{
    content: '';
    content: none;
}
small{
    font-size: 80%;
}
sub,sup{
    font-size: 75%;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}
sup{
    top: -0.5em;
}
sub{
    bottom: -0.25em;
}

download

HTML常用编码转换

$
0
0

本代码片段由rookie提供。

var encoding = (function () {
   function ToASCII(str) {
       return this.ToNormal(str).replace(/[^\u0000-\u00FF]/g, function () { return escape(arguments[0]).replace(/(?:%u)([0-9a-f]{4})/gi, "\$1;") });
   }
   function ToUnicode(str) {
       return this.ToNormal(str).replace(/[^\u0000-\u00FF]/g, function () { return escape(arguments[0]).replace(/(?:%u)([0-9a-f]{4})/gi, "\\u$1") });
   }
   function ToNormal(str) {
       return str.replace(/(?:)([0-9a-f]{4});|(?:\\u)([0-9a-f]{4})/gi, function () { return unescape("%u" + (arguments[1] || arguments[2])); });
   }
   function ToCss(str) {
       return this.ToNormal(str).replace(/[^\u0000-\u00FF]/g, function () { return escape(arguments[0]).replace(/(?:%u)([0-9a-f]{4})/gi, "\\$1") });
   }
   return {
       ToASCII: ToASCII,
       ToUnicode: ToUnicode,
       ToNormal: ToNormal,
       ToCss: ToCss
   };
})();
console.log(encoding.ToASCII("宋体"));
console.log(encoding.ToUnicode("宋体"));
console.log(encoding.ToNormal("宋\\u4F53"));
console.log(encoding.ToUnicode("宋体"));
console.log(encoding.ToCss('Arial , Helvetica ,"宋体", sans-serif'));
Viewing all 1557 articles
Browse latest View live