Selecting a random css class from a list

body is wrong here, I am not changing the body.

Pseudo code:

body.randomClassname1 .curtain{background: ..... whatever }
body.randomClassname2 .curtain{background: ..... whatever next }
body.randomClassname3 .curtain{background: ..... whatever next again }

I am adding css to the javascript there?

I don’t even know what that means. :slight_smile:

I believe you are already adding a random class to the body element. If so then you can use that class to change the background on the element of your choice using the format I showed in my previous post.

I got it. https://jsfiddle.net/vhbLma0q/3/

.curtain {
  flex: 1 0 0;
  margin: auto;
  max-width: 640px;
  position: relative;
  overflow: hidden;
}

body.vc1 .curtain {
  background: radial-gradient(60% 60% at 50% 50%, rgb(255, 255, 0), rgb(0, 0, 0));
}

body.vc2 .curtain {
  background: radial-gradient(60% 60% at 50% 50%, rgb(40, 0, 115), rgb(0, 0, 0));
}

body.vc3 .curtain {
  background: linear-gradient(120deg, #155799, #159957);
}
1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.