:checked
. Here's what it looks like: <style> /* hide radio element */ .myradio { display:none; height:0px; visibility:hidden; } .mybox { width:100px; height:50px; background-color: #eeeeee; display:none; padding:5px; } /* change tab to bold */ .myradio:checked + label { font-weight: bold; } /* show content */ #radio1:checked ~ .box1, #radio2:checked ~ .box2 { display:block; } </style> <input name="myradio" type=radio id="radio1" class="myradio" checked> <label for="radio1">Tab 1</label> | <input name="myradio" type=radio id="radio2" class="myradio"> <label for="radio2">Tab 2</label> <div class="mybox box1">Box 1</div> <div class="mybox box2">Box 2</div>
:checked
and related selectors, adjacent (+) and general (~), you can selectively highlight in bold type the name and display the associated content of the tab.:checked
pseudo-class, and Yahoo! Mail cuts a selector (~) and renames id and classes when rendering, making the for attribute useless. <label><input type=radio name="tab" id="tab1" checked> <span><div class="title1">Tab 1</div> <!-- NESTED TAB 2 --> <label><input type=radio name="tab" id="tab2"> <span><div class="title2">Tab 2</div> <!-- NESTED TAB 3 --> <label><input type=radio name="tab" id="tab3"> <span><div class="title3">Tab 3</div> <div class="content3"> Tab 3 Content </div></span> </label> <!-- /NESTED TAB 3 --> <div class="content2"> Tab 2 Content </div></span> </label> <!-- /NESTED TAB 2 --> <div class="content1"> Tab 1 Content </div></span> </label>
:checked
displays the div container if the selector is the same: <style> .tabcheck:checked + div { display:block !important; max-height: none !important; height: auto !important; } </style> <input type=radio class="tabcheck" style="display:none !important;" checked> <div style="height:0px;max-height:0px;overflow:hidden;"> TABBED CONTENT </div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Interactive Tabs for Email</title> <style> * { font-family: Helvetica, sans-serif; margin:0; padding:0; } body { -webkit-text-size-adjust:100%; } .tab, .tabcheck { display: none; } .tabcheck { height:0px; visibility:hidden; } .title1,.title2,.title3 { background-color:#ffffff; float: left; padding:15px 20px 15px 20px; border: 1px solid #888888; border-bottom: 0px; cursor: pointer; border-radius: 5px 5px 0px 0px; } .tabcheck:checked + #container { height: 363px !important; max-height: 363px !important; } .tabcheck:checked + div, #tab2:checked + span .content2, #tab3:checked + span .content3 { display:block !important; max-height: none !important; height: auto !important; } #tab1:checked + span .title1, #tab2:checked + span .title2, #tab3:checked + span .title3 { background-color:#bbbbbb; } /* GMAIL [lang] fix */ .gfix{} * [lang=x-title1], * [lang=x-title2], * [lang=x-title3]{ background-color:#ffffff; float: left; padding:15px 20px 15px 20px; border: 1px solid #888888; border-bottom: 0px; cursor: pointer; border-radius: 5px 5px 0px 0px; } * [lang=x-tabcheck]:checked + [lang=x-container] { height: 363px !important; max-height: 363px !important; } * [lang=x-tabcheck]:checked + div, * [lang=x-tab2]:checked + span [lang=x-content2], * [lang=x-tab3]:checked + span [lang=x-content3] { display:block !important; max-height: none !important; height: auto !important; } * [lang=x-tab1]:checked + span [lang=x-title1], * [lang=x-tab2]:checked + span [lang=x-title2], * [lang=x-tab3]:checked + span [lang=x-title3]{ background-color:#bbbbbb; } </style> </head> <body bgcolor="#ffcc00"> <table width="100%" height="100%"> <tr> <td></td> <td bgcolor="#ffcc00"> <div class="content"> <table> <tr> <td> <form> <!--[if !mso]><!-- --> <input type=radio class="tabcheck" lang="x-tabcheck" style="display:none !important;" checked> <!--<![endif]--> <div id="container" lang="x-container" style="width:500px;height:310px;max-height:310px;overflow:hidden;"> <!--[if !mso]><!-- --> <input type=radio class="tabcheck" lang="x-tabcheck" style="display:none !important;" checked> <div style="height:0px;max-height:0px;overflow:hidden;"> <label><input type=radio name="tab" class="tab" lang="x-tab1" id="tab1" style="display:none !important;" checked><span><div class="title1" lang="x-title1" >Tab 1</div> <!-- NESTED TAB 2 --> <label><input type=radio name="tab" class="tab" lang="x-tab2" id="tab2" style="display:none !important;"><span><div class="title2" lang="x-title2">Tab 2</div> <!-- NESTED TAB 3 --> <label><input type=radio name="tab" class="tab" lang="x-tab3" id="tab3" style="display:none !important;"><span><div class="title3" lang="x-title3">Tab 3</div> <div class="content3" lang="x-content3" style="height:0px;max-height:0px;overflow:hidden;clear:left;"> <table cellpadding="0" cellspacing="0"> <tr> <td colspan="2" height="150" width="500" bgcolor="#bbbbbb" valign=center align=center style="font-size:50px;color:#555555;"><b>Tab 3</b></td> </tr><tr> <td width="250" height="170" valign="top" style="background: #777777; font-family: Helvetica; font-size: 14px; line-height: 100%; color: #ffffff;"><div style="padding:20px;"> <H2>Title 3A</H2> <p>The quick, brown fox jumps over a lazy dog. <a href="#" style="color: #BDD4FC;">View Deal</a> </p> </div></td> <td width="250" height="170" valign="top" style="background: #555555; font-family: Helvetica; font-size: 14px; line-height: 100%; color: #ffffff;"><div style="padding:20px;"> <h2>Title 3B</h2> <p>The quick, brown fox jumps over a lazy dog. <a href="#" style="color: #BDD4FC;">View Deal</a> </p> </div></td> </tr> </table> </div></span> </label> <!-- END NESTED TAB 3 --> <div class="content2" lang="x-content2" style="height:0px;max-height:0px;overflow:hidden;clear:left;"> <table cellpadding="0" cellspacing="0"> <tr> <td colspan="2" height="150" width="500" bgcolor="#bbbbbb" valign=center align=center style="font-size:50px;color:#555555;"><b>Tab 2</b></td> </tr> <tr> <td width="250" height="170" valign="top" style="background: #777777; font-family: Helvetica; font-size: 14px; line-height: 100%; color: #ffffff;"><div style="padding:20px;"> <H2>Title 2A</H2> <p>The quick, brown fox jumps over a lazy dog. <a href="#" style="color: #BDD4FC;">View Deal</a> </p> </div></td> <td width="250" height="170" valign="top" style="background: #555555; font-family: Helvetica; font-size: 14px; line-height: 100%; color: #ffffff;"><div style="padding:20px;"> <h2>Title 2B</h2> <p>The quick, brown fox jumps over a lazy dog. <a href="#" style="color: #BDD4FC;">View Deal</a> </p> </div></td> </tr> </table> </div> </span> </label> <!-- END NESTED TAB 2 --> <!-- TAB 1 Content originally here --> </span></label> </div> <!--<![endif]--> <!-- TAB 1 Content moved outside nested labels for fallback for non supported clients: Outlook.com/Outlook --> <table cellpadding="0" cellspacing="0"> <tr> <td colspan="2" height="150" width="500" bgcolor="#bbbbbb" valign=center align=center style="font-size:50px;color:#555555;"><b>Tab 1</b></td> </tr> <tr> <td width="250" height="170" valign="top" style="background: #777777; font-family: Helvetica; font-size: 14px; line-height: 100%; color: #ffffff;"><div style="padding:20px;"> <H2>Title 1A</H2> <p>The quick, brown fox jumps over a lazy dog. <a href="#" style="color: #BDD4FC;">View Deal</a> </p> </div></td> <td width="250" height="170" valign="top" style="background: #555555; font-family: Helvetica; font-size: 14px; line-height: 100%; color: #ffffff;"><div style="padding:20px;"> <h2>Title 1B</h2> <p>The quick, brown fox jumps over a lazy dog. <a href="#" style="color: #BDD4FC;">View Deal</a> </p> </div></td> </tr> </table> </div> </form> </td> </tr> </table> </div> </td> <td></td> </tr> </table> </body> </html>
Source: https://habr.com/ru/post/265409/
All Articles