分类目录归档:CSS

CSS

CSS3中如何实现鼠标悬停在菜单上时-出现相应的动画效果呢?


摘要:
下文讲述使用css代码为一个菜单制作一个鼠标悬停的效果的方法分享,如下所示:

下午将通过示例的方式讲述其方法,如下所示:

  实现思路:
      1.为菜单元素设置hover属性
	      设置其待放入菜单下元素的位置left
	  2.设置菜单下放入元素的transition属性
	      使其呈现出动画效果
 

例:
css3代码编写一个鼠标放入菜单上时出现动画效果的示例分析

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.maomao365.com/" />
<title>猫猫小屋</title>
<style type="text/css">
* {
  margin: 0;
  padding: 0;
}
html {
  font-size: 62.5%;
}
a, a:hover, a:focus {
  text-decoration: none;
}
ul, li {
  list-style: none;
}
body {
  font-family: "mircoft yahei";
  font-size: 14px;
  font-size: 1.4rem;
  line-height: 1;
}
.clearfix:after {
  display: block;
  content: '';
  clear: both;
}
.nav {
  text-align: center;
  margin: 8rem 0;
}
.wrapper {
  position: relative;
  display: inline-block;
  text-align: center;
}
.nav .wrapper:after {
  position: absolute;
  bottom: -0.2rem;
  display: block;
  content: '';
  width: 100%;
  height: 2px;
  background-color: #FF0132;
}
.nav a {
  float: left;
  color: #000;
  padding: 1.2rem 3.6rem;
  display: block;
  position: relative;
}
.nav a:hover {
  color: #FF0132;
}
.nav a:after {
  position: absolute;
  top: 3.6rem;
  left: 45%;
  display: block;
  content: '';
  width: 0.6rem;
  height: 0.6rem;
  background-color: #FF0132;
  border-radius: 100%;
}
.dot {
  display: block;
  position: absolute;
  top: 3.4rem;
  left: -12.5%;
  width: 0.9rem;
  height: 0.9rem;
  background-color: #FF0132;
  border-radius: 100%;
  opacity: 0;
  -webkit-transition: 0.6s ease-in-out;
  -moz-transition: 0.6s ease-in-out;
  -o-transition: 0.6s ease-in-out;
  transition: 0.6s ease-in-out;
}
.nav a:first-child:hover ~ .dot {
  left: 9%;
}
.nav a:nth-child(2):hover ~ .dot {
  left: 31.5%;
}
.nav a:nth-child(3):hover ~ .dot {
  left: 57.5%;
}
.nav a:nth-child(4):hover ~ .dot {
  left: 85.5%;
}
.nav a:hover ~ .dot {
  opacity: 1;
}
</style>
</head>
<body>
  <nav class="nav">
    <div class="wrapper clearfix">
      <a href="">菜单一</a>
      <a href="">菜单二</a>
      <a href="">菜单三</a>
      <a href="">菜单四</a>
      <i class="dot"></i>
    </div>
  </nav>
</body>
</html>
css3为菜单设置动画的示例分享

css3为菜单设置动画的示例分享

CSS3中如何绘制一个”点状圆形的加载等待效果”呢?


摘要:
下文讲述使用css代码制作一个”点状圆形的加载等待效果”的方法分享,如下所示:

下午将通过示例的方式讲述其方法,如下所示:

  实现思路:
       1.绘制5个点状元素
	   2.设置动画,对元素进行旋转
	    即可模拟出“加载等待效果”
 

例:
css3代码编写一个“点状圆形的加载等待效果”的示例分析

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.maomao365.com/" />
<title>猫猫小屋</title>
<style>
/*css reset */
body, p, div, ol, ul, li, dl, dt, dd, h1, h2, h3, h4, h5, h6, form, input, iframe, nav {
  margin: 0;
  padding: 0;
}
.wrapper {
  width: 1000px;
  margin: 200px auto;
}
.windows8 {
  position: relative;
  width: 44px;
  height: 44px;
  margin: auto;
}
.windows8 .wBall {
  position: absolute;
  width: 42px;
  height: 42px;
  opacity: 0;
  transform: rotate(225deg);
  -o-transform: rotate(225deg);
  -ms-transform: rotate(225deg);
  -webkit-transform: rotate(225deg);
  -moz-transform: rotate(225deg);
  animation: orbit 3.6325s infinite;
  -o-animation: orbit 3.6325s infinite;
  -webkit-animation: orbit 3.6325s infinite;
  -moz-animation: orbit 3.6325s infinite;
}
.windows8 .wBall .wInnerBall {
  position: absolute;
  width: 5px;
  height: 5px;
  background: rgb(0,0,0);
  left: 0px;
  top: 0px;
  border-radius: 5px;
}
.windows8 #wBall_1 {
  animation-delay: 0.796s;
  -o-animation-delay: 0.796s;
  -webkit-animation-delay: 0.796s;
  -moz-animation-delay: 0.796s;
}
.windows8 #wBall_2 {
  animation-delay: 0.153s;
  -o-animation-delay: 0.153s;
  -webkit-animation-delay: 0.153s;
  -moz-animation-delay: 0.153s;
}
.windows8 #wBall_3 {
  animation-delay: 0.3165s;
  -o-animation-delay: 0.3165s;
  -webkit-animation-delay: 0.3165s;
  -moz-animation-delay: 0.3165s;
}
.windows8 #wBall_4 {
  animation-delay: 0.4695s;
  -o-animation-delay: 0.4695s;
  -webkit-animation-delay: 0.4695s;
  -moz-animation-delay: 0.4695s;
}
.windows8 #wBall_5 {
  animation-delay: 0.633s;
  -o-animation-delay: 0.633s;
  -webkit-animation-delay: 0.633s;
  -moz-animation-delay: 0.633s;
}
@keyframes orbit {
  0% {
    opacity: 1;
    z-index: 99;
    transform: rotate(180deg);
    animation-timing-function: ease-out;
  }
  7% {
    opacity: 1;
    transform: rotate(300deg);
    animation-timing-function: linear;
  }
  30% {
    opacity: 1;
    transform: rotate(410deg);
    animation-timing-function: ease-in-out;
  }
  39% {
    opacity: 1;
    transform: rotate(645deg);
    animation-timing-function: linear;
  }
  70% {
    opacity: 1;
    transform: rotate(770deg);
    animation-timing-function: ease-out;
  }
  75% {
    opacity: 1;
    transform: rotate(900deg);
    animation-timing-function: ease-out;
  }
  76% {
    opacity: 0;
    transform: rotate(900deg);
  }
  100% {
    opacity: 0;
    transform: rotate(900deg);
  }
}
@-o-keyframes orbit {
  0% {
    opacity: 1;
    z-index: 99;
    -o-transform: rotate(180deg);
    -o-animation-timing-function: ease-out;
  }
  7% {
    opacity: 1;
    -o-transform: rotate(300deg);
    -o-animation-timing-function: linear;
  }
  30% {
    opacity: 1;
    -o-transform: rotate(410deg);
    -o-animation-timing-function: ease-in-out;
  }
  39% {
    opacity: 1;
    -o-transform: rotate(645deg);
    -o-animation-timing-function: linear;
  }
  70% {
    opacity: 1;
    -o-transform: rotate(770deg);
    -o-animation-timing-function: ease-out;
  }
  75% {
    opacity: 1;
    -o-transform: rotate(900deg);
    -o-animation-timing-function: ease-out;
  }
  76% {
    opacity: 0;
    -o-transform: rotate(900deg);
  }
  100% {
    opacity: 0;
    -o-transform: rotate(900deg);
  }
}
@-ms-keyframes orbit {
  0% {
    opacity: 1;
    z-index: 99;
    -ms-transform: rotate(180deg);
  }
  7% {
    opacity: 1;
    -ms-transform: rotate(300deg);
  }
  30% {
    opacity: 1;
    -ms-transform: rotate(410deg);
  }
  39% {
    opacity: 1;
    -ms-transform: rotate(645deg);
  }
  70% {
    opacity: 1;
    -ms-transform: rotate(770deg);
  }
  75% {
    opacity: 1;
    -ms-transform: rotate(900deg);
  }
  76% {
    opacity: 0;
    -ms-transform: rotate(900deg);
  }
  100% {
    opacity: 0;
    -ms-transform: rotate(900deg);
  }
}
  
@-webkit-keyframes orbit {
  0% {
    opacity: 1;
    z-index: 99;
    -webkit-transform: rotate(180deg);
    -webkit-animation-timing-function: ease-out;
  }
  7% {
    opacity: 1;
    -webkit-transform: rotate(300deg);
    -webkit-animation-timing-function: linear;
  }
  30% {
    opacity: 1;
    -webkit-transform: rotate(410deg);
    -webkit-animation-timing-function: ease-in-out;
  }
  39% {
    opacity: 1;
    -webkit-transform: rotate(645deg);
    -webkit-animation-timing-function: linear;
  }
  70% {
    opacity: 1;
    -webkit-transform: rotate(770deg);
    -webkit-animation-timing-function: ease-out;
  }
  75% {
    opacity: 1;
    -webkit-transform: rotate(900deg);
    -webkit-animation-timing-function: ease-out;
  }
  76% {
    opacity: 0;
    -webkit-transform: rotate(900deg);
  }
  100% {
    opacity: 0;
    -webkit-transform: rotate(900deg);
  }
}
@-moz-keyframes orbit {
  0% {
    opacity: 1;
    z-index: 99;
    -moz-transform: rotate(180deg);
    -moz-animation-timing-function: ease-out;
  }
  7% {
    opacity: 1;
    -moz-transform: rotate(300deg);
    -moz-animation-timing-function: linear;
  }
  30% {
    opacity: 1;
    -moz-transform: rotate(410deg);
    -moz-animation-timing-function: ease-in-out;
  }
  39% {
    opacity: 1;
    -moz-transform: rotate(645deg);
    -moz-animation-timing-function: linear;
  }
  70% {
    opacity: 1;
    -moz-transform: rotate(770deg);
    -moz-animation-timing-function: ease-out;
  }
  75% {
    opacity: 1;
    -moz-transform: rotate(900deg);
    -moz-animation-timing-function: ease-out;
  }
  76% {
    opacity: 0;
    -moz-transform: rotate(900deg);
  }
  100% {
    opacity: 0;
    -moz-transform: rotate(900deg);
  }
}
</style>
</head>
<body>
  <div class="wrapper">
    <div class="windows8">
      <div class="wBall" id="wBall_1">
        <div class="wInnerBall"></div>
      </div>
      <div class="wBall" id="wBall_2">
        <div class="wInnerBall"></div>
      </div>
      <div class="wBall" id="wBall_3">
        <div class="wInnerBall"></div>
      </div>
      <div class="wBall" id="wBall_4">
        <div class="wInnerBall"></div>
      </div>
      <div class="wBall" id="wBall_5">
        <div class="wInnerBall"></div>
      </div>
    </div>
  </div>
</body>
</html>
css3实现一个点状圆形进度条的示例分享

css3实现一个点状圆形进度条的示例分享

CSS3中如何绘制一个”运动的边框”呢?


摘要:
下文讲述使用css代码为一个元素绘制”运动着的边框”的方法分享,如下所示:

下午将通过示例的方式讲述其方法,如下所示:

  实现思路:
      1.为元素设置"边框线"背景
	  2.设置动画,通过改变元素背景位置,
	    使其产生动画效果
 

例:
css 为元素设置“运动的边框”的示例分析

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.maomao365.com/" />
<title>猫猫小屋</title>
<style>
body {
  background-color: rgb(229, 201, 255);
}
.father {
  width: 280px;
  height: 180px;
  background-color: #fff;
  padding: 1px;
  background-image: -webkit-linear-gradient(-45deg,rgba(0, 0, 0, 1) 25%,rgba(0, 0, 0, 0) 25%,rgba(0, 0, 0, 0) 50%,rgba(0, 0, 0, 1) 50%,rgba(0, 0, 0, 1) 75%,rgba(0, 0, 0, 0) 75%,rgba(0, 0, 0, 0));
  background-size: 10px 10px;
  animation: dongHua 0.8s linear;
  animation-iteration-count: infinite;
}
.child {
  width: 280px;
  height: 180px;
  background-color: rgba(255,255,255,1);
}
@keyframes dongHua {
  0% {
    background-position: 0px 0px;
  }
  80% {
    background-position: 0px 5px;
  }
  100% {
    background-position: 0px 10px;
  }
}
</style>
</head>
<body>
<div class="father">
  <div class="child">
    maomao365.com
	 运动边框示例
  </div>
</div>
</body>
</html>
css3绘制一个运动着边框的示例分享

css3绘制一个运动着边框的示例分享