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

回答編集履歴

3

説明追記

2020/11/05 14:45

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -24,6 +24,11 @@
24
24
  ---
25
25
  CSSが提示されたので、それを元に改修。
26
26
 
27
+ - liには幅を設定しないで子要素の`.page-numbers`に幅を設定
28
+ - 「前へ」`.prev`「次へ」`.next`には上記と異なる幅を設定
29
+ - liに`display: inline-block;`を設定すれば横並びになるので、`position: absolute;`は不要。複雑になるだけ。
30
+ - 冗長な設定が多かったので、それを排除してシンプルに修正。
31
+
27
32
  ```scss
28
33
  $lightblue3: lightblue;
29
34
  $blue: blue;
@@ -49,19 +54,18 @@
49
54
  -moz-transition: all 0.3s ease;
50
55
  -o-transition: all 0.3s ease;
51
56
  transition: all 0.3s ease;
57
+ &:hover,
58
+ &:active {
59
+ color: #000;
60
+ background: #ccf;
61
+ border-color: #00f;
62
+ }
63
+ &.current {
64
+ color: #fff;
65
+ background: $blue;
66
+ }
52
67
  }
53
68
 
54
- >.current {
55
- background: $blue;
56
- }
57
-
58
- &:hover,
59
- &:active {
60
- color: #000;
61
- background: #ccf;
62
- border-color: #00f;
63
- }
64
-
65
69
  >.prev,
66
70
  >.next {
67
71
  width: 80px;
@@ -69,5 +73,4 @@
69
73
  }
70
74
  }
71
75
  ```
72
-
73
76
  [CodePenサンプル](https://codepen.io/hatena19/pen/RwRByKM)

2

コード修正

2020/11/05 14:45

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -25,6 +25,9 @@
25
25
  CSSが提示されたので、それを元に改修。
26
26
 
27
27
  ```scss
28
+ $lightblue3: lightblue;
29
+ $blue: blue;
30
+
28
31
  .page-numbers {
29
32
  text-align: center;
30
33
 
@@ -39,7 +42,7 @@
39
42
  display: table-cell;
40
43
  vertical-align: middle;
41
44
  color: #fff;
42
- background: lightblue;
45
+ background: $lightblue3;
43
46
  border-radius: 10px;
44
47
  text-decoration: none;
45
48
  -webkit-transition: all 0.3s ease;
@@ -49,7 +52,7 @@
49
52
  }
50
53
 
51
54
  >.current {
52
- background: blue;
55
+ background: $blue;
53
56
  }
54
57
 
55
58
  &:hover,

1

コード追記

2020/11/05 14:23

投稿

hatena19
hatena19

スコア34367

answer CHANGED
@@ -19,4 +19,52 @@
19
19
  ul.page-numbers > li > a.next {
20
20
  width: 50px;
21
21
  }
22
- ```
22
+ ```
23
+
24
+ ---
25
+ CSSが提示されたので、それを元に改修。
26
+
27
+ ```scss
28
+ .page-numbers {
29
+ text-align: center;
30
+
31
+ >li {
32
+ margin: 0 2px;
33
+ padding: 0;
34
+ display: inline-block;
35
+
36
+ >.page-numbers {
37
+ width: 50px;
38
+ height: 50px;
39
+ display: table-cell;
40
+ vertical-align: middle;
41
+ color: #fff;
42
+ background: lightblue;
43
+ border-radius: 10px;
44
+ text-decoration: none;
45
+ -webkit-transition: all 0.3s ease;
46
+ -moz-transition: all 0.3s ease;
47
+ -o-transition: all 0.3s ease;
48
+ transition: all 0.3s ease;
49
+ }
50
+
51
+ >.current {
52
+ background: blue;
53
+ }
54
+
55
+ &:hover,
56
+ &:active {
57
+ color: #000;
58
+ background: #ccf;
59
+ border-color: #00f;
60
+ }
61
+
62
+ >.prev,
63
+ >.next {
64
+ width: 80px;
65
+ }
66
+ }
67
+ }
68
+ ```
69
+
70
+ [CodePenサンプル](https://codepen.io/hatena19/pen/RwRByKM)