回答編集履歴
1
追記
answer
CHANGED
|
@@ -26,4 +26,56 @@
|
|
|
26
26
|
<option value="green">グリーン</option>
|
|
27
27
|
</select>
|
|
28
28
|
<div class="change blue">色よ変われ!</div>
|
|
29
|
+
```
|
|
30
|
+
# 追記
|
|
31
|
+
.kokomo:beforeの色を変える
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
.red{ background-Color: red;}
|
|
35
|
+
.blue{ background-Color: blue;}
|
|
36
|
+
.green{ background-Color:green;}
|
|
37
|
+
.beforered:before{background-Color: red;}
|
|
38
|
+
.beforeblue:before{ background-Color: blue;}
|
|
39
|
+
.beforegreen:before{ background-Color:green;}
|
|
40
|
+
|
|
41
|
+
.box {margin: 20px;}
|
|
42
|
+
.change {
|
|
43
|
+
color: #fff;
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
width: 200px;
|
|
46
|
+
margin: 20px;
|
|
47
|
+
}
|
|
48
|
+
.kokomo {
|
|
49
|
+
color: #000000;
|
|
50
|
+
margin: 20px;
|
|
51
|
+
font-weight: bold;
|
|
52
|
+
}
|
|
53
|
+
.kokomo:before {
|
|
54
|
+
content: '';
|
|
55
|
+
position: absolute;
|
|
56
|
+
top: 0;
|
|
57
|
+
width: 20px;
|
|
58
|
+
height: 20px;
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
```javascript
|
|
63
|
+
$(function(){
|
|
64
|
+
$('select').on('change',function(){
|
|
65
|
+
$('.change').removeClass('red blue green').addClass($(this).val());
|
|
66
|
+
$('.kokomo').removeClass('beforered beforeblue beforegreen').addClass("before"+$(this).val());
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
```
|
|
70
|
+
```HTML
|
|
71
|
+
<div class="box">
|
|
72
|
+
<select class="select_color" name="onamae" data-required="no" data-type="select">
|
|
73
|
+
<option value="blue">ブルー</option>
|
|
74
|
+
<option value="red">レッド</option>
|
|
75
|
+
<option value="green">グリーン</option>
|
|
76
|
+
</select>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div class="change blue">ここの色が変わる!</div>
|
|
80
|
+
<div class="kokomo beforeblue">ここも</div>
|
|
29
81
|
```
|