css3第一步第二步分步效果

antzone發表於2018-02-14

本章節分享一段程式碼例項,它實現了第一步、第二步這樣的分步流程效果。

程式碼例項如下:

[HTML] 純文字檢視 複製程式碼執行程式碼
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>螞蟻部落</title>
<link href="" rel="stylesheet">
<style type="text/css">
.step {
  border: 1px solid #E9E9E9;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 0 4px #E9E9E9;
  width: 80%;
  margin: 50px auto;
  box-sizing: border-box;
}
.step .steps {
  display: inline-block;
  padding: 10px 10%;
  background: white;
  color: black;
  font-family: "Microsoft YaHei";
  position: relative;
  width: 25%;
  box-sizing: border-box;
  float: left;
  transition: all ease-in 0.5s;
  cursor: pointer;
}
.step .steps::after {
  position: absolute;
  content: "";
  display: block;
  height: 30px;
  width: 30px;
  background: white;
  top: 5px;
  right: -15px;
  transform: rotate(-45deg);
  transition: all ease-in 0.5s;
}
.step .steps:nth-child(1) {
  z-index: 3;
}
.step .steps:nth-child(2) {
  z-index: 2;
}
.step .steps:nth-child(3) {
  z-index: 1;
}
.step .steps:last-child::after {
  display: none;
}
.step .steps:hover, .step .steps:hover::after {
  background: #F0F0F0;
}
.step .steps:active, .step .steps:active::after {
  background: #8FA35D;
  color: white;
}
.step .steps.action {
  color: white;
  background-color: #3690CF;
}
.step .steps.action::after {
  background-color: #3690CF;
}
.step .steps:nth-child(3)::after {
  border-bottom: 1px solid #E5E5E5;
  border-right: 1px solid #E5E5E5;
}
.step .steps.disabled, .step .steps.disabled::after {
  color: #CBCBCB;
  background: white;
}
</style>
</head>
<body>
  <div class="step">
    <span class="steps">第一步</span>
    <span class="steps action">第二步</span>
    <span class="steps">第三步</span>
    <span class="steps disabled">第四步</span>
  </div>
</body>
</html>

相關文章