1

我的幻灯片切换不会显示?我已经做到了,所以当你点击 id 时,会出现文本 id。但不知何故它没有连接?好像text id一直在后面,但是我看不下去了?我也想知道如何让它切换到侧面而不是向下?

有人可以帮忙吗?谢谢

$(document).ready(function() {
  $("#Introduction_click").click(function() {
    $("#Introduction_text").slideToggle("slow")
  })
  
  $("#Toggle2_click").click(function() {
    $("#Toggle2_text").slideToggle("slow")
  })
})
.container {
  padding-left: 00px;
  padding-bottom: 55px;
  box-sizing: border-box;
  cursor: pointer;
  background-color: yellow;
}

.title {
  padding-top: 20px;
  font-family: 'RimaRegular';
  font-weight: 800;
  font-style: normal;
  font-size: 18px;
  line-height: 21.5px;
  background-color: blue;
  border-radius: 25px;
  /*  margin-top:10px;*/
  margin-top: 5px;
  margin-right: 5vw;
  height: 100%;
}

h1 {
  font-family: 'Till-Normal';
  font-weight: 900;
  font-style: normal;
  font-size: 30px;
  font-weight: normal;
  -webkit-font-smoothing: antialiased;
  text-align: center;
}

.paragraph {
  margin-right: 10vw;
}

p {
  /*  margin-left:30px;*/
  margin-left: 20px;
  /* text-indent: 30px; */
  font-family: 'RimaRegular';
  font-weight: 400;
  font-style: normal;
  font-size: 15px;
  line-height: 20.5px;
  -webkit-font-smoothing: antialiased;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  /*  text-align: justify;*/
  text-justify: inter-word;
  overflow-wrap: break-word;
}

#Introduction_click {
  height: 100%;
  margin-left: 0vw;
  margin-top: 10px;
}

#Introduction_text {
  display: none;
  margin-top: 0px;
}

#Toggle2_click {
  height: 100%;
  margin-left: 0vw;
  margin-top: 10px;
}

#Toggle2_text {
  display: none;
  margin-top: 0px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">


  <div id="Introduction_click">
    <div class="title">
      <h1>Introduction</h1>
      <br>
      <div id="Introduction_text">
        <div class="paragraph">
          <br>
          <p>hallo text here</p>
        </div>
      </div>
    </div>

    <div id="Toggle2_click">
      <div class="title">
        <h1>Toggle 2</h1>
        <br>
        <div id="Toggle2_text">
          <div class="paragraph">
            <br>
            <p>hallo text here</p>
          </div>
        </div>
      </div>

4

2 回答 2

0

我发现了这个问题。这是因为#introduction_click没有关闭并包含整个容器。所以我</div>之前加了#Toggle2_click。现在可以了。

$(document).ready(function() {
  $("#Introduction_click").click(function() {
    $("#Introduction_text").slideToggle("slow");
  });
});

$(document).ready(function() {
  $("#Toggle2_click").click(function() {
    $("#Toggle2_text").slideToggle("slow");
  });
});
.container {
  padding-left: 00px;
  padding-bottom: 55px;
  box-sizing: border-box;
  cursor: pointer;
  background-color: yellow;
}

.title {
  padding-top: 20px;
  font-family: 'RimaRegular';
  font-weight: 800;
  font-style: normal;
  font-size: 18px;
  line-height: 21.5px;
  background-color: blue;
  border-radius: 25px;
  /*  margin-top:10px;*/
  margin-top: 5px;
  margin-right: 5vw;
  height: 100%;
}

h1 {
  font-family: 'Till-Normal';
  font-weight: 900;
  font-style: normal;
  font-size: 30px;
  font-weight: normal;
  -webkit-font-smoothing: antialiased;
  text-align: center;
}

.paragraph {
  margin-right: 10vw;
}

p {
  /*  margin-left:30px;*/
  margin-left: 20px;
  /* text-indent: 30px; */
  font-family: 'RimaRegular';
  font-weight: 400;
  font-style: normal;
  font-size: 15px;
  line-height: 20.5px;
  -webkit-font-smoothing: antialiased;
  hyphens: auto;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  /*  text-align: justify;*/
  text-justify: inter-word;
  overflow-wrap: break-word;
}

#Introduction_click {
  margin-left: 0vw;
  margin-top: 10px;
}

#Introduction_text {
  display: none;
  margin-top: 0px;
}

#Toggle2_click {
  height: 100%;
  margin-left: 0vw;
  margin-top: 10px;
}

#Toggle2_text {
  display: none;
  margin-top: 0px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container">


  <div id="Introduction_click">
    <div class="title">
      <h1>Introduction</h1>
      <br>
      <div id="Introduction_text">
        <div class="paragraph">
          <br>
          <p>hallo text here</p>
        </div>
      </div>
    </div>
    </div>

    <div id="Toggle2_click">
      <div class="title">
        <h1>Toggle 2</h1>
        <br>
        <div id="Toggle2_text">
          <div class="paragraph">
            <br>
            <p>hallo text here</p>
          </div>
        </div>
      </div>

于 2021-04-08T13:43:01.540 回答
0

我认为您忘记在脚本单击事件之前添加 Jquery 库添加此内容

 <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
于 2021-04-08T13:48:29.780 回答