简体   繁体   English

普通代码在CSS标签内无法正常工作

[英]Normal code works abnormally inside CSS tab

I was making guest page code for my blog : 我正在为博客创建访客页面代码:

 <div class="guest_tistory_write">
        <s_guest_input_form>
            <div class="g_write">
                <s_guest_member>
                    <s_guest_form>
                    <div class="write_input_info">
                        <input type="text" name="[##_guest_input_name_##]" value="[##_guest_name_##]" placeholder="이름" />
                        <input type="text" name="[##_guest_input_password_##]" value="[##_guest_password_##]" maxlength="8" placeholder="비밀번호" />
                        <input type="text" name="[##_guest_input_homepage_##]" value="[##_guest_homepage_##]" placeholder="홈페이지" />
                    </div>
                    </s_guest_form>
                </s_guest_member>
                <div class="write_input_cont">
                <textarea name="[##_guest_textarea_body_##]" cols="50" rows="6"></textarea>
                <input type="submit" value="올리기" onclick="[##_guest_onclick_submit_##]" />
                </div>
            </div>
        </s_guest_input_form>
   </div>

It work normally : http://jsfiddle.net/o3omng/3bzgb/ (s_something tag is substitution tag.) 它可以正常工作: http : //jsfiddle.net/o3omng/3bzgb/ (s_something标签是替代标签。)

But if this code goes into tabs which made with CSS, Then It makes problem. 但是,如果此代码进入使用CSS制作的标签中,则会出现问题。

<div id="guest_tabs">
        <!-- 라디오 -->
        <input type="radio" id="tab1" name="tab" checked="checked" />
        <input type="radio" id="tab2" name="tab" />
        <!-- 라벨 -->
        <label for="tab1">소셜 방명록</label>
        <label for="tab2">티스토리 방명록</label>
        <!-- 각 탭 내용 -->
        <div class="guest_tab1">
            <!-- 소셜 방명록 -->
            <p>여기에 소셜 방명록 코드를 붙여넣어 주세요.</p>
        </div>
        <div class="guest_tab2">
            <!-- 티스토리 방명록 -->
            <div class="guest_tistory">

                <!-- The code that I show you first. -->

                <div class="guest_tistory_list">    
                </div>
            </div>
        </div>
    </div>

Like this : http://jsfiddle.net/o3omng/hqsX9/ 像这样: http : //jsfiddle.net/o3omng/hqsX9/

The code must show me five inputs like first code, but second code shows just two inputs. 该代码必须向我显示五个输入,例如第一个代码,但是第二个代码仅显示两个输入。

Your second example hides every input element, because you told the browser to do that: 第二个示例隐藏了每个输入元素,因为您告诉浏览器要这样做:

#guest_tabs input:nth-of-type(1),
#guest_tabs input:nth-of-type(1) ~ div:nth-of-type(1),
#guest_tabs input:nth-of-type(2),
#guest_tabs input:nth-of-type(2) ~ div:nth-of-type(2) {
    display : none ;
}

You tell him here to hide the radio buttons, so there is no way to switch the tabs. 您在这里告诉他隐藏单选按钮,因此无法切换选项卡。 Change your CSS to look like this and check if the results matches your expectations: 更改CSS,使其看起来像这样,并检查结果是否符合您的期望:

#guest_tabs input:nth-of-type(1) ~ div:nth-of-type(1),
#guest_tabs input:nth-of-type(2) ~ div:nth-of-type(2) {
    display : none ;
}

New Css work for you: 新的CSS为您工作:

#guest_tabs input:nth-of-type(1) ~ div:nth-of-type(1),
#guest_tabs input:nth-of-type(2) ~ div:nth-of-type(2) { display : none ; } 
#guest_tabs input:nth-of-type(1):checked ~ div:nth-of-type(1),
#guest_tabs input:nth-of-type(2):checked ~ div:nth-of-type(2) { display : block ; }

Check here: http://jsfiddle.net/hqsX9/2/ 在这里检查: http : //jsfiddle.net/hqsX9/2/

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

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