jQuery CSS3弯曲文本标题特效代码插件

jQuery CSS3弯曲文本标题特效代码插件

这是一款jQuery基于CSS3属性制作页面标题文字弯曲排列悬停特效。

使用方法
在页面引入以下jquery.min.js文件

1
<script type="text/javascript" src="js/jquery.min.js"></script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script type="text/javascript">
(function() {
  // We must use JS as we need to select previous
  // elements which can't be done with CSS.
  $('.skew-title').children('span').hover((function() {
    var $el, n;
    $el = $(this);
    n = $el.index() + 1;
    $el.addClass('flat');
    if (n % 2 === 0) {
      return $el.prev().addClass('flat');
    } else {
      if (!$el.hasClass('last')) {
        return $el.next().addClass('flat');
      }
    }
  }), function() {
    return $('.flat').removeClass('flat');
  });
   
}).call(this);
</script>

CSS样式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<style>
body {
  margin-top: 180px;
  background-color: #112;
 background-color: #0c2d41;
 font-family: Roboto, 'helvetica neue', Helvetica, Arial, sans-serif;
}
.container {
  width: 800px;
  margin: auto;
}
.row {
  position: relative;
  height: 50px;
  z-index: 1;
  clear: both;
  margin-bottom: 30px;
  text-align: center;
}
.row--intro {
  padding-top: 20px;
  font-size: 16px;
  line-height: 28px;
  font-weight: 300;
  color: #fff;
 opacity: 0.4;
}
.row--intro span {
  font-size: 11px;
}
.skew-title {
  font-size: 25px;
}
.skew-title span {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 50px;
  margin: auto;
  z-index: 2;
  text-align: center;
  color: #fff;
 font-family: 'roboto condensed';
  font-weight: 700;
  font-size: 35.714285714285715px;
  line-height: 50px;
  -webkit-transform: skewY(-15deg);
          transform: skewY(-15deg);
  -webkit-transform-origin: 0 100%;
          transform-origin: 0 100%;
  transition: all 0.2s;
  cursor: default;
}
.skew-title span:after,
.skew-title span:before {
  display: block;
  top: 0;
  left: 0;
  width: 40px;
  height: 50px;
  position: absolute;
  background: #185a81;
 content: ' ';
  z-index: -1;
  transition: all 0.2s;
}
.skew-title span:before {
  background: rgba(0,0,0,0.1);
  -webkit-transform: skewY(15deg);
          transform: skewY(15deg);
  -webkit-transform-origin: 0 0;
          transform-origin: 0 0;
}
.skew-title span:nth-child(even) {
  background-color: #144c6e;
 -webkit-transform: skewY(15deg);
          transform: skewY(15deg);
  -webkit-transform-origin: 100% 100%;
          transform-origin: 100% 100%;
  color: #d9d9d9;
}
.skew-title span:nth-child(even):after {
  background-color: #144c6e;
}
.skew-title span:nth-child(even):before {
  -webkit-transform-origin: 100% 0;
          transform-origin: 100% 0;
  -webkit-transform: skewY(-15deg);
          transform: skewY(-15deg);
}
.skew-title span.flat {
  -webkit-transform: skewY(0);
          transform: skewY(0);
  color: #fff;
}
.skew-title span.flat:before {
  -webkit-transform: skewY(0);
          transform: skewY(0);
}
.skew-title span.flat:nth-child(even):after {
  background-color: #185a81;
}
.skew-title span.alt:after {
  background-color: #b94a2c;
}
.skew-title span.alt:nth-child(even):after {
  background-color: #9d3f25;
}
.skew-title span.alt.flat:nth-child(even):after {
  background-color: #b94a2c;
}
</style>

文件信息:

    0

    发表评论