Not with raw CSS, but this is certainly possible with JavaScript. First, we need to add a click function to the HTML to trigger the JavaScript:
<button type="button" class="close" onclick="move()" data-dismiss="modal">Close</button>
Then we need to build a function that moves .rouletteWheelGradient
:
function move() {
for (var i = 0; i < document.getElementsByClassName("rouletteWheelGradient").length; i++) {
document.getElementsByClassName("rouletteWheelGradient")[i].style.marginTop = "62px";
}
}
Note the px
at the end of the function, which represents pixels. You need to specify a unit of measurement for your selector, and you're missing this in your CSS.
Here's a working example:
function move() {
for (var i = 0; i < document.getElementsByClassName("rouletteWheelGradient").length; i++) {
document.getElementsByClassName("rouletteWheelGradient")[i].style.marginTop = "62px"
}
}
<button type="button" class="close" onclick="move()" data-dismiss="modal">Close</button>
<div id="1" class="rouletteWheelGradient">One</div>
<div id="2" class="rouletteWheelGradient">Two</div>
<div id="3" class="rouletteWheelGradient">Three</div>
The above sample gives every element with class rouletteWheelGradient
a top margin of 62px when the button is clicked.
I've also created a JSFiddle showcasing this here.
Hope this helps! :)