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

質問編集履歴

1

参考にしたサイトのコードを追加しました。

2021/08/20 16:35

投稿

morfonica
morfonica

スコア33

title CHANGED
File without changes
body CHANGED
@@ -99,7 +99,74 @@
99
99
  ### 試したこと
100
100
 
101
101
  https://deshinon.com/2019/03/02/omosiro-sugoi-button-css/
102
- 上記のサイトを参考にしました。
102
+ 上記のサイトのぴょこんとするボタンを参考にしました。
103
+ ```html
104
+ <figure>
105
+ <button>Recommend</button>
106
+ <div class="shadow"></div>
107
+ </figure>
108
+ ```
109
+ ```scss
110
+ @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600);
111
+
112
+ * {
113
+ box-sizing: border-box;
114
+ margin: 0;
115
+ border: 0;
116
+ }
117
+
118
+ html, body { height: 100%; }
119
+ body {
120
+ display: flex;
121
+ justify-content: center;
122
+ align-items: center;
123
+ background: whitesmoke;
124
+ }
125
+
126
+ button {
127
+ font-family: Source Sans Pro;
128
+ font-size: 1rem;
129
+ line-height: 3.5em;
130
+ padding: 0 1.5em;
131
+ background: gold;
132
+ box-shadow: inset 0 -.125rem rgba(0,0,0,.2);
133
+ color: black;
134
+ border-radius: 5em;
135
+ cursor: pointer;
136
+ user-select: none;
137
+ transform-origin: 100% 100%;
138
+
139
+ &:focus { outline: 0; }
140
+ }
141
+
142
+ .shadow {
143
+ margin-top: -.325rem;
144
+ width: 100%;
145
+ height: .75rem;
146
+ background: radial-gradient(closest-side, gainsboro, transparent);
147
+ opacity: 0;
148
+ }
149
+ ```
150
+ ```js
151
+ $("button").mousedown(function(){
152
+ $(this).html("Recommended").velocity({
153
+ backgroundColorRed : "0",
154
+ translateY: "-1.5rem",
155
+ rotateZ: "-10deg"
156
+ }, 100, "easeOut").velocity({
157
+ rotateZ: "8deg",
158
+ }, 150).velocity({
159
+ translateY: "0",
160
+ rotateZ: "0"
161
+ }, 600, "easeOutBounce");
162
+
163
+ $("+ .shadow", this).velocity({
164
+ scale: "1.3",
165
+ opacity: "1"
166
+ }, 150).velocity("reverse", 600, "easeOutBounce");
167
+
168
+ });
169
+ ```
103
170
  html()中に何を入れたらいいのかわからなかったので、imageををのまま入れても効果がありませんでした。
104
171
  console.logをデベロッパーツールで確認してみましたが、来ていませんでした。
105
172