简体   繁体   English

Tabindex不适用于<a>HTML中的</a>字段集<a>内</a>的<a>标记</a>

[英]Tabindex is not working for <a> tag inside fieldset in HTML

I have designed a HTML for with the tabindex set to the fieds. 我设计了一个HTML,其中tabindex设置为fieds。 There are 3 fieldsets. 有3个字段集。 The lower fieldset contains the submit tab with the proper tabindex specified. 下部字段集包含带有指定的正确tabindex的Submit选项卡。 But the tab is not pointing to the tag. 但是选项卡未指向标签。 After fieldset2 it is moving directly to fieldset. 在fieldset2之后,它将直接移至fieldset。

Please find the following code described: 请找到以下描述的代码:

<form action="#" method="post" id="registrationfrm">
            <fieldset id="personalinfo">
            <div class="fieldwrapper">
                <label for="register_firstname">first name</label> 
                <div class="inputwrapper">    
                    <input type="text" tabindex="201" value="" name="register_firstname" id="register_firstname">
                </div>
            </div>
            <div class="fieldwrapper">
                <label for="register_lastname">last name</label>
                <div class="inputwrapper">
                    <input type="text" tabindex="202" name="register_lastname" id="register_lastname">
                </div>
            </div>
            <div class="clear"></div>
            <div class="fieldwrapper">
                <label for="register_industry">industry</label>
                <div class="inputwrapper">

<select  tabindex="203" id="register_industry" name="register$industry">
<option value="">--- please select an industry ---</option>
<option value="adagency">Ad Agency/Public Relations</option>
<option value="other">Other</option>
</select>
</div>
            </div>        
            <div class="fieldwrapper">
                <label for="register_role">role</label>
                <div class="inputwrapper">
                    <select tabindex="204" id="register_role" name="register_role">
<option value="">--- please select a role ---</option>
<option value="Education">Educator/Student</option>
<option value="MktSales">Marketing/Sales</option>
</select>
                </div>
            </div>
            <div class="clear"></div>      
            <div class="fieldwrapper">
                <label for="register_loginname">user name</label>
                <div class="inputwrapper">
                    <input type="text" tabindex="205" name="register_loginname" id="register_loginname">
                </div>
            </div>
            <div class="fieldwrapper">
                <label for="register_emailaddress">email address</label>
                <div class="inputwrapper">
                    <input type="text" tabindex="206" name="register_emailaddress" id="register_emailaddress">
                </div>
            </div>
            <div class="clear"></div>
            <div class="fieldwrapper">
                <label for="register_password">password</label>
                <div class="inputwrapper">
                    <input type="password" value="" tabindex="207" name="register_password" id="register_password">
                </div>
             </div>
            <div class="fieldwrapper">
                <label for="register_passwordconfirm">confirm password</label>
                <div class="inputwrapper">
                    <input type="password" tabindex="208" value="" name="register_passwordconfirm" id="register_passwordconfirm">
                </div>
             </div>
            <div class="clear"></div>
            <div class="fieldwrapper">
                <label for="register_securityquestion">security question</label>
                <div class="inputwrapper">
<select tabindex="209" id="register_securityquestion" name="register$securityquestion">
<option value="">--- please select a question ---</option>
<option value="School">What was the name of your elementary school?</option>
</select>
                </div>
            </div>
            <div class="fieldwrapper">
                <label for="register_securityanswer">security answer</label>
                <div class="inputwrapper">
                    <input type="text" tabindex="210" title="security answer" value="" name="register_securityanswer" id="register_securityanswer">
                </div>
            </div>
            <div class="clear"></div>
        </fieldset>
        <fieldset id="registrationcheckboxes">
            <label for="register_agree"><input type="checkbox" name="register_agree" id="register_agree" class="checkbox {validate:{required:true, messages:{required:'Please review and accept the terms and conditions. If you do not agree to the terms and conditions please use the website as our guest.'}}}" tabindex="211" value="true">&nbsp;I accept Neenah's terms and conditions.</label>
            <div id="register_agreetoterms_exception"></div>
            <label for="register_receiveemails"><input type="checkbox" checked="" name="register_receiveemails" id="register_receiveemails" tabindex="212" value="true">&nbsp;YES, I would like to receive occassional emails about Neenah Paper news and special offers.</label>
        </fieldset>
        <fieldset id="submitsection">
                <a tabindex="213" id="registration_submit" href="#">register account</a>
        </fieldset>
            </form>

CSS 的CSS

#registration .fieldwrapper {
display:inline;
float:left;
padding:0 3px;
}


.inputwrapper {
display:block;
font-size:12px;
padding-bottom:10px;
}


a#registration_submit {
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
background:transparent url(/images/global/CreateNewAccountSubmit.png) no-repeat scroll 0 0;
float:left;
height:21px;
position:relative;
text-indent:-9000px;
width:160px;
}

I would be very glad to have your sugestion. 我很高兴得到你的建议。

Thanks, Nirmal 谢谢,尼尔玛

I tried your code, and it does give focus to the registration link. 我尝试了您的代码,它确实将重点放在了注册链接上。 But the registration link isn't shown due to the text indentation being set to -9000px . 但是由于文本缩进设置为-9000px ,所以未显示注册链接。 In order to do so, you can use the focus pseudo class and remove the text indentation. 为此,您可以使用focus伪类并删除文本缩进。 Eg 例如

a#registration_submit:focus {
    text-indent:0;
}

Keep in mind that this doesn't work in the older IE browsers. 请记住,这在较旧的IE浏览器中不起作用。 To fix that, you might have to resort to JavaScript. 要解决此问题,您可能必须求助于JavaScript。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM