I have a problem with this multiple slideshow inside a Tab Menu. I´m trying to make a multiple slideshow that cycles automatically in loop and pauses on hover, but I can´t get it to work properly. So far the slideshow only plays once and the looping is not working, once the slideshow gets to the last image, the slideshow container looks "empty". Somehow it only reproduces once and to get it to work again, one most refresh the page.
Please help, and thank you a lot in advance!
/* Tabs */
function mySlides(evt, day) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(day).style.display = "block";
evt.currentTarget.className += " active";
}
var doAnimation = true;
var slideIndex = 0;
showSlides(slideIndex);
function toggleSlides(n) {
showSlides(slideIndex + n, true);
}
Array.from(document.getElementsByClassName("mySlides")).forEach((mySlide)=> {
mySlide.addEventListener("mouseover",function() {
doAnimation = false;
})
mySlide.addEventListener("mouseout",function() {
doAnimation = true;
});
});
var timer;
function showSlides(n, force) {
console.log(doAnimation)
if (doAnimation || force) {
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 (n) {
slideIndex = n;
}
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";
if (force) {
clearInterval(timer);
timer = setInterval(showSlides, 4000);
}
}
}
timer = setInterval(showSlides, 4000);
/* Style Fonts */
#import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght#300&display=swap');
body {font-family:'Roboto Condensed', sans-serif;}
/* Body */
p {
font-weight: 900;
font-size: 50px;
text-align: center;
color: #e84048;
position: auto;
margin-top:30px;
}
p.thick {
font-weight: bold;
font-size: 20px;
text-align: center;
color: #e84048;
position: absolute;
top: 10%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
p.thicker {
font-weight: bold;
font-size: 20px;
text-align: center;
color: #e84048;
position: absolute;
bottom: 0%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
/* Title Slide */
h1 {font-family: 'Roboto Condensed', sans-serif;
color: white;
font-size: 3.5rem;
font-weight: bold;
position: absolute;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;}
#media only screen and (max-width: 450px) {
h1 {
font-size: 2rem;
}
}
/* Time */
h2 {font-family: 'Roboto Condensed', sans-serif;
color: #e84048;
font-size: 1rem;
position: absolute;
top: 10%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;}
#media only screen and (max-width: 450px) {
h2 {
font-size: 1rem;
}
}
/* Instructor */
h3 {font-family: 'Roboto Condensed', sans-serif;
color: #e84048;
font-size: 1rem;
position: absolute;
bottom:0%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;}
#media only screen and (max-width: 450px) {
h3 {
font-size: 1rem;
}
}
/* Hover Description */
h4 {font-family: 'Roboto Condensed', sans-serif;
color: white;
font-size: 1rem;
position:absolute;
left:50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;}
#media only screen and (max-width: 450px) {
h4 {
font-size: 1rem;
}
}
/* Title Tab */
h5 {font-family: 'Roboto Condensed', sans-serif;
color: #1e0f55;
font-size: 40px;
left: 50%;
position: relative;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
margin-top: 100px;
margin-bottom: 0px;
}
/* Subtitle Tab */
h6 {font-family: 'Roboto Condensed', sans-serif;
color: white;
font-size: 25px;
left: 50%;
position: relative;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
margin-top: -10px;
margin-bottom: 0px;
}
/* Tab Weekend */
.tab {
overflow: hidden;
background-color: #e84048;
}
/* Style buttons tab */
.tab button {
background-color: inherit;
color: white;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 18px;
font-family:'Roboto Condensed', sans-serif;
}
/* tab buttons hover */
.tab button:hover {
background-color: #ff8080;
color: ##e84048
;
}
/* active tablink class */
.tab button.active {
background-color: #1e0f55;
color: #e84048
;
}
/* Style tab content */
.tabcontent {
display: none;
border: none;
}
/* Slideshow container */
* {
box-sizing: border-box;
}
.mySlides {
display: none;
}
img {
vertical-align: middle;
height:100%;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
.slideshow-container {
width: 100vw;
height: 80vh;
position: relative;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
opacity: 0;
transition: .5s ease-in-out;
background-color: #1e0f55;
vertical-align: middle;
width: 100%;
height:100%;
}
.slideshow-container:hover .overlay {
opacity: 0.9;
}
/* dots */
.dot {
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active {
background-color: #717171;
}
/* Fading animation Autorun */
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 2s;
animation-name: fade;
animation-duration: 2s;
}
#-webkit-keyframes fade {
from {
opacity: .4
}
to {
opacity: 1
}
}
#keyframes fade {
from {
opacity: .4
}
to {
opacity: 1
}
}
<div class="text">
<h5>Weekend 1 </h5>
<h6> 27.01 - 29.01</h6>
</div>
<div class="tab">
<button class="tablinks" onclick="mySlides(event, 'firstfriday')">Friday</button>
<button class="tablinks" onclick="mySlides(event, 'firstsaturday')">Saturday</button>
<button class="tablinks" onclick="mySlides(event, 'firstsunday')">Sunday</button>
</div>
<div id="firstfriday" class="tabcontent" style="text-align:center">
>
<div class="slideshow-container";
}>
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="https://winterwerft.de/wp-content/uploads/sites/3/2022/12/Residui.jpg">
<div class="text">
<h1>RETURN TO THE BEGINNING</h1>
<p class="thicker">15:00 -18:00</p>
<p class="thick">Theater</p>
</div>
<div class="overlay">
<div class="text">
<h2>Von 15:00 bis 18:00 Uhr</h2>
<h4>RETURN TO THE BEGINNING<br>open rehearsal<br><br>Although the work is still in progress, with a premiere scheduled for the end of spring 2023, we have decided to share our work in progress, thanking you in advance for your reflections on the subject.<br>Three survivors in a cave, inside an old mine, amuse themselves resurrecting possible lives of angels and demons, gods and goddesses in search of a lost truth. None of them lived be-fore the disaster. Who is the son or sister of whom? They don’t even know. They don’t dare to leave the cave or maybe they do...?</h4>
<h3>Residui Teatro and CAAE</h3>
</div>
</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img id="myImg" src="https://winterwerft.de/wp-content/uploads/sites/3/2023/01/mehrimpulse.jpg">
<div class="text">
<h1>Mehr Impulse</h1>
<p class="thicker">22:00 - 23:00</p>
<p class="thick">Music</p>
</div>
<div class="overlay">
<div class="text">
<h2>22:00 - 23:00</h2>
<h4>Mehr Impulse<br>Alle Infos - bald hier!</h4>
<h3>Mehr Impulse</h3>
</div>
</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="https://winterwerft.de/wp-content/uploads/sites/3/2021/02/Profilbild_white_Logo.jpg">
<div class="text">
<h1>Alle Infos - bald hier!</h1>
<p class="thicker">Uhrzeit</p>
<p class="thick">Art der Veranstaltung</p>
</div>
<div class="overlay">
<div class="text">
<h2>...</h2>
<h4>Alle Infos - bald hier!</h4>
<h3>...</h3>
</div>
</div>
</div>
</div>
<p>Friday 27.01.23</p>
<br>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</div>
<div id="firstsaturday" class="tabcontent" style="text-align:center">
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="https://winterwerft.de/wp-content/uploads/sites/3/2022/12/AmorSacroAmorProfano_photoSimonTemplar21.jpg">
<div class="text">
<h1>THE DANCING ACTOR</h1>
<p class="thicker">10:00 -13:00</p>
<p class="thick">Oeffentliche Workshop</p>
</div>
<div class="overlay">
<div class="text">
<h2>Von 10:00 bis 13:00 Uhr</h2>
<h4>THE DANCING ACTOR<br><br>klassischem indischen Tanztheater im Bharata Natyam Stil.Die Teilnehmer werden durch das Ueben und Studieren der Grundelemente des Tanzes, von den Grundschritten bis zu den ersten Prinzipien des Schauspiels, in den Tanz eingefuehrt.<br>Der Workshop hat einen Umfang von 10h und findet auf Englisch, sowie wenn
nötig mit Übersetzung statt.</h4>
<h3>mit Caterina Scotti<br>von Teatro Tascabile di Bergamo</h3>
</div>
</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="https://winterwerft.de/wp-content/uploads/sites/3/2022/12/AmorSacroAmorProfano_photoSimonTemplar21.jpg">
<div class="text">
<h1>THE DANCING ACTOR</h1>
<p class="thicker">15:00 - 18:00</p>
<p class="thick">Oeffentliche Workshop</p>
</div>
<div class="overlay">
<div class="text">
<h2>Von 15:00 bis 18:00 Uhr</h2>
<h4>THE DANCING ACTOR<br><br>klassischem indischen Tanztheater im Bharata Natyam Stil.Die Teilnehmer werden durch das Ueben und Studieren der Grundelemente des Tanzes, von den Grundschritten bis zu den ersten Prinzipien des Schauspiels, in den Tanz eingefuehrt.<br>Der Workshop hat einen Umfang von 10h und findet auf Englisch, sowie wenn
nötig mit Übersetzung statt.</h4>
<h3>mit Caterina Scotti<br>von Teatro Tascabile di Bergamo</h3>
</div>
</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="https://winterwerft.de/wp-content/uploads/sites/3/2022/12/IMG-20221224-WA0000.jpg">
<div class="text">
<h1>Green Clouds<br>Vapour</h1>
<p class="thicker">22:30 - 23:00</p>
<p class="thick">Music</p>
</div>
<div class="overlay">
<div class="text">
<h2>Von 22:30 bis 23:00 Uhr</h2>
<h4>Vapour is an electro acoustic live performance. A viridescent entity dissolving into heavy storms, gently raining down onto the virtual stage. By creating a fog of synthetic sound objects, we enter the world of a wondrous dormant terrain. Sonic material is composed of mineral vibration and reverberating particles
to form low - pitched holograms, placed in an artificial space. Scanning the green void,
palpating moist textures, observing ambiguous matter, leads to confusing diffusing fading decay. Exhaling misty thoughts, spreading a languid feeling of inertia.</h4>
<h3>Green Clouds <br>(David Synth)<br></h3>
</div>
</div>
</div>
</div>
<p>Saturday 28.01.23</p>
<br>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</div>
<div id="firstsunday" class="tabcontent" style="text-align:center">
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="https://winterwerft.de/wp-content/uploads/sites/3/2022/12/Beconscious.jpg">
<div class="text">
<h1>Beconscious</h1>
<p class="thicker">14:00</p>
<p class="thick">Oeffentliche Workshop</p>
</div>
<div class="overlay">
<div class="text">
<h2>Um 14:00 Uhr</h2>
<h4>Beconscious<br><br>In diesem Workshop werden wir mit unseren Körpern und der Beziehung zwischen ihnen spielen, während wir den Prozess in Stille und mit Wohlwollen mental beobachten. Dies geschieht insbesondere durch Techniken des Theaters der Forschung, einem von der Gruppe eingeführten theatralischen Weg. Ziel ist es, als Einheit, aber auch als Ganzes, offener und bewusster an unseren Handlungsort zurückzukehren.<br>Der Workshop hat einen Umfang von 4h und findet auf Englisch, sowie wenn nötig mit Übersetzung statt.</h4>
<h3>mit der Multiactive Group<br>der Art Fabrica Athen</h3>
</div>
</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="https://winterwerft.de/wp-content/uploads/sites/3/2022/12/AmorSacroAmorProfano_photoSimonTemplar21.jpg">
<div class="text">
<h1>THE DANCING ACTOR</h1>
<p class="thicker">15:00 -18:00</p>
<p class="thick">Oeffentliche Workshop</p>
</div>
<div class="overlay">
<div class="text">
<h2>Von 15:00 bis 18:00 Uhr</h2>
<h4>THE DANCING ACTOR<br><br>klassischem indischen Tanztheater im Bharata Natyam Stil.Die Teilnehmer werden durch das Ueben und Studieren der Grundelemente des Tanzes, von den Grundschritten bis zu den ersten Prinzipien des Schauspiels, in den Tanz eingefuehrt.<br>Der Workshop hat einen Umfang von 10h und findet auf Englisch, sowie wenn
nötig mit Übersetzung statt.</h4>
<h3>mit Caterina Scotti<br>von Teatro Tascabile di Bergamo</h3>
</div>
</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="https://winterwerft.de/wp-content/uploads/sites/3/2022/12/MEGELLA.jpg">
<div class="text">
<h1>Meg Ella</h1>
<p class="thicker">22:00 -23:00</p>
<p class="thick">Music</p>
</div>
<div class="overlay">
<div class="text">
<h2>Von 22:00 bis 23:00 Uhr</h2>
<h4>Join us for an intimate concert of original songs from Welsh singer songwriter and multi-instrumentalist Meg Ella. With soaring vocals, intricate harmony and cinematic arrangements she will be joined on stage by world class instrumentalists Fraser Bowles (cello) and Nic Jones (trombone).
<br>Marc Almond and Othon Matargas Now based in London, UK, Meg Ella also works as a vocalist, cellist & pianist as a session musician, arranger and Musical Director for artists, theatre, film and ensembles.</h4>
<h3>Meg Ella</h3>
</div>
</div>
</div>
</div>
<p>Sunday 29.01.23</p>
<br>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</div>
Related
I am trying to implement a image slider in angular from scratch, and trying to replicate a w3school based image slider.
Below I have tried to implement in angular, Can anyone guide me how to implement using angular?
Here you can find stackblitz link
component.html
<div class="slideshow-container" #myDiv>
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="https://img.adaptivereso.com/https://stellarmls-propertyresi.s3.us-west-002.backblazeb2.com/314a10f7-07d4-4d9e-b8ea-be44be55ab35.jpeg/?rwidth=300&rheight=200&type=jpg" style="width:100%">
<div class="text">Caption Text</div>
</div>
<div class="mySlides fade" >
<div class="numbertext">2 / 3</div>
<img src="https://img.adaptivereso.com/https://stellarmls-propertyresi.s3.us-west-002.backblazeb2.com/cd7c5e85-d528-4d10-a635-ace77aaef77d.jpeg/?rwidth=300&rheight=200&type=jpg" style="width:100%">
<div class="text">Caption Two</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="https://img.adaptivereso.com/https://stellarmls-propertyresi.s3.us-west-002.backblazeb2.com/314a10f7-07d4-4d9e-b8ea-be44be55ab35.jpeg/?rwidth=300&rheight=200&type=jpg" style="width:100%">
<div class="text">Caption Three</div>
</div>
<a class="prev" (click)="plusSlides(-1)">❮</a>
<a class="next" (click)="plusSlides(1)">❯</a>
</div>
<br>
<div style="text-align:center">
<span class="dot" (click)="currentSlide(1)"></span>
<span class="dot" (click)="currentSlide(2)"></span>
<span class="dot" (click)="currentSlide(3)"></span>
</div>
component.ts
import { Component, OnInit, ViewChild, ElementRef, ViewChildren, QueryList } from '#angular/core';
#Component({
selector: 'app-custom-gallery',
templateUrl: './custom-gallery.component.html',
styleUrls: ['./custom-gallery.component.css']
})
export class CustomGalleryComponent implements OnInit {
slideIndex:number = 1;
constructor (public elementRef: ElementRef) { }
ngOnInit(): void {
this.showSlides(this.slideIndex);
}
plusSlides(n) {
this.showSlides(this.slideIndex += n);
}
currentSlide(n) {
console.log(n)
this.showSlides(this.slideIndex = n);
}
showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
var dots = document.getElementsByClassName("dot");
if (n > slides.length) {this.slideIndex = 1}
if (n < 1) {this.slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
console.log(typeof slides[i]);
// slides[i].style.display = "none";
}
for (i = 0; i < dots.length; i++) {
dots[i].className = dots[i].className.replace(" active", "");
}
// slides[this.slideIndex-1].style.display = "block";
dots[this.slideIndex-1].className += " active";
}
}
component.css
* {box-sizing: border-box}
body {font-family: Verdana, sans-serif; margin:0}
.mySlides {display: none}
img {vertical-align: middle;}
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 16px;
margin-top: -22px;
color: white;
font-weight: bold;
font-size: 18px;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
user-select: none;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
/* Caption text */
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* The dots/bullets/indicators */
.dot {
cursor: pointer;
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active, .dot:hover {
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) {
.prev, .next,.text {font-size: 11px}
}
Here is an approach you could use:
Create an ImageSlider component, which takes a list of images as in an input, and keeps track of the current slide
export class ImageSliderComponent {
#Input() images: string[];
slideIndex: number = 0;
changeSlide(n: number) {
this.slideIndex += n;
}
}
In the template, display only the active slide (refer to the img src binding):
<div class="slideshow-container" #myDiv>
<div class="mySlides fade">
<div class="numbertext">{{ slideIndex + 1}} / {{ images.length }}</div>
<img
[src]="images[slideIndex]"
style="width:100%"
/>
<div class="text">Caption Text</div>
</div>
<a class="prev" (click)="changeSlide(-1)">❮</a>
<a class="next" (click)="changeSlide(1)">❯</a>
</div>
Use your component like:
<app-image-slider [images]="[
'http://images.com/image1.jpg',
'http://images.com/image1.jpg',
'http://images.com/image3.jpg']"></app-image-slider>
Stackblitz: https://stackblitz.com/edit/angular-ivy-x9nk16?file=src%2Fapp%2Fimage-slider.component.ts
Note:
avoid use of ElementRef, getElementsByClassName, etc in Angular applications, this is usually an indication you are not using Angular conventions.
I'm creating a simple html page with some text and css, on the top I have a few imagens with slideshow and on the body I put a big text, but I'm learning html and css.
The Question:
I used padding for the text but when is mobile the padding is not good for reading, if someone can help me just take a look at the codes, I used w3schools as a reference to create the page:
<!DOCTYPE html>
<html>
<head>
<style>
div .padding {
padding: 90px;
}
</style>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box;}
body {font-family: Verdana, sans-serif;}
.mySlides {display: none;}
img {vertical-align: middle;}
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
/* Caption text */
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* The dots/bullets/indicators */
.dot {
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active {
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}
}
</style>
</head>
<body>
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="https://cdn.dooca.store/568/files/2img.jpg?v=1617815220" style="width:100%">
<div class="text">Óleos Ozonizados</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="https://cdn.dooca.store/568/files/1img.jpg?v=1617815212" style="width:100%">
<div class="text">Óleo de Girassol</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img src="https://cdn.dooca.store/568/files/3img.jpg?v=1617818739" style="width:100%">
<div class="text">Óleo de Oliva</div>
</div>
</div>
<br>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
<script>
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, 2000); // Change image every 2 seconds
}
</script>
<div class="padding">
<p><strong>O que são os óleos ozonizados?</strong></p>
<p style="text-align: justify;">Os óleos ozonizados são produzidos basicamente a partir de 2 ingredientes, o óleo vegetal e o gás ozônio. A incorporação da molécula de ozônio ao óleo vegetal resulta de uma reação química, onde o ozônio reage com as ligações duplas de carbono presente nas cadeias lipídicas. Essa reação produz uma série de novas moléculas como ozonídeos e peróxidos que são responsáveis pela ação antimicrobiana e bioestimuladora dos óleos ozonizados. </p> </div>
</body>
</html>
Just edit this:
div .padding {
padding: 90px;
}
to
.padding {
padding: 90px;
}
You should also only use one <style> tag.
Also would like to advice to check out Media Queries where you can control the styling base on Responsive:
https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
My Carousel images are disappearing on Joomla. I'm trying to have an automatic banner for a webpage using the below code from W3 Schools, I have entered the code into a custom module in Joomla. I have also tried using it with Notepad++ and opening it in a browser and it works completely fine. However, on the Joomla page the images become white and do not display. I am able to switch between them an the CSS for the slider and arrows seems to work. Please find my code:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box;}
body {font-family: Verdana, sans-serif;}
.mySlides {display: none;}
img {vertical-align: middle;}
/* Slideshow container */
.slideshow-container {
max-width: 1000px;
position: relative;
margin: auto;
}
/* Caption text */
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* The dots/bullets/indicators */
.dot {
height: 15px;
width: 15px;
margin: 0 2px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active {
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}
}
</style>
</head>
<body>
<h2>Automatic Slideshow</h2>
<p>Change image every 2 seconds:</p>
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<img src="https://www.w3schools.com/howto/img_nature_wide.jpg"
style="width:100%">
<div class="text">Caption Text</div>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<img src="https://www.w3schools.com/howto/img_fjords_wide.jpg"
style="width:100%">
<div class="text">Caption Two</div>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<img
src="https://www.w3schools.com/howto/img_mountains_wide.jpg"
style="width:100%">
<div class="text">Caption Three</div>
</div>
</div>
<br>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
<script>
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, 6000); // Change image every 6 seconds
}
</script>
</body>
</html>
If you are using Custom HTML Module - it disables all of your scripts
I advice you to use something else for using JS in module - for example - Flexi Custom Code
The code you have shown is for an entire html document, you can't simply dump that whole into another entire html document. Joomla is a CMS, you shouldn't just drop html into it. To add an image carousel it would be better to create your own module to do that.
how can i remove my slideshow width? and how can i add more number of picture in my slideshow
i want to increase my slideshow width, and increase number of picture of myslideshow, slideshow is writtern in java, css and html.
my pics size is 1200x300.
i tried to add width in css but width increased just right side, my pic does not fit in center please help me experts.
Help Help Help
Help Help Help
Help Help Help
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box
}
body {
font-family: Verdana, sans-serif;
}
.mySlides {
display: none
}
/* Slideshow container */
.slideshow-container {
max-width: 1200px;
position: relative;
margin: auto;
}
/* Caption text */
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
.active {
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
}
}
</style>
</head>
<body>
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="https://4.bp.blogspot.com/-LMLb-SRggk8/WdfQDgzmHYI/AAAAAAAAByc/UWQgh2DqSdAY5esr3-i5qmRYDFVuTh7zACLcBGAs/s1600/Flag%2B1200x300.jpg" style="width:100%">
<div class="text"></div>
</div>
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="https://3.bp.blogspot.com/-lbgXjiKwfss/WdfQufxdrsI/AAAAAAAAByk/A8oJ9b3nMugIs6LIgjv04qCHAfrO-NXrACLcBGAs/s1600/Animation%2BLight%2BHouse.gif" style="width:100%">
<div class="text"></div>
</div>
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="https://1.bp.blogspot.com/-6RWJYpjHqFE/WdfQ8S9RWrI/AAAAAAAAByo/OflSPE6aAKQpvWjfNUS3-lrddygVFaL6QCLcBGAs/s1600/outer%2Bspace%2Bnight%2Bstars.jpg" style="width:100%">
<div class="text"></div>
</div>
</div>
<br>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
<script>
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, 2000); // Change image every 2 seconds
}
</script>
</body>
</html>
Simply remove the margin in the body and add the min-width: 100%; to the .slideshow-container.
For adding more slide just duplicate this code.
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="my-image.jpg"> <!-- remove the width property from all image tag. -->
<div class="text"></div>
</div>
There is no magical width property that will set the image width to 100% you need to set the width of the container of the image and the image will expand accordingly.
Also, increase the number of <span class="dot"></span> element as you increase the slides. Because it depends on the number of slides else it will stop the js code and throw an error.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box
}
body {
font-family: Verdana, sans-serif;
margin: 0px;
}
.widget {
margin: 0px;
}
.mySlides {
display: none
}
/* Slideshow container */
.slideshow-container {
min-width: 100%;
position: relative;
margin: auto;
}
/* Caption text */
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
.active {
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
}
}
</style>
</head>
<body>
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="https://4.bp.blogspot.com/-LMLb-SRggk8/WdfQDgzmHYI/AAAAAAAAByc/UWQgh2DqSdAY5esr3-i5qmRYDFVuTh7zACLcBGAs/s1600/Flag%2B1200x300.jpg" style="width: 100%">
<div class="text"></div>
</div>
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="https://3.bp.blogspot.com/-lbgXjiKwfss/WdfQufxdrsI/AAAAAAAAByk/A8oJ9b3nMugIs6LIgjv04qCHAfrO-NXrACLcBGAs/s1600/Animation%2BLight%2BHouse.gif" style="width: 100%">
<div class="text"></div>
</div>
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="https://1.bp.blogspot.com/-6RWJYpjHqFE/WdfQ8S9RWrI/AAAAAAAAByo/OflSPE6aAKQpvWjfNUS3-lrddygVFaL6QCLcBGAs/s1600/outer%2Bspace%2Bnight%2Bstars.jpg" style="width: 100%">
<div class="text"></div>
</div>
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="http://lorempixel.com/output/food-q-c-1200-300-3.jpg" style="width: 100%">
<div class="text"></div>
</div>
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="http://lorempixel.com/output/animals-q-c-1200-300-5.jpg" style="width: 100%">
<div class="text"></div>
</div>
</div>
<br>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<!-- Increase the dots as you increase the slides -->
</div>
<script>
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, 2000); // Change image every 2 seconds
}
</script>
</body>
</html>
Is this what you want?
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing:border-box}
body {font-family: Verdana,sans-serif;}
.mySlides {display:none}
/* Slideshow container */
.slideshow-container {
position: relative;
margin: auto;
}
/* Caption text */
.text {
color: #f2f2f2;
font-size: 15px;
padding: 8px 12px;
position: absolute;
bottom: 8px;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.numbertext {
color: #f2f2f2;
font-size: 12px;
padding: 8px 12px;
position: absolute;
top: 0;
}
.active {
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}
}
</style>
</head>
<body>
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="https://4.bp.blogspot.com/-LMLb-SRggk8/WdfQDgzmHYI/AAAAAAAAByc/UWQgh2DqSdAY5esr3-i5qmRYDFVuTh7zACLcBGAs/s1600/Flag%2B1200x300.jpg" style="width:100%">
<div class="text"></div>
</div>
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="https://3.bp.blogspot.com/-lbgXjiKwfss/WdfQufxdrsI/AAAAAAAAByk/A8oJ9b3nMugIs6LIgjv04qCHAfrO-NXrACLcBGAs/s1600/Animation%2BLight%2BHouse.gif" style="width:100%">
<div class="text"></div>
</div>
<div class="mySlides fade">
<div class="numbertext"></div>
<img src="https://1.bp.blogspot.com/-6RWJYpjHqFE/WdfQ8S9RWrI/AAAAAAAAByo/OflSPE6aAKQpvWjfNUS3-lrddygVFaL6QCLcBGAs/s1600/outer%2Bspace%2Bnight%2Bstars.jpg" style="width:100%">
<div class="text"></div>
</div>
</div>
<br>
<div style="text-align:center">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
<script>
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, 2000); // Change image every 2 seconds
}
</script>
</body>
</html>
<marquee>
<div class="client">
<img src="images/c1.png"/>
</div>
<div class="client">
<img src="images/c2.png"/>
</div>
<div class="client">
<img src="images/c3.png"/>
</div>
<div class="client">
<img src="images/c4.png"/>
</div>
<div class="client">
<img src="images/c5.png"/>
</div
><div class="client">
<img src="images/c6.png"/>
</div
><div class="client">
<img src="images/c7.png"/>
</div>
</marquee>
I wanted to scroll these images without using html's marquee tag...please help me.I have used css keyframes but I didn't get what I wanted. These images are in index page bottom side. This is clients logos scrolling from left to right or right to left....thanks in advance.
/*download .js file from here and include it in ur project */
http://technicalpixel.com/post%20sample%20code/Continous%20Horizontal%20JQuery%20Image%20Marquee/assets/js/crawler.js
<head>
<script src="assets/js/crawler.js" type="text/javascript" ></script>
</head>
/* add id to ur div tag */
<div id="marquee">
<div class="client">
<img src="images/c1.png"/>
</div>
<div class="client">
<img src="images/c2.png"/>
</div>
<div class="client">
<img src="images/c3.png"/>
</div>
<div class="client">
<img src="images/c4.png"/>
</div>
<div class="client">
<img src="images/c5.png"/>
</div
><div class="client">
<img src="images/c6.png"/>
</div
><div class="client">
<img src="images/c7.png"/>
</div>
</div>
/* Add this script in ur project in head tag*/
marqueeInit({
uniqueid: 'marquee',
style: {
},
inc: 5, //speed - pixel increment for each iteration of this marquee's movement
mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false)
moveatleast: 2,
neutral: 150,
savedirection: true,
random: true
});
Please try this:
<style type="text/css">
/* Make it a marquee */
.marquee {
width: 450px;
margin: 0 auto;
overflow: hidden;
white-space: nowrap;
box-sizing: border-box;
animation: marquee 50s linear infinite;
}
.marquee:hover {
animation-play-state: paused
}
/* Make it move */
#keyframes marquee {
0% { text-indent: 27.5em }
100% { text-indent: -105em }
}
/* Make it pretty */
.microsoft {
padding-left: 1.5em;
position: relative;
font: 16px 'Segoe UI', Tahoma, Helvetica, Sans-Serif;
}
/* ::before was :before before ::before was ::before - kthx */
.microsoft:before, .microsoft::before {
z-index: 2;
content: '';
position: absolute;
top: -1em; left: -1em;
width: .5em; height: .5em;
box-shadow: 1.0em 1.25em 0 #F65314,
1.6em 1.25em 0 #7CBB00,
1.0em 1.85em 0 #00A1F1,
1.6em 1.85em 0 #FFBB00;
}
.microsoft:after, .microsoft::after {
z-index: 1;
content: '';
position: absolute;
top: 0; left: 0;
width: 2em; height: 2em;
background-image: linear-gradient(90deg, white 70%, rgba(255,255,255,0));
}
/* Style the links */
.vanity {
color: #333;
text-align: center;
font: .75em 'Segoe UI', Tahoma, Helvetica, Sans-Serif;
}
.vanity a, .microsoft a {
color: #1570A6;
transition: color .5s;
text-decoration: none;
}
.vanity a:hover, .microsoft a:hover {
color: #F65314;
}
/* Style toggle button */
.toggle {
display: block;
margin: 2em auto;
}
</style>
<p class="microsoft marquee"><img src="https://s-media-cache-ak0.pinimg.com/236x/a2/4b/48/a24b48e465e666fffd4cbcaa79107c7c.jpg" /></p>
<button class="toggle">Toggle Beautification</button>
<script type="application/javascript">
$(".toggle").on("click", function () {
$(".marquee").toggleClass("microsoft");
});
</script>
http://jsfiddle.net/jonathansampson/XxUXD/