「CSS」label要素とinput要素を使うサンプル

説明
<label> を <input> 要素に関連付けるには、 <input> に id 属性を設定しなければなりません。
<label> に for 属性を設定して、値を input の id と同じにします。

使用例1

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<label class="sampleA" for="cftCd">
<input type="checkbox" id="cftCd"/>
<span>1233</span>
</label>
CSSコード
.sampleA input[type='checkbox'] {
position: absoulute;
}
<label class="sampleA" for="cftCd"> <input type="checkbox" id="cftCd"/> <span>1233</span> </label> CSSコード .sampleA input[type='checkbox'] { position: absoulute; }
<label class="sampleA" for="cftCd">
   <input type="checkbox" id="cftCd"/>
  <span>1233</span>   
</label>

CSSコード
.sampleA input[type='checkbox'] {
  position: absoulute;
}

使用例2

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<div class="prce">
<label for="cftId">abcede</label>
<input type="checkbox" name="cftId" id="cftId">
</div>
<div class="prce"> <label for="cftId">abcede</label> <input type="checkbox" name="cftId" id="cftId"> </div>
<div class="prce">
    <label for="cftId">abcede</label>
    <input type="checkbox" name="cftId" id="cftId">
</div>

 

Html

Posted by arkgame