我想在我的hompage上创建一个小的下拉div。当点击一个按钮时,它会在点击它时显示下拉列表

时间:2021-12-30 20:43:14

I want to create a button that when clicked will show will show a little drop down menu on the side like this one here: http://postimg.org/image/re433fr2l/ this the code that i already have:

我想创建一个按钮,点击后会显示一个像下面这样的一个下拉菜单:http://postimg.org/image/re433fr2l/这个我已有的代码:

HTML

<body background="http://s14.postimg.org/rpo7dneox/NEWW.png/>
    <div class="div3">
         <UL>
       <LI><a href="color.html">HOME</a></LI>
       <LI><a href="layout.html">ARTICLES</a></LI>
       <LI><a href="myform.html">CONTACT </a></LI>
         <UL>
    <div>

CSS: ul{ font-family: impact; font-size: 90px; list-style: none; }

CSS:ul {font-family:impact; font-size:90px; list-style:none; }

.div3{
    float:right;
    width:300px;
    height:300px;
    border:0px solid cyan;
    margin-top: 50px;
    margin-left: 570px;
}

a { 
    color:green;
}

a:hover{
    color:orange; 
    font-size: 100px;
}

1 个解决方案

#1


You are looking for something like this: http://jsfiddle.net/Ltbodn0j/

你正在寻找这样的东西:http://jsfiddle.net/Ltbodn0j/

$(document).ready(function () {
    $(".menu-toggle > button").click(function() {
        $(".menu-toggle > ul").toggle();
    });
});

Which translates to: if a user clicks the button -> toggle (show/hide) the list.

转换为:如果用户单击按钮 - >切换(显示/隐藏)列表。

However, this is a very basic question so I advise you to follow an introductory tutorial on JavaScript and jQuery rather than simply copy-pasting my answer.

但是,这是一个非常基本的问题,因此我建议您遵循JavaScript和jQuery的入门教程,而不是简单地复制粘贴我的答案。

#1


You are looking for something like this: http://jsfiddle.net/Ltbodn0j/

你正在寻找这样的东西:http://jsfiddle.net/Ltbodn0j/

$(document).ready(function () {
    $(".menu-toggle > button").click(function() {
        $(".menu-toggle > ul").toggle();
    });
});

Which translates to: if a user clicks the button -> toggle (show/hide) the list.

转换为:如果用户单击按钮 - >切换(显示/隐藏)列表。

However, this is a very basic question so I advise you to follow an introductory tutorial on JavaScript and jQuery rather than simply copy-pasting my answer.

但是,这是一个非常基本的问题,因此我建议您遵循JavaScript和jQuery的入门教程,而不是简单地复制粘贴我的答案。