I'm trying to make a dynamic menu that changes the bg of a page.
But I have problems that I change the background if I do it with the general background of the page if it comes out, but in a div, no.
function menu_id(id){
document.getElementsByClassName("bg001").className=("fondo"+id);
}
body {
font: 18px Arial, Tahoma;
color: #b7a687;
}
.bg001 {
background: url("file:///H:\img1.jpg")
no-repeat center center fixed;
background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
-webkit-transition: width 0.5s; /* For Safari 3.1 to 6.0 */
transition: background 0.5s;
-webkit-transition-timing-function: linear;
-moz-transition-timing-function: linear;
-o-transition-timing-function: linear;
transition-timing-function: linear;
height:99vh;
}
.fondo1 {
background: url("file:///H:\img1.jpg")
no-repeat center center fixed;
background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
}
.fondo2 {
background: url("file:///H:\img2.jpg")
no-repeat center center fixed;
background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
}
.fondo3 {
background: url("file:///H:\img3.jpg")
no-repeat center center fixed;
background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
}
.fondo4 {
background: url("file:///H:\img4.jpg")
no-repeat center center fixed;
background-size: cover;
-moz-background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
}
.interior{
background: #fff;
position: absolute;
padding-top: 5px;
top: 0;
bottom: 0;
left: 50%;
right: 0;
width: 50%;
height: 284px;
margin: auto;
}
.aqs{
margin: 15px;
padding-left: 20px;
line-height: 52px;
cursor:pointer; cursor: hand;
transition: margin 1s, background 1s;
}
.aqs:hover{
}
.cli{
width: 3%;
background: url("file:///H:\linea.svg")
center bottom fixed;
-webkit-transition: width 0.5s; /* For Safari 3.1 to 6.0 */
transition: width 0.5s background 0.5s;
}
.cli:hover{
width: 100%;
}
span{
background: #fff ;
padding: 15px 20px 15px 10px;
}
<html>
<head>
</head>
<body>
<div class="bg001">
<div class="interior">
<div id="1" class="aqs" onmouseenter="menu_id(id)"><div class="cli"><span>item1</span></div></div>
<div id="2" class="aqs" onmouseenter="menu_id(id)"><div class="cli"><span>item2</span></div></div>
<div id="3" class="aqs" onmouseenter="menu_id(id)"><div class="cli"><span>item3</span></div></div>
<div id="4" class="aqs" onmouseenter="menu_id(id)"><div class="cli"><span>item4</span></div></div>
</div>
</div>
</body>
</html>