teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

外部サービスなど使わずに質問場所にコードを掲載するように変更しました

2018/08/13 14:47

投稿

teta
teta

スコア16

title CHANGED
File without changes
body CHANGED
@@ -6,4 +6,59 @@
6
6
  htmlにspanを書く方法だと簡単に実装できるかと思うのですが毎回1文字ずつspanで囲むのが大変になるので、できればしたくありません。
7
7
  初めて投稿するため勝手がわかりませんが、今現在このような感じです。
8
8
  どなたかいいやり方ご教授いただけると助かります。
9
+ ```html
10
+ <p class="text_animate">te<br>st</p>
11
+ ```
12
+
13
+ ```scss
14
+
15
+ .text_animate{
16
+ span{
17
+ transition: 1s;
18
+ opacity: 0;
19
+ &.text_animate_on{
20
+ transition: 1s;
21
+ opacity: 1;
22
+
23
+ }
24
+ }
25
+ &.text_animate_rotate span{
26
+ transform: rotate(-45deg);
27
+ display: inline-block;
28
+ &.text_animate_rotate_on{
29
+ transform: rotate(0deg);
30
+ }
31
+ }
32
+ &.text_animate_size span{
33
+ font-size: 22px;
34
+ &.text_animate_size_on{
35
+ font-size: 10px;
36
+ }
37
+ }
38
+ }
39
+ ```
40
+ ```javascript
41
+ $(function(){
42
+ var text=$(".text_animate").html();
9
- https://codepen.io/eqnu7zplnsaq9gl/pen/PBLpPm
43
+ /*var html_tags = /</?[^>]+>/;
44
+ var text_split=text.split(html_tags);*/
45
+ var text_split=text.split("");
46
+ $(".text_animate").html("");
47
+ function animate(){
48
+ text_split.forEach(function(val){
49
+ /*console.log(val);*/
50
+
51
+
52
+ $(".text_animate").append("<span>"+val+"</span>");
53
+
54
+ });
55
+
56
+ }
57
+ animate();
58
+ $(window).load(function(){
59
+ $(".text_animate span").each(function(index){
60
+ $(this).css({transitionDelay:index * 0.6 +"s"}).addClass("text_animate_on");
61
+ });
62
+ });
63
+ });
64
+ ```