Top method for utilizing overlays

Is there a method to randomly select hex codes for specific colors?

I want to replicate the design in this image through coding.

Image

Here is the code I have so far:

HTML

<div id="group">
<div class="sub red panel">

</div><!--sub-->
<div class="sub orange">

</div><!--sub-->
<div class="sub yellow">

</div><!--sub-->

CSS

body{
    background:#333;
}
#group{
    position:relative;
    float:left;
    width:500px;
   height:300px;
}
.sub{position:relative; float:left; width:96px;}

.pxl{width:7px; position:relative;float:left; height:7px; margin:1px 1px 0 0;}
.red div{background:#f00;}
.orange div{background:#f26607;}
.yellow div{background:#f5e70b;}

js

var pageLimit=288;

 for(var i = 1; i <= pageLimit; i++) {
  $('.sub').append('<div class="pxl"></div>' )
 }

var randint = function ( ceiling ) {
    return Math.floor( Math.random() * ceiling );
};

setTimeout(function () {
    $( '.pxl' ).each(function () {
        $( this ).delay( randint(5000) ).fadeTo( randint(10000), 0 );
    });
}, 5000 );

If you can offer any assistance, it would be greatly appreciated. jsFiddle

Answer №1

If you're looking for a fun way to add some color to your webpage, you might want to try this out:

Check it out live!

http://jsfiddle.net/GHsBn/8/

Here's a snippet for you:

var col;
    $('.red .pxl').each(function(i, e) {
            col = 'rgb(255,' + (Math.floor(Math.random() * 150)) + ',' + (Math.floor(Math.random() * 150)) + ')';
            $(e).css('background', col);
        });

This code will cycle through each pixel in the red class and assign a random background color to it.

Feel free to experiment with the random values and ranges until you achieve the look you desire. Have fun! ;)

Answer №2

If you're looking to customize the array of colors returned, check out this resource for generating random hex color codes:

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to position a static element next to a Vue draggable list?

I'm currently working on implementing a feature to display a list of draggable elements using vue-draggable. These elements are occasionally separated by a fixed element at specified position(s). My approach so far has involved creating a separate el ...

Slider that is always being updated cannot be moved by dragging

Currently, I am utilizing React wrapped with cljs+reagent to develop a small application. One key feature I require is a slider that updates roughly every second and can be adjusted by the user. At present, my implementation looks like this: [:div.scrubb ...

Strange occurrences with the IMG tag

There seems to be an issue with my IMG element on the webpage. Even though I have set the height and width to 100%, there is some extra space at the end of the image. You can view the problem here: I have also included a screenshot from the developer too ...

Unusual occurrence while creating a unique identifier for a React component

I am working on creating a unique identification number for each React component, which will be assigned to the component upon mounting. Here is the approach I am taking: The callOnce function is used to ensure that a specific function is only executed on ...

Do I need to use the "--save" flag in npm to add dependencies to the "package.json" file?

Do I really need to use the "--save" flag in order to add an installed dependency to the "package.json" file? I conducted a test without the "save" flag and found that the package was still added to the "dependencies" section. It seems like it is the defa ...

The setInterval() function is not functioning properly when used with PHP's file_get_contents

Currently, I'm encountering an issue while attempting to use the function get_file_contents() within a setInterval(). The objective is to continuously update some text that displays the contents of a file. Below is the code snippet: <script src="h ...

Which javascript library provides the top-notch SVG graphics support for Internet Explorer and other web browsers?

Currently, I am developing a web application using javascript and jquery that involves drawing numerous rectangles and lines connecting them. It seems like I need to find an SVG graphics library to create lightweight components (approximately 300). The ch ...

Refreshing HTML tables with AJAX in Django

After going through all the posts here, I found that some are outdated and others don't quite match my issue. Apologies for bringing it up again. I have a basic HTML table with data in it. My goal is to update this data without refreshing the entire ...

Enhanced auto-zoom feature with orientation change for iOS 7

My web page was functioning perfectly until the release of iOS 7 by Apple today, causing the layout to break when the screen orientation is changed. When focusing on a text area and rotating the screen to landscape view, the entire page zooms in. However, ...

Implementing a technique for activating a Bootstrap modal using a function

Hello, I am currently experimenting with integrating JQUERY functionality into React, and it truly feels like magic. After conducting extensive research, I am attempting to trigger the Bootstrap Modal using an external function. Here is a link to my code ...

What is the method to determine the number of keys that have the same value in a JavaScript object?

My goal is to achieve functionality similar to this: var data = [ { tag:'A', others:'Abc' }, { tag:'B', others:'Bbc' }, { tag:'A', others ...

Progressing with Jquery AJAX sequentially

I'm attempting to send two ajax requests in succession. My plan was to utilize the ajax success() function for this task: $.ajax({ ... success: function() { //perform the second ajax request here } }); The issue is that the first ...

Is it possible to execute JavaScript code (using Node.js) through AppleScript on MAC OS?

After downloading Node.js for MAC OS from this link: http://nodejs.org/download/ (http://nodejs.org/dist/v0.10.29/node-v0.10.29.pkg), I needed to execute a JavaScript on Google Chrome. To do this, I utilized the following AppleScript code: do shell script ...

Tips for effectively structuring material-ui Grid in rows

I am currently using the material-ui framework to create a form. Utilizing the Grid system, I want to achieve the following layout: <Grid container> <Grid item xs={4} /> <Grid item xs={4} /> <Grid item xs={4} /> </Gr ...

To enable the description p tag only when the search box text matches the search criteria, otherwise keep the p tag disabled

I need to develop a search feature that includes a search box, a heading, and a paragraph description. Initially, the description should be hidden, but when a user enters text that matches the description, the paragraph tag should become visible. An exampl ...

JavaScript fails to effectively validate URLs

I have implemented the following validation for URLs: jQuery.validator.addMethod("urlValidatorJS", function (value, element) { var regExp = (/^HTTP|HTTP|http(s)?:\/\/(www\.)?[A-Za-z0-9]+([\-\.]{1}[A-Za-z0-9]+)*\.[A-Za-z]{ ...

Environment variables in Node process are uninitialized

I'm currently in the process of developing my first Express application, which requires interaction with an API using a secure API key. To ensure the security of this key and any future environment variables, I have decided to store them in a .env fil ...

Ensuring that md-select(s) created through ng-repeat are linked to the same model

<div ng-repeat="(key, value) in dataSet | groupBy: 'partner.partnerName'"> <md-select ng-model="userName" placeholder="{{ key }}" class="partnerUser" > <md-option >{{ key }} </md-option> <md-option ng-repe ...

Guide to streaming audio files using vue.js

I am attempting to incorporate an audio file into my vue.js project using the following code: import sound from '../../recordings/sound.mp4' const audio = new Audio(sound) audio.play() Although this method works perfectly fine, I have encounter ...

What is the process for changing the color of a button upon clicking with bootstrap?

Is there a way to specifically change the color of a button in Bootstrap when it is clicked? I have multiple buttons and only want the one that is clicked to change its color. Any help would be appreciated. Thanks! ...