Reputation: 33
I am an amateur at coding and I am trying to code for my own website. Why my contents are overlapping? How do I make it in such a way that my content in section-1 is below the content in slide-show-container?
The following picture is the problem I am experiencing at the moment:
The following picture is how I want it to look like:
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
setTimeout(showSlides, 7000); // Change image every 7 seconds
}
* {box-sizing: border-box;}
.mySlides {display: none;}
.slideshow-container img {vertical-align: middle;
height:500px;
}
/* Slideshow container */
.slideshow-container {
max-width: 800px;
height: 10px;
position: relative;
margin: auto;
}
/* The dots/bullets/indicators */
.dot {
height: 7px;
width: 7px;
margin: 2px;
background-color: #000000;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active {
background-color: #C5B358;
}
/* 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}
}
.slideshow-container .btn {
position: absolute;
top: 3150%;
left:50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
background-color: black;
color: white;
font-size: 12px;
padding:6px 12px;
border: none;
cursor: pointer;
text-align: center;
}
.slideshow-container .btn3 {
position: absolute;
top: 4650%;
left:50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
background-color: black;
color: white;
font-size: 12px;
padding:6px 12px;
border: none;
cursor: pointer;
text-align: center;
}
.slideshow-container .btn:hover {
color:#C5B358;
}
.slideshow-container .btn3:hover {
color:#C5B358;
}
.section-1 h1{
font-size: 60px;
font-family: Helvetica;
font-weight: 100;
text-align: center;
}
.section-1 p{
font-family: Helvetica;
text-align: center;
line-height: 1.5;
}
<div class="main">
<div class="slideshow-container">
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/ A.png" style="width:100%">
<button class="btn">SCHEDULE</button>
</div>
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/B.png"style="width:100%">
<button class="btn">BROWSE</button>
</div>
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/C.png"style="width:100%">
<button class="btn3">SHOP</button>
</div>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</div>
<div class="section-1">
<h1>AAA AAA AAAAAAA AAAA<br>AA A AAAAA AAAA</h1>
<p>AAAAAAA AA AAA AAAAAA AAAAA, AAAAA AA AAAAA A AAAAA AA AAA AAAAAAA AAAAAAAAAAA AA AA AAAAAAAAAA AAAAA.<br>AAA AAAAAAAA AAAAAAA AA AAAAAAAAA, AAA AA AAAAA AAA AAA AAAAAA AAA AAAAAAAA AAAAA.<br>AAAAA AAAA AAAA AAAAAA AAAAAAA AAA? <Br>AAAAAAA AA AAA AA AAAA AAAAA AAA AAA AAAA AAAAA. </p>
</div>
</div>
Upvotes: 1
Views: 58
Reputation:
Right! The height of .slideshow-container is a problem here.
<!DOCTYPE html>
<html>
<head>
<title>slide</title>
</head>
<style type="text/css">
* {box-sizing: border-box;}
.mySlides {display: none;}
.slideshow-container img {vertical-align: middle;
height:500px;
}
/* Slideshow container */
.slideshow-container {
max-width: 800px;
/*height: 10px;*/
position: relative;
margin: auto;
}
/* The dots/bullets/indicators */
.dot {
height: 7px;
width: 7px;
margin: 2px;
background-color: #000000;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active {
background-color: #C5B358;
}
/* 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}
}
.slideshow-container .btn {
position: absolute;
top: 3150%;
left:50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
background-color: black;
color: white;
font-size: 12px;
padding:6px 12px;
border: none;
cursor: pointer;
text-align: center;
}
.slideshow-container .btn3 {
position: absolute;
top: 4650%;
left:50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
background-color: black;
color: white;
font-size: 12px;
padding:6px 12px;
border: none;
cursor: pointer;
text-align: center;
}
.slideshow-container .btn:hover {
color:#C5B358;
}
.slideshow-container .btn3:hover {
color:#C5B358;
}
.section-1 h1{
font-size: 60px;
font-family: Helvetica;
font-weight: 100;
text-align: center;
}
.section-1 p{
font-family: Helvetica;
text-align: center;
line-height: 1.5;
}
</style>
<body>
<div class="main">
<div class="slideshow-container">
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/ A.png" style="width:100%">
<button class="btn">SCHEDULE</button>
</div>
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/B.png"style="width:100%">
<button class="btn">BROWSE</button>
</div>
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/C.png"style="width:100%">
<button class="btn3">SHOP</button>
</div>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</div>
<div class="section-1">
<h1>AAA AAA AAAAAAA AAAA<br>AA A AAAAA AAAA</h1>
<p>AAAAAAA AA AAA AAAAAA AAAAA, AAAAA AA AAAAA A AAAAA AA AAA AAAAAAA AAAAAAAAAAA AA AA AAAAAAAAAA AAAAA.<br>AAA AAAAAAAA AAAAAAA AA AAAAAAAAA, AAA AA AAAAA AAA AAA AAAAAA AAA AAAAAAAA AAAAA.<br>AAAAA AAAA AAAA AAAAAA AAAAAAA AAA? <Br>AAAAAAA AA AAA AA AAAA AAAAA AAA AAA AAAA AAAAA. </p>
</div>
</div>
<script type="text/javascript">
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
setTimeout(showSlides, 7000); // Change image every 7 seconds
}
</script>
</body>
</html>
Upvotes: 1
Reputation: 8098
You can set a min-height:
to your slideshow-container
,if you initially want some height
. You content is more than the height
and it is overflow
on the .slideshow-container
. Try this :)
.slideshow-container {
max-width: 800px;
min-height: 10px;// Change to min-height
position: relative;
margin: auto;
}
FULL CODE:
* {box-sizing: border-box;}
.mySlides {display: none;}
.slideshow-container img {vertical-align: middle;
height:500px;
}
/* Slideshow container */
.slideshow-container {
max-width: 800px;
min-height: 10px;/*min-height used*/
position: relative;
margin: auto;
}
/* The dots/bullets/indicators */
.dot {
height: 7px;
width: 7px;
margin: 2px;
background-color: #000000;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active {
background-color: #C5B358;
}
/* 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}
}
.slideshow-container .btn {
position: absolute;
top: 3150%;
left:50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
background-color: black;
color: white;
font-size: 12px;
padding:6px 12px;
border: none;
cursor: pointer;
text-align: center;
}
.slideshow-container .btn3 {
position: absolute;
top: 4650%;
left:50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
background-color: black;
color: white;
font-size: 12px;
padding:6px 12px;
border: none;
cursor: pointer;
text-align: center;
}
.slideshow-container .btn:hover {
color:#C5B358;
}
.slideshow-container .btn3:hover {
color:#C5B358;
}
.section-1 h1{
font-size: 60px;
font-family: Helvetica;
font-weight: 100;
text-align: center;
}
.section-1 p{
font-family: Helvetica;
text-align: center;
line-height: 1.5;
}
<div class="main">
<div class="slideshow-container">
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/ A.png" style="width:100%">
<button class="btn">SCHEDULE</button>
</div>
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/B.png"style="width:100%">
<button class="btn">BROWSE</button>
</div>
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/C.png"style="width:100%">
<button class="btn3">SHOP</button>
</div>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</div>
<div class="section-1">
<h1>AAA AAA AAAAAAA AAAA<br>AA A AAAAA AAAA</h1>
<p>AAAAAAA AA AAA AAAAAA AAAAA, AAAAA AA AAAAA A AAAAA AA AAA AAAAAAA AAAAAAAAAAA AA AA AAAAAAAAAA AAAAA.<br>AAA AAAAAAAA AAAAAAA AA AAAAAAAAA, AAA AA AAAAA AAA AAA AAAAAA AAA AAAAAAAA AAAAA.<br>AAAAA AAAA AAAA AAAAAA AAAAAAA AAA? <Br>AAAAAAA AA AAA AA AAAA AAAAA AAA AAA AAAA AAAAA. </p>
</div>
</div>
Upvotes: 1
Reputation: 72
Here I have commented and changes the line that you have to change the min-height attribute
var slideIndex = 0;
showSlides();
function showSlides() {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
slides[slideIndex-1].style.display = "block";
dots[slideIndex-1].className += " active";
setTimeout(showSlides, 7000); // Change image every 7 seconds
}
* {box-sizing: border-box;}
.mySlides {display: none;}
.slideshow-container img {vertical-align: middle;
height:500px;
}
/* Slideshow container */
.slideshow-container {
max-width: 800px;
min-height: 10px;//changed here
position: relative;
margin: auto;
}
/* The dots/bullets/indicators */
.dot {
height: 7px;
width: 7px;
margin: 2px;
background-color: #000000;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active {
background-color: #C5B358;
}
/* 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}
}
.slideshow-container .btn {
position: absolute;
top: 3150%;
left:50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
background-color: black;
color: white;
font-size: 12px;
padding:6px 12px;
border: none;
cursor: pointer;
text-align: center;
}
.slideshow-container .btn3 {
position: absolute;
top: 4650%;
left:50%;
transform: translate(-50%,-50%);
-ms-transform: translate(-50%,-50%);
background-color: black;
color: white;
font-size: 12px;
padding:6px 12px;
border: none;
cursor: pointer;
text-align: center;
}
.slideshow-container .btn:hover {
color:#C5B358;
}
.slideshow-container .btn3:hover {
color:#C5B358;
}
.section-1{
display:block;
position:relative;
}
.section-1 h1{
font-size: 60px;
font-family: Helvetica;
font-weight: 100;
text-align: center;
margin:10px;
}
.section-1 p{
font-family: Helvetica;
text-align: center;
line-height: 1.5;
}
<div class="main">
<div class="slideshow-container">
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/ A.png" style="width:100%">
<button class="btn">SCHEDULE</button>
</div>
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/B.png"style="width:100%">
<button class="btn">BROWSE</button>
</div>
<div class="mySlides fade">
<img src="file:///User/Name/Desktop/C.png"style="width:100%">
<button class="btn3">SHOP</button>
</div>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</div>
<div class="section-1">
<h1>AAA AAA AAAAAAA AAAA<br>AA A AAAAA AAAA</h1>
<p>AAAAAAA AA AAA AAAAAA AAAAA, AAAAA AA AAAAA A AAAAA AA AAA AAAAAAA AAAAAAAAAAA AA AA AAAAAAAAAA AAAAA.<br>AAA AAAAAAAA AAAAAAA AA AAAAAAAAA, AAA AA AAAAA AAA AAA AAAAAA AAA AAAAAAAA AAAAA.<br>AAAAA AAAA AAAA AAAAAA AAAAAAA AAA? <Br>AAAAAAA AA AAA AA AAAA AAAAA AAA AAA AAAA AAAAA. </p>
</div>
</div>
Upvotes: 0