質問編集履歴
1
使ったコードを貼り付けました
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,3 +25,125 @@
|
|
25
25
|
いろんなサイトの、同じようなコードを貼り付けましたがどれもダメでした
|
26
26
|
|
27
27
|
どのような原因が考えられますでしょうか
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
htmlは
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
<div class="tabs-sample">
|
36
|
+
|
37
|
+
<!-- ↓切り替え用タブ(ラジオボタン) -->
|
38
|
+
|
39
|
+
<input id="sample01" type="radio" name="tab_item" checked><label class="tab_item" for="sample01">sample01</label><input id="sample02" type="radio" name="tab_item"><label class="tab_item" for="sample02">sample02</label>
|
40
|
+
|
41
|
+
<!-- ↓切り替わり要素(sample01) -->
|
42
|
+
|
43
|
+
<div class="tab_content" id="sample01_content">
|
44
|
+
|
45
|
+
<!-- ↓切り替わり要素(sample01)の内容が入ります -->
|
46
|
+
|
47
|
+
</div>
|
48
|
+
|
49
|
+
<!-- ↓切り替わり要素(sample02) -->
|
50
|
+
|
51
|
+
<div class="tab_content" id="sample02_content">
|
52
|
+
|
53
|
+
<!-- ↓切り替わり要素(sample02)の内容が入ります -->
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
</div>
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
cssは
|
62
|
+
|
63
|
+
/* ラジオボタンを全て消す */
|
64
|
+
|
65
|
+
input[name="tab_item"] {
|
66
|
+
|
67
|
+
display: none;
|
68
|
+
|
69
|
+
}
|
70
|
+
|
71
|
+
/* 選択されているタブのコンテンツのみを表示 */
|
72
|
+
|
73
|
+
#sample01:checked ~ #sample01_content,
|
74
|
+
|
75
|
+
#sample02:checked ~ #sample02_content{
|
76
|
+
|
77
|
+
display: block;
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
/* 選択されているタブのスタイルを変える */
|
82
|
+
|
83
|
+
div.tabs-sample input:checked + .tab_item {
|
84
|
+
|
85
|
+
background-color: #000;
|
86
|
+
|
87
|
+
color: #fff;
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
/* タブ切り替え全体のスタイル(任意) */
|
92
|
+
|
93
|
+
div.tabs-sample {
|
94
|
+
|
95
|
+
text-align:center;
|
96
|
+
|
97
|
+
}
|
98
|
+
|
99
|
+
/* タブのスタイル(任意) */
|
100
|
+
|
101
|
+
.tab_item {
|
102
|
+
|
103
|
+
padding:10px 45px;
|
104
|
+
|
105
|
+
border: solid #000 1px;
|
106
|
+
|
107
|
+
background-color: #fff;
|
108
|
+
|
109
|
+
font-size: 18px;
|
110
|
+
|
111
|
+
text-align: center;
|
112
|
+
|
113
|
+
line-height:1em;
|
114
|
+
|
115
|
+
color: #333;
|
116
|
+
|
117
|
+
display:inline-block;
|
118
|
+
|
119
|
+
font-weight: bold;
|
120
|
+
|
121
|
+
transition: all 0.2s ease;
|
122
|
+
|
123
|
+
margin:0;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
.tab_item:hover {
|
128
|
+
|
129
|
+
opacity: 0.75;
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
/* タブ切り替えの中身のスタイル(任意) */
|
134
|
+
|
135
|
+
.tab_content {
|
136
|
+
|
137
|
+
display: none; /* ←のみ必ず必要 */
|
138
|
+
|
139
|
+
border:solid #ccc 1px;
|
140
|
+
|
141
|
+
margin:50px 0 0;
|
142
|
+
|
143
|
+
padding:25px;
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
を貼り付けています
|