单击按钮时,输入框切换

问题描述 投票:-1回答:1

当我按下搜索按钮(红色方块)时,如何使输入框(蓝色方块)可见/隐藏Link Image

我试图在CSS中进行转换,我也在javascript中测试过,但是JS ...我关闭(idk js是如何工作的)

现在,我尝试了!

$("#Hide").click(function() {
    $(".buttontoggle").hide("blind");
});
* {
  padding: 0;
  margin: 0;
}

html {
  background-image: url(../Images/background.jp);
  background-repeat: no-repeat;
  background-attachment: fixed;
  font-family: 15px/1.5 'Arial', 'Helvetica', 'sans-serif', 'Montserrat';
}

body {
  height: 2000px;
}

.container {
  border: 2px solid;
  width: 1164px;
  height: 1600px;
  margin: 177px 350px 0px 371px;
  overflow: hidden;
  background-color: #0A081E;
}


/* #region Header */

header {
  background: #0A081E;
  color: #ffffff;
  padding-top: 0px;
  min-height: 55px;
  border-bottom: #e8491d 3px solid;
  position: fixed;
  min-width: 1920px;
  top: 0px;
  z-index: 1;
}

header a {
  color: #ffffff;
  text-decoration: none;
  text-transform: uppercase;
  font-size: 14px;
}

header li {
  float: left;
  display: inline;
  padding: 11px 45px 0 15px;
  margin-left: -30px;
}

#logo {
  width: 360px;
  height: 55px;
  background-size: cover;
  background-repeat: no-repeat;
}

header #logo {
  float: left;
  background-image: url(../Images/logo.png);
  background-size: 280px 40px;
  margin: 7px 0px -7px 40px;
}

.nav-container {
  width: 1280px;
  margin: auto;
  overflow: hidden;
  right: 10px;
}

header nav {
  float: right;
  margin-top: 10px;
}

header a:hover {
  color: #cccccc;
}

.vl {
  border-left: 2px solid white;
  height: 35px;
  float: left;
  position: absolute;
  left: 76.40%;
  top: 10px;
  opacity: 0.76;
  border-radius: 35%;
}

.LoginButton {
  margin: -11px -3px 0px 20px;
  background-color: #0A081E;
  /* Green */
  border: none;
  color: white;
  padding: 10px 10px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  -webkit-transition-duration: 0.4s;
  /* Safari */
  transition-duration: 0.4s;
  cursor: pointer;
  border-radius: 15%;
  font-weight: bold;
}

.LoginButton:hover {
  background-color: #ffffff;
}

.LoginButton:hover a {
  color: black;
  font-weight: bold;
}

.fa-search {
  margin: -7px 0px 0px 0px;
  background-color: #0A081E;
  /* Green */
  border: none;
  color: white;
  text-align: center;
  padding: 5px 5px;
  text-decoration: none;
  display: inline-block;
  font-size: 15px;
  transition-duration: 0.4s;
  cursor: pointer;
  border-radius: 15%;
  position: relative;
}

.fa-search:hover {
  background-color: #ffffff;
  color: black;
}

.searchbox {
  border: 1px solid red;
  box-sizing: border-box;
  border-radius: 4px;
  margin: -5px -10px 0px -5px;
  padding: 0px 6px 6px 6px;
  visibility: visible;
  text-align: center;
}
<body>
  <header>
    <div class="nav-container">
      <a href="Default.aspx" id="Logo">
      </a>
      <nav>
        <ul>
          <li class="buttontoggle"> <a href="#">New Release</a> </li>
          <li class="buttontoggle"> <a href="#">Others</a> </li>
          <li class="buttontoggle"> <a href="#">Top</a> </li>
          <li class="buttontoggle"> <a href="#">Contact</a> </li>
          <li>
            <form>
              <input type="text" class="searchbox" name="search" />
            </form>
          </li>
          <li><i class="fa fa-search" id="Hide"></i></li>

          <div class="vl"></div>
          <li> <span class="LoginButton">
                                       <a href="#" >Login</a>
                                    </span>
          </li>
        </ul>
      </nav>
    </div>
  </header>

  <body>

这是我写的最后一个代码...我也试过用css中的webkit过渡,但它不是我想要的Hover BugWithout hover

我的英语非常糟糕,我认为你不明白我的意思

编辑:您可以尝试直播编辑:.. WebPage

javascript html css transitions
1个回答
1
投票

您应该使用切换而不是隐藏,如下所示

$("#Hide").click(function() {
    $(".searchbox").toggle("blind");
});

当然,你已经确定你在你的HTML中包含了jquery。如果没有,只需将其添加到您的html中即可快速测试您的工作:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

同样的字体 - 令人敬畏

<link href="//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css" rel="stylesheet">
© www.soinside.com 2019 - 2024. All rights reserved.