微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在div中选择选中的输入以在另一个div中显示? 没有javascript

如何解决如何在div中选择选中的输入以在另一个div中显示? 没有javascript

我有一个必须在其中做菜单的项目。

当我单击<input />时,它必须显示一个<div>

当我直接在代码中编写列表时,它可以工作,但是问题是当我将列表放入<div>中时,它不起作用。为什么?

以下代码有效:

#home,#vin,#ipp,#rez {
    position: relative;
    margin: 10px;
    cursor: pointer;
}
#acceuilCheck,#vinlandCheck,#ippoCheck,#rezeroCheck,#acceuil,#vinland,#ippo,#rezero {
    display: none;
}
#acceuilCheck:checked~.paragraphe #acceuil {
    display: block;
}
#vinlandCheck:checked~.paragraphe #vinland {
    display: block;
}
#ippoCheck:checked~.paragraphe #ippo {
    display: block;
}
#rezeroCheck:checked~.paragraphe #rezero {
    display: block;
}
<!DOCTYPE HTML>
<html>
<head>
    <link rel="stylesheet" href="Style.css">
    <title>Wiki No Anime</title>

</head>
<body>
        <input id="acceuilCheck" name="list" type="radio">
        <label for="acceuilCheck" id="home">Accueil</label>
        <input id="vinlandCheck" name="list" type="radio">
        <label for="vinlandCheck" id="vin">Vinland</label>
        <input id="ippoCheck" name="list" type="radio">
        <label for="ippoCheck" id="ipp">Ippo</label>
        <input id="rezeroCheck" name="list" type="radio">
        <label for="rezeroCheck" id="rez">Re:Zero</label>
    <div class="paragraphe">
        <div id="acceuil">Presentation anime</div>
        <div id="vinland">Viland c'est du ma nibru ça</div>
        <div id="ippo">Ippo franchement c'est trop magnifique</div>
        <div id="rezero">Re:Zero est un anime de ouffff !!!!</div>
    </div>
</body>
</html>

这是无效的代码

#home,#rezero {
    display: none;
}
.menu #acceuilCheck:checked~.paragraphe #acceuil {
    display: block;
}
.menu #vinlandCheck:checked~.paragraphe #vinland {
    display: block;
}
.menu #ippoCheck:checked~.paragraphe #ippo {
    display: block;
}
.menu #rezeroCheck:checked~.paragraphe #rezero {
    display: block;
}
<!DOCTYPE HTML>
<html>
<head>
    <link rel="stylesheet" href="Style.css">
    <title>Wiki No Anime</title>
</head>
<body>
    <div class="menu">
        <input id="acceuilCheck" name="list" type="radio">
        <label for="acceuilCheck" id="home">Accueil</label>
        <input id="vinlandCheck" name="list" type="radio">
        <label for="vinlandCheck" id="vin">Vinland</label>
        <input id="ippoCheck" name="list" type="radio">
        <label for="ippoCheck" id="ipp">Ippo</label>
        <input id="rezeroCheck" name="list" type="radio">
        <label for="rezeroCheck" id="rez">Re:Zero</label>
    </div>
    <div class="paragraphe">
        <div id="acceuil">Presentation anime</div>
        <div id="vinland">Viland c'est du ma nibru ça</div>
        <div id="ippo">Ippo franchement c'est trop magnifique</div>
        <div id="rezero">Re:Zero est un anime de ouffff !!!!</div>
    </div>
</body>
</html>

没有JavaScript怎么办?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。