I'm not sure whether it's possible or not in my way. But I need it.
I have a css rule to define home page background image in style.css.
I would like to randomly select an image from a directory. Images names are like main-bg-*.jpg (i.e. main-bg-1.jpg, main-bg-2.jpg).
CSS
#background-div {
padding: 0;
margin: 0;
color: #000;
position: absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
z-index: -1;
background-image: url('../Images/Backgrounds/home-page-bg-1.jpg');
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-color: #464646;
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-o-filter: blur(5px);
-ms-filter: blur(5px);
filter: blur(5px);
}
HTML
<body>
<div id="background-div"></div>
-------
-------
</body>
I want to generate a number between 1 to 10 in controller method, then pass it to the css rule.
How can i do it?
If there is any other convenient way, please let me know.
Sorry if this is a silly question.
Thank you.