JSFiddle - React, Tailwind, and code Playground
HTML
<div class="post">
<div class="something">
<h1>Same</h1>
text text text
</div>
</div>
<div class="post">
<div class="something">
<h1>Same</h1>
<div>Same</div>
text text text
</div>
</div>
<div class="post">
<div class="something">
<h1>Same</h1>
<div>Same</div>
text text text
</div>
</div>
CSS
h1 {font-weight: bold;}
.something {color:#000;}
.post {padding-top:10px; padding-bottom: 5px; margin: 5px 0;
border-top: 1px solid;
border-bottom: 1px solid;}
JavaScript
function get_random_color() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.round(Math.random() * 15)];
}
return color;
}
$(".post").each(function() {
var color = get_random_color();
$(this).css('border-color', color);
$(this).children("h1").css('font-color', color);
$(this).children("div").css('background-color', color);
});