良い日に、私はCSSがうまくいかず、チェックボックスのラベルの上にチェックボックスのラベルを配置するのに苦労します。手伝ってくれませんか? jqueryを使って動的にテキストを変更したいので、ラベルを中央の書式付きテキストにしたい。私がそれをチェックした場合、 "修正"テキストは "固定"になり、このテキストはチェックボックスの上の中央に置かれたままになります。 JSFIDDLE >>>https://jsfiddle.net/koykoys/d2cb96xo/です。HTML、CSSのチェックボックスのラベルの位置がチェックボックスの上にあるようにしてください
**注:「html」部分は変更しないでください。「css」部分のみを変更してください。
ありがとうございます。あなたが実際に(あなたの質問の状態のように)あなたのチェックボックスの上ご<label>
要素をしたい、とあなたの代わりに縦にここに他の回答のようなあなたのラベルのテキストを揃えたいと思っていないと仮定すると、
input[type="checkbox"]:not(:checked),
input[type="checkbox"]:checked {
position: absolute;
left: -9999px;
}
input[type="checkbox"]:not(:checked) + label,
input[type="checkbox"]:checked + label{
position: relative;
padding-left: 50px;
cursor: pointer;
}
/* checkbox aspect */
input[type="checkbox"]:not(:checked) + label:before,
input[type="checkbox"]:checked + label:before {
content: '';
position: absolute;
left:0; top: 2px;
width: 40px; height: 40px;
background: #f8f8f8;
border-radius: 3px;
border: 2px solid #aaa;
-webkit-box-shadow: groove 0 0 13px rgba(0, 0, 0, 0.5);
box-shadow: groove 0 0 13px rgba(0, 0, 0, 0.5);
}
/* checked mark aspect */
input[type="checkbox"]:not(:checked) + label:after,
input[type="checkbox"]:checked + label:after {
content: '✔';
position: absolute;
top: 0; left: 5px;
font-size: 34px;
color: green;
transition: all .2s;
-webkit-transition: all .2s;
-moz-transition: all .2s;
-ms-transition: all .2s;
-o-transition: all .2s;
}
/* checked mark aspect changes */
input[type="checkbox"]:not(:checked) + label:after {
opacity: 0;
transform: scale(0);
}
input[type="checkbox"]:checked + label:after {
opacity: 1;
transform: scale(1);
}
<div class="col-md-12">
<input id="checkid" type="checkbox">
<label for="checkid">Fixed</label>
</div>
ありがとうございます@connexo、これは私が探しているものです:)私はあなたがcssになると私はあなたの才能になることができることを願っています。 :) – Rocky