回答編集履歴

2

編集

2018/09/08 09:45

投稿

s4i
s4i

スコア139

test CHANGED
@@ -1,45 +1,187 @@
1
- ボタンエリアを大きくdivで囲ってfloat:right;を設すれば、
1
+ 表示エリア全体をdiv要素で囲って、そこでは、幅の指
2
2
 
3
+ float:left;を指定しています。
4
+
5
+ a要素は全てfloat:right;を効かせることで外側のdiv要素の
6
+
3
- 寄りなります。
7
+ 一致するようにしています。
4
8
 
5
9
  ```HTML
6
10
 
7
- <div style="float:right;">
11
+ <!DOCTYPE html>
8
12
 
9
- <a href="http://www.url/#okashi" target="_blank" class="cp_btn">その他の商品はこっち</a>
13
+ <html lang="ja">
10
-
11
- <img class="img-responsive maximage" src="http://www.amu.jpg" alt="" width="1000" height="704" />
12
14
 
13
15
 
14
16
 
15
- <a href="http://www.url/#okashi" target="_blank" class="ar_btn">小さくして右寄りにしたいボタン</a>
17
+ <head>
16
18
 
17
- <img class="img-responsive maximage" src="http://www.nroke.jpg" alt="" width="1000" height="699" />
19
+ <meta charset="utf-8">
20
+
21
+ <title>駄菓子</title>
18
22
 
19
23
 
20
24
 
21
- <a href="http://www.url/#okashi" target="_blank" class="ar_btn">小さくして右寄りにしたいボタン</a>
25
+ <style type="text/css">
22
26
 
27
+ html,
28
+
29
+ body {
30
+
23
- <img class="img-responsive maximage" src="http://www.nde-ta.jpg" alt="" width="1000" height="828" />
31
+ width: 100%;
32
+
33
+ }
24
34
 
25
35
 
26
36
 
27
- <a href="http://www.url/#okashi" target="_blank" class="cp_btn">その他の商品はこっち</a>
37
+ div {
28
38
 
39
+ width: 100%;
40
+
41
+ }
42
+
43
+
44
+
45
+ .btn-area {
46
+
47
+ width: 1000px;
48
+
49
+ /* left: 左寄せ right: 右寄せ */
50
+
51
+ float: left;
52
+
53
+ /* floatをコメントアウトした場合、中央 */
54
+
55
+ margin: 0 auto;
56
+
57
+ }
58
+
59
+
60
+
61
+ a.cp_btn {
62
+
63
+ position: relative;
64
+
65
+ float: right;
66
+
67
+ display: block;
68
+
69
+ width: 400px;
70
+
71
+ margin: auto;
72
+
73
+ max-width: 500px;
74
+
75
+ padding: 0.5em;
76
+
77
+ text-align: center;
78
+
79
+ font-weight: bold;
80
+
81
+ text-decoration: none;
82
+
83
+ color: #FFF;
84
+
85
+ text-shadow: 0 0 5px rgba(255, 255, 255, 0.0);
86
+
87
+ background: #e6b422;
88
+
89
+ transition: .4s;
90
+
91
+ border-radius: 4px;
92
+
93
+ font-size: 17pt
94
+
95
+ }
96
+
97
+
98
+
99
+ a.cp_btn:hover {
100
+
101
+ text-shadow: -6px 0px 15px rgba(255, 255, 240, 0.83), 6px 0px 15px rgba(255, 255, 240, 0.83);
102
+
103
+ transition: .4s;
104
+
105
+ }
106
+
107
+
108
+
109
+ a.ar_btn {
110
+
111
+ position: relative;
112
+
113
+ float: right;
114
+
115
+ display: block;
116
+
117
+ width: 400px;
118
+
119
+ margin: auto;
120
+
121
+ max-width: 500px;
122
+
123
+ padding: 0.5em;
124
+
125
+ text-align: center;
126
+
127
+ font-weight: bold;
128
+
129
+ text-decoration: none;
130
+
131
+ color: #FFF;
132
+
133
+ text-shadow: 0 0 5px rgba(255, 255, 255, 0.0);
134
+
135
+ background: #e6b422;
136
+
137
+ transition: .4s;
138
+
139
+ border-radius: 4px;
140
+
141
+ font-size: 17pt
142
+
143
+ }
144
+
145
+
146
+
147
+ a.ar_btn:hover {
148
+
149
+ text-shadow: -6px 0px 15px rgba(255, 255, 240, 0.83), 6px 0px 15px rgba(255, 255, 240, 0.83);
150
+
151
+ transition: .4s;
152
+
153
+ }
154
+
155
+ </style>
156
+
157
+ </head>
158
+
159
+
160
+
161
+ <body>
162
+
163
+ <div class="btn-area">
164
+
165
+ <a href="http://www.url/#okashi" target="_blank" class="cp_btn">その他の商品はこっち</a>
166
+
167
+ <img class="img-responsive maximage" src="http://www.amu.jpg" alt="" width="1000" height="704" />
168
+
169
+ <a href="http://www.url/#okashi" target="_blank" class="ar_btn">小さくして右寄りにしたいボタン</a>
170
+
171
+ <img class="img-responsive maximage" src="http://www.nroke.jpg" alt="" width="1000" height="699" />
172
+
173
+ <a href="http://www.url/#okashi" target="_blank" class="ar_btn">小さくして右寄りにしたいボタン</a>
174
+
175
+ <img class="img-responsive maximage" src="http://www.nde-ta.jpg" alt="" width="1000" height="828" />
176
+
177
+ <a href="http://www.url/#okashi" target="_blank" class="cp_btn">その他の商品はこっち</a>
178
+
29
- </div>
179
+ </div>
180
+
181
+ </body>
182
+
183
+
184
+
185
+ </html>
30
186
 
31
187
  ```
32
-
33
- 2番目と3番目の大きさを変えるには、既に書かれている
34
-
35
- class="ar_btn"のwidthを変えるだけです。
36
-
37
- ```CSS
38
-
39
- a.ar_btn {
40
-
41
- width: 200px;
42
-
43
- }
44
-
45
- ```

1

誤字

2018/09/08 09:45

投稿

s4i
s4i

スコア139

test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ```HTML
6
6
 
7
- <div style="float:left;">
7
+ <div style="float:right;">
8
8
 
9
9
  <a href="http://www.url/#okashi" target="_blank" class="cp_btn">その他の商品はこっち</a>
10
10