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

質問編集履歴

2

内容を修正しました

2024/07/22 22:08

投稿

takayuiyui
takayuiyui

スコア5

title CHANGED
@@ -1,1 +1,1 @@
1
- 【html/CSS/jQuary】クリックするとテキストが変更され方法が分からない
1
+ 【html/CSS/jQuary】「続きを読む」ボタンをクリックすると「閉じ」ボタンにるようにした
body CHANGED
@@ -11,10 +11,9 @@
11
11
  ```HTML
12
12
  <section id="sample">
13
13
  <div class="case">
14
- <figure>
15
- <img src="images/case2.png" alt="" >
14
+ <div class="more-btn js-title">
16
- </figure>
17
- <div class="more-btn js-title open">続きを読む</div>
15
+ <span class="next">続きを読む</span>
16
+ <span class="close">閉じる</span>
18
17
  <div class="inner">
19
18
  <p>
20
19
  内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。内容が入ります。
@@ -25,68 +24,28 @@
25
24
  ```
26
25
 
27
26
  ```CSS
28
- #sample figure {
29
- margin: 130px 0 0;
30
- position: relative;
31
- }
32
-
33
- #sample .more-btn {
27
+ #sample .more-btn .next {
34
- position: relative;
35
- background-color: #916a49;
36
- color: #fff;
37
- cursor: pointer;
38
- font-size: 20px;
39
- text-align: center;
40
- padding: 10px 0;
41
- margin: 0 250px 15px;
42
- border-radius: 20px;
43
- top: 40px;
44
- z-index: 10;
45
- }
46
-
47
- #sample .more-btn:before {
48
- position: absolute;
49
28
  display: block;
50
- color: #fff;
51
- font-family: "Font Awesome 5 Free";
52
- font-weight: 900;
53
- content: '\f139';
54
- top: 10px;
55
- left: 20px;
56
- font-size: 20px;
57
- transition: all .3s ease-in-out;
58
29
  }
59
30
 
60
- #sample .more-btn.open:before {
31
+ #sample .more-btn .close {
61
- transform: rotate(-180deg);
62
- top: 8px;
32
+ display: none;
63
33
  }
64
34
 
65
- #sample .inner {
35
+ #sample .more-btn .on-click .next {
66
36
  display: none;
67
- background-color: #fff;
68
- border: 4px solid #c1946b;
69
- padding: 50px 40px 40px;
70
37
  }
71
38
 
72
- #sample .inner.default {
39
+ #sample .more-btn .on-click .close {
73
40
  display: block;
74
41
  }
75
42
  ```
76
43
 
77
44
  ```js
78
45
  $(function () {
79
- $(".js-title").on("click", function () {
46
+ $(".more-btn").on("click", function() {
80
- $(this).next().slideToggle(200);
81
- $(this).toggleClass("open", 200);
47
+ $(this).toggleClass("on-click");
82
- });
83
48
  });
84
-
85
- $(function () {
86
- $(".js-title-box").on("click", function () {
87
- $(this).toggleClass("open");
88
- $(this).children(".method-box").slideToggle(200);
89
- });
90
49
  });
91
50
  ```
92
51
 

1

タイトル変更

2024/07/22 14:55

投稿

takayuiyui
takayuiyui

スコア5

title CHANGED
@@ -1,1 +1,1 @@
1
- クリックするとテキストが変更される方法が分からない(html/CSS/jQuary)
1
+ 【html/CSS/jQuary】クリックするとテキストが変更される方法が分からない
body CHANGED
File without changes