0
 const hus1 = Math.floor(Math.random()*16777215).toString(16);
  document.getElementById("house1").style.background = "#"+hus1;
  document.getElementsByClassName("house1::before").style.background-color = "#"+hus1;
  console.log(hus1)
.house {
  top: 50%;
  left: 30px;
  height: 80px;
  width: 104px;
  border: 1px solid;
}
.house::before {
  content: '';
  position: absolute;
  top: -38px;
  left: 13.2px;
  height: 73.2px;
  width: 73.4px;
  transform: rotate(45deg);
  border-top: 4px solid white;
  border-left: 4px solid white;
  z-index: 1
}

I am trying to change the color on the .house::before also in the same color, but doesn't seem like it likes this:

document.getElementsByClassName("house1::before").style.background-color = "#"+hus1;

tried just picking one color and changing the z-index, but didn't like that either

devpolo
  • 2,487
  • 3
  • 12
  • 28

0 Answers0