Maison >interface Web >tutoriel HTML >请教关于nth-child的问题_html/css_WEB-ITnose
有如下代码
<style>.formtabs .panel { display: none; }.formtabs .panel:first-child { display: block; }.formtabs input[name="tabs"]:checked ~ .panels .panel { display: none; }.formtabs input[name="tabs"]:nth-of-type(1):checked ~ .panels .panel:nth-child(1),.formtabs input[name="tabs"]:nth-of-type(2):checked ~ .panels .panel:nth-child(2),.formtabs input[name="tabs"]:nth-of-type(3):checked ~ .panels .panel:nth-child(3) { display: block; }</style><div class="formtabs"> <input id="one" name="tabs" type="radio" checked> <input id="two" name="tabs" type="radio"> <input id="three" name="tabs" type="radio"> <div class="panels"> <form method="post" action="" class="form"> <!-- <input type="hidden" name=""> --> <div class="panel">11</div> <div class="panel">22</div> <div class="panel">33</div> </form> </div> </div>
:nth-of-type(1)
:nth-of-type(1)