HTML 水平制表符。单击显示的选项卡时如何制作

标签 html css

我正在练习一个新网站。这个网站有一个单杠。 (文本是我要标记的地方)。

我的问题是。单击选项卡时如何制作它。它将转到该选项卡并显示写入该选项卡的任何内容。

我一直尝试的一切都行不通。我需要上课吗?

感谢所有帮助过我的人!

我的代码:

<!DOCTYPE html>

<html lang="en">

<head> </head>

<title>Title - Title</title>

<body>

<body style="background-color:pink;">

<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}

li {
float: left;
}

li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

li a:hover {
background-color: #111;
}
</style>

<ul>
<li><a class="active" href="#text">text</a></li>
<li><a href="#text">text</a></li>
<li><a href="#text">text</a></li>
<li><a href="#text">text</a></li>
<li><a href="#text">text</a></li>					
<li><a href="#text">text</a></li>					
</ul>

</body>
</html>

最佳答案

$(function(){
	$(document).on('click', '.open-panel', function(e){
  	  $('.panel-item').each(function(){
      	$(this).removeClass('active');
      });
	    var $this = $(this);
      setTimeout(function(){
          var panel = $this.data('panel');
          $('#' + panel).addClass('active');
      }, 500);
  });
});
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}

li {
float: left;
}

li a {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

li a:hover {
background-color: #111;
}

.panel-item {
  position: relative;
  max-height:0;
  transition: max-height ease-in-out .4s;
  -webkit-transition: max-height ease-in-out .4s;
  -moz-transition: max-height ease-in-out .4s;
  -o-transition: max-height ease-in-out .4s;
  -ms-transition: max-height ease-in-out .4s;
  overflow: hidden;
}

.panel-item.active{
  max-height: 400px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<ul>
<li><a href="#text" class="open-panel" data-panel="text">text</a></li>
<li><a href="#text1" class="open-panel" data-panel="text1">text</a></li>
<li><a href="#text2" class="open-panel" data-panel="text2">text</a></li>
<li><a href="#text3" class="open-panel" data-panel="text3">text</a></li>					
<li><a href="#text4" class="open-panel" data-panel="text4">text</a></li>					
</ul>

<div class="panel-container">
  <div id="text" class="panel-item">
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </div>
  <div id="text1" class="panel-item">
      Why do we use it?
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
  </div>
    <div id="text2" class="panel-item">
      Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.

The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham.


  </div>
    <div id="text3" class="panel-item">
      Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
  </div>
      <div id="text4" class="panel-item">
      There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.


  </div>
</div>

关于HTML 水平制表符。单击显示的选项卡时如何制作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46459302/

相关文章:

html - CSS:强制textarea占用所有可用区域

html - 垂直对齐 SVG 单选按钮

css - html中textarea中行的等效div属性

javascript - 在 JavaScript 函数中调用 JQuery 函数

PHP/MySQL 登录不工作

html - float 设计如何实现这种类似表格的结果?

javascript - 带 slider 的 jquery 二十二十插件

jquery - 我如何将这些导航元素居中?

html - 每个列表项后带有外部图标的 Bootstrap 链接列表

css - 为 "pointer"使用自定义光标