gpt4 book ai didi

javascript - HTML, CSS - 页脚与页面内容重叠

转载 作者:太空宇宙 更新时间:2023-11-03 22:35:59 25 4
gpt4 key购买 nike

我目前在主页页脚上遇到问题。我有一个幻灯片,我尝试从 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>

最佳答案

footer前有 float div,需要清除 float 效果,去除footer高度。 html内容默认position:static和静态位置top/right/bottom/left定位不适用。

请更改此 css 样式。

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

关于javascript - HTML, CSS - 页脚与页面内容重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46483347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com