选项卡导航栏下方的内容

时间:2017-09-08 05:37:31

标签: html css

我在互联网上发现这个代码很好,但是我想要先输入部分标签然后输入,我尝试了很多次,将标签导航移动到内容下面而没有成功。



section {
  display: none;
  padding: 20px 0 0;
  border-top: 1px solid #ddd;
}

input {
  display: none;
}

input:checked+label {
  color: #ff0000;
}

#tab1:checked~#content1,
#tab2:checked~#content2,
#tab3:checked~#content3,
#tab4:checked~#content4 {
  display: block;
}

<input id="tab1" type="radio" name="tabs" checked>
<label for="tab1">home</label>

<input id="tab2" type="radio" name="tabs">
<label for="tab2">about</label>

<input id="tab3" type="radio" name="tabs">
<label for="tab3">FAQ</label>

<input id="tab4" type="radio" name="tabs">
<label for="tab4">contact</label>

<section id="content1">
  <p>home</p>
</section>

<section id="content2">
  <p>about</p>
</section>

<section id="content3">
  <p>FAQ</p>
</section>

<section id="content4">
  <p>contact</p>
</section>
&#13;
&#13;
&#13;

如何移动内容下方的导航栏

谢谢

4 个答案:

答案 0 :(得分:1)

您可以尝试如下.local wrap section tags,然后您可以使用div更改label的定位,

position:absolute
section {
  display: none;
  padding: 0px 0 0;
  border-bottom: 1px solid #ddd;
}
input {
  display: none;
}
input:checked+label {
  color: #ff0000;
}
#tab1:checked~.wr #content1{
  display:block;
}
#tab2:checked~.wr #content2{
  display:block;
}
#tab3:checked~.wr #content3{
  display:block;
}
#tab4:checked~.wr #content4{
  display:block;
}
.wr{
  position:relative;
  top:0;
  display:block;
}
.tb1{
   position:absolute;
   top:80px;
   display:inline-block;
}
.tb2{
   position:absolute;
   top:80px;
   display:inline-block;
   left:60px;
}
.tb3{
   position:absolute;
   top:80px;
   display:inline-block;
   left:120px;
}
.tb4{
   position:absolute;
   top:80px;
   display:inline-block;
   left:180px;
}

答案 1 :(得分:0)

我已经更改了你的代码。请尝试此代码。

&#13;
&#13;
a:focus {
  outline: none!important; 
}
.content-wrap {
  background:#eee;
  padding:20px;
  margin-bottom:10px;
}
.tabs-bottom > .nav-tabs{
  border-bottom: 0;
}
.tabs-below > .nav-tabs {
  border-bottom: 0;
}
.tab-content > .tab-pane,
.pill-content > .pill-pane {
  display: none;
}
.tab-content > .active,
.pill-content > .active {
  display: block;
}
.tabs-bottom > .nav-tabs {
  border-top: 1px solid #ddd;
}
.tabs-bottom > .nav-tabs > li {
  margin-top: -1px;
  margin-bottom: 0;
}
.tabs-bottom > .nav-tabs > li > a { 
  border-radius: 0 0 4px 4px;
}

.tabs-below > .nav-tabs > li > a:hover,
.tabs-below > .nav-tabs > li > a:focus {
  border-top-color: #ddd;
  border-bottom-color: transparent;
}

.tabs-bottom > .nav-tabs > .active > a,
.tabs-bottom > .nav-tabs > .active > a:hover,
.tabs-bottom > .nav-tabs > .active > a:focus {
  border-color: transparent #ddd #ddd #ddd;
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
<div class="container">
  <div class="row">
    <div class="col-xs-12">		 
      <!-- tabs -->
      <div class="tabbable tabs-bottom">
        <div class="tab-content">
          <div class="tab-pane active" id="home">                
            <div class="content-wrap">
              <h2>Home Tab</h2>
              <p>test</p>                 
            </div>
          </div> 
          <div class="tab-pane" id="about"> 
            <div class="content-wrap">
              <h2>About Tab</h2>
              <p>test</p>                 
            </div>
          </div>

          <div class="tab-pane" id="services"> 
            <div class="content-wrap">
              <h2>Services Tab</h2>
              <p>test</p>                 
            </div>
          </div>

          <div class="tab-pane" id="contact"> 
             <div class="content-wrap">
              <h2>Contact Tab</h2>
              <p>test</p>                 
             </div>
          </div>
        </div>
        <!-- tab content -->
        <ul class="nav nav-tabs">
          <li class="active"><a href="#home" data-toggle="tab">Home</a></li>
          <li><a href="#about" data-toggle="tab">About</a></li>
          <li><a href="#services" data-toggle="tab">Services</a></li>
          <li><a href="#contact" data-toggle="tab">Contact</a></li>
        </ul>				
      </div>
      <!-- /tabs -->
    </div>
  </div>
</div>
&#13;
&#13;
&#13;

答案 2 :(得分:0)

将导航栏技术与<div id="home">一起使用。

这很容易。

或者您可以使用javascript使其看起来更精致。

&#13;
&#13;
body {margin:0;}

.navbar {
  overflow: hidden;
  background-color: #fff;
  position: fixed;
  bottom: 0;
  width: 100%;
}

.navbar a {
  float: left;
  display: block;
  color: #000;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
  font-size: 17px;
}

.main {
  padding: 16px;
  margin-bottom: 30px;
  height: 1500px; /* Used to enable scrolling */
}
&#13;
<!DOCTYPE html>
<html>
<head>
</head>
<body>

<div class="navbar">
  <a href="#home">Home</a>
  <a href="#about">About</a>
</div>

<div id="home"class="main">
  <h1>Home</h1>
</div>

<div id="about"class="main">
  <h1>About</h1>
</div>

</body>
</html>
&#13;
&#13;
&#13;

答案 3 :(得分:0)

你只需要使用CSS display flex来重新排序内容:

https://codepen.io/seltix/pen/XaLVaY

<dix id="blockcontainer" >

  <input id="tab1" type="radio" name="tabs" checked>
  <label for="tab1">home</label>

  <input id="tab2" type="radio" name="tabs">
  <label for="tab2">about</label>

  <input id="tab3" type="radio" name="tabs">
  <label for="tab3">FAQ</label>

  <input id="tab4" type="radio" name="tabs">
  <label for="tab4">contact</label>

  <div class="divider"></div>

  <section id="content1">
    <p>home</p>
  </section>

  <section id="content2">
    <p>about</p>
  </section>

  <section id="content3">
    <p>FAQ</p>
  </section>

  <section id="content4">
    <p>contact</p>
  </section>

  </div>

CSS:

section {
  display: none;
  padding: 20px;
  border-bottom: 1px solid #AAA;
  background :#EEE;
}

div.divider {
  width:100%;
}

input {
  display: none;
}

label {
  padding: 10px;
}

input:checked + label {
  color: #ff0000;
}

#tab1:checked ~ #content1,
#tab2:checked ~ #content2,
#tab3:checked ~ #content3,
#tab4:checked ~ #content4 {
  display: block;
}


#blockcontainer {
  -ms-box-orient: horizontal;
  display: -webkit-box;
  display: -moz-box;
  display: -ms-flexbox;
  display: -moz-flex;
  display: -webkit-flex;
  display: flex;

  -webkit-flex-flow: row wrap;
  flex-flow: row wrap;
}

section {
    -ms-flex-order: 1;
    order: 1;
}

div.divider {
    -ms-flex-order: 6;
    order: 6;
}

input, label {
    -ms-flex-order: 12;
    order: 12;
}