Annaboka,
учите css - строки 7 - 40, и js учите
Добавление и удаление узлов
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
.carousel{
width: 350px;
height: 170px;
position: relative;
opacity: 0;
border-radius: 8px;
box-sizing: border-box;
border: #8B4513 2px solid;
transition: opacity .8s ease-in;
background-size: 350px 170px;
}
.carousel.show{
opacity: 1;
}
.carousel + h1{
cursor: default;
width: 350px;
color: #0000CD ;
opacity: 0;
transition: .3s ease-in;
text-align: center;
margin: auto 0;
transform: scale(0);
}
.carousel + h1 span{
color: #FF1493;
font-size: .8em;
}
.carousel.pause + h1{
opacity: 1;
transform: scale(1);
}
</style>
<script>
window.addEventListener("DOMContentLoaded", function() {
[].forEach.call(document.querySelectorAll(".carousel"), function(el) {
var img = JSON.parse(el.dataset.src),
text = JSON.parse(el.dataset.text);
len = img.length,
i = 0,
p = el.dataset.pause || 5E3,
h = document.createElement("h1");
document.body.insertBefore(h,el.nextSibling)
function g() {
el.style.backgroundImage = "url(" + img[i] + ")";
h.innerHTML = text[i];
el.classList.add("show");
window.setTimeout(k, p);
}
g();
function k() {
el.classList.contains("pause") || (i = ++i % len, el.classList.remove("show"));
window.setTimeout(g, 800);
}
function tgl() {
el.classList.toggle("pause");
}
el.addEventListener("click", tgl);
h.addEventListener("click", tgl);
});
});
</script>
</head>
<body>
<div class="carousel" data-pause="3000"
data-src='["http://sunnytravel.by/upload/image/Tours/Nicca-karnaval.jpg",
"http://img-fotki.yandex.ru/get/5640/35900228.10c/0_7388e_3ab59b4a_XL.jpeg.jpg",
"http://1.bp.blogspot.com/-aleHkBUuqOI/VY0HrCytsXI/AAAAAAAAq1g/f2emGtdqdWo/s640/2015-06-05_0145.jpg",
"http://turj.ru/images/e/3/9/7/1/b641b8a77c.jpg"]' data-text='["карнавал<br><span>и всякий бред</span>",
"Ницца<br><span>и всякий бред</span>",
"маска<br><span>и всякий бред</span>",
"праздник<br><span>и всякий бред</span>"]'>
</div>
</body>
</html>