HTML,CSS - 页脚重叠页面中的内容

时间:2017-09-29 06:55:45

标签: javascript html css

我目前在主页上的页脚有问题。我有一个幻灯片,我尝试从w3school复制粘贴垂直表格代码以检查我的页脚。

我遇到我的页脚在页面底部不是静态的,尽管我已经将位置更改为相对位置。

P.s - 我甚至试过其他类似帖子的解决方案,似乎没有什么对我有用。

真的需要帮助。



body {
  background-color: #d62929;
  font-family: Verdana, sans-serif;
  margin: 0;
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: whitesmoke;
  font-weight: bold;
  font-size: 18px;
}

li {
  float: left;
}

li a,
.dropbtn {
  display: inline-block;
  color: black;
  text-align: center;
  padding: 22px 30px;
  text-decoration: none;
}

li a:hover,
.dropdown:hover .dropbtn {
  background-color: #c12525;
  color: white;
}

li.dropdown {
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: whitesmoke;
  min-width: 250px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.dropdown-content a {
  color: black;
  padding: 20px 20px;
  text-decoration: none;
  display: block;
  text-align: left;
  font-size: 15px;
}

.dropdown-content a:hover {
  background-color: #c12525;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.active {
  background-color: #d62929;
  color: white;
  font-weight: bold;
  font-size: 18px;
}

@media screen and (max-width: 600px) {
  ul li,
  ul li {
    float: none;
  }
}

* {
  box-sizing: border-box;
}

.mySlides {
  display: none;
}


/* Slideshow container */

.slideshow-container {
  max-width: 950px;
  position: relative;
  margin: auto;
}


/* Caption text */

.text {
  color: black;
  font-size: 15px;
  padding: 8px 12px;
  position: absolute;
  bottom: 8px;
  width: 100%;
  text-align: center;
}


/* Number text (1/3 etc) */

.numbertext {
  color: black;
  font-weight: bold;
  font-size: 12px;
  padding: 8px 12px;
  position: absolute;
  top: 0;
}


/* The dots/bullets/indicators */

.dot {
  height: 13px;
  width: 13px;
  margin: 0 2px;
  background-color: #bbb;
  border-radius: 50%;
  display: inline-block;
  transition: background-color 0.6s ease;
}

.active2 {
  background-color: #717171;
}


/* Fading animation */

.fade {
  -webkit-animation-name: fade;
  -webkit-animation-duration: 1.5s;
  animation-name: fade;
  animation-duration: 1.5s;
}

@-webkit-keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}

@keyframes fade {
  from {
    opacity: .4
  }
  to {
    opacity: 1
  }
}


/* On smaller screens, decrease text size */

@media only screen and (max-width: 300px) {
  .text {
    font-size: 11px
  }
  footer {
    -webkit-order: 3;
    order: 3;
  }
}

footer {
  background: #aaa;
  color: white;
  position: static;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1rem;
  text-align: center;
}

.footp {
  margin: 0;
  padding: 0;
  margin-left: 20px;
  display: inline-block;
  line-height: 30px;
  vertical-align: top;
}


/* Style the tab */

div.tab {
  float: left;
  border: 1px solid #ccc;
  background-color: #f1f1f1;
  width: 30%;
  height: 300px;
}


/* Style the buttons inside the tab */

div.tab button {
  display: block;
  background-color: inherit;
  color: black;
  padding: 22px 16px;
  width: 100%;
  border: none;
  outline: none;
  text-align: left;
  cursor: pointer;
  transition: 0.3s;
  font-size: 17px;
}


/* Change background color of buttons on hover */

div.tab button:hover {
  background-color: #ddd;
}


/* Create an active/current "tab button" class */

div.tab button.active {
  background-color: #ccc;
}


/* Style the tab content */

.tabcontent {
  float: left;
  padding: 0px 12px;
  border: 1px solid #ccc;
  width: 70%;
  border-left: none;
  height: 300px;
}

<body>
  <div class="flex-container">
    <ul>
      <li><a class="active" href="">A</a></li>
      <li class="dropdown">
        <a href="javascript:void(0)" class="dropbtn">B</a>
        <div class="dropdown-content">
          <a href="">D</a>
          <a href="">E</a>
        </div>
      </li>
      <li><a href="">Contact</a>C</li>
    </ul>

    <br /><br />
    <div class="slideshow-container">

      <div class="mySlides fade">
        <div class="numbertext">1 / 7</div>
        <img src="image1.jpg" style="width:100%">
        <div class="text"></div>
      </div>

      <div class="mySlides fade">
        <div class="numbertext">2 / 7</div>
        <img src="image2.jpg" style="width:100%">
        <div class="text"></div>
      </div>

      <div class="mySlides fade">
        <div class="numbertext">3 / 7</div>
        <img src="image3.jpg" style="width:100%">
        <div class="text"></div>
      </div>

      <div class="mySlides fade">
        <div class="numbertext">4 / 7</div>
        <img src="image4.jpg" style="width:100%">
        <div class="text"></div>
      </div>

      <div class="mySlides fade">
        <div class="numbertext">5 / 7</div>
        <img src="image5.jpg" style="width:100%">
        <div class="text"></div>
      </div>

      <div class="mySlides fade">
        <div class="numbertext">6 / 7</div>
        <img src="image6.jpg" style="width:100%">
        <div class="text"></div>
      </div>

      <div class="mySlides fade">
        <div class="numbertext">7 / 7</div>
        <img src="image7.jpg" style="width:100%">
        <div class="text"></div>
      </div>
    </div>
    <br>

    <div style="text-align:center">
      <span class="dot" onclick="currentSlide(1)"></span>
      <span class="dot" onclick="currentSlide(2)"></span>
      <span class="dot" onclick="currentSlide(3)"></span>
      <span class="dot" onclick="currentSlide(4)"></span>
      <span class="dot" onclick="currentSlide(5)"></span>
      <span class="dot" onclick="currentSlide(6)"></span>
      <span class="dot" onclick="currentSlide(7)"></span>
    </div>

    <div class="tab">
      <button class="tablinks" onclick="openCity(event, 'London')" id="defaultOpen">London</button>
      <button class="tablinks" onclick="openCity(event, 'Paris')">Paris</button>
      <button class="tablinks" onclick="openCity(event, 'Tokyo')">Tokyo</button>
    </div>

    <div id="London" class="tabcontent">
      <h3>London</h3>
      <p>London is the capital city of England.</p>
    </div>

    <div id="Paris" class="tabcontent">
      <h3>Paris</h3>
      <p>Paris is the capital of France.</p>
    </div>

    <div id="Tokyo" class="tabcontent">
      <h3>Tokyo</h3>
      <p>Tokyo is the capital of Japan.</p>
    </div>

    <div>
      <footer>
        <p class="footp">&copy; 2017 . All rights reserved.</p>
        <p class="footp">|</p>
        <p class="footp"> Internal Use Only</p>
        <p class="footp">|</p>
        <p class="footp">Maintained By : </p>
      </footer>
    </div>
  </div>
</body>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:3)

在页脚之前有浮动div,你需要清除浮动效果并从页脚移除高度。默认位置的html内容:静态和静态位置顶部/右侧/底部/左侧定位不适用。

请更改此CSS样式。

footer {
    background: #aaa;
    color: #fff;
    text-align: center;
    clear: both; /* clearing floating affects from both left,right sides */
}

答案 1 :(得分:0)

您是否尝试在java中使用普通表类型?我觉得这很容易。

  <table>
  <tr>
        <td>
          add your code here
        </td>
  </tr>

 </table>