I've created a header class in my CSS with the following styling-
header {
background-image: url('../img/header-bg.jpg');
background-repeat: none;
background-attachment: scroll;
background-position: center center;
.background-cover;
text-align: center;
color: white;
.intro-text {
padding-top: 100px;
padding-bottom: 50px;
.intro-lead-in {
.serif-font;
font-style: italic;
font-size: 22px;
line-height: 22px;
margin-bottom: 25px;
}
.intro-heading {
.heading-font;
font-weight: 700;
font-size: 50px;
line-height: 50px;
margin-bottom: 25px;
}
}
}
My goal now is to change the background image every 10 seconds with a different image file named 'abc.jpg
'. Most online solutions involve adding two <img>
tags to the HTML and using jQuery for the transition. However, I have specified the image in the CSS for the header and there are no <img>
tags in my HTML. Is there a way to achieve this transition without modifying the HTML by manipulating the CSS file with jQuery or JavaScript to change the background-image URL of the header class every 10 seconds?