day-4 updated

pull/197/head
satya 3 years ago
parent 512f9d4e13
commit 3f05452f1a

@ -152,11 +152,20 @@ h2 {
padding: 4px 8px; padding: 4px 8px;
color: #fff; color: #fff;
} }
.colorGen{ .colorGen {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
color: #f37575; width: 100%;
}
.color {
display: flex;
justify-content: center;
align-items: center;
height: 50px;
width: 80%;
color: #fff;
} }
.colorGen button{ .colorGen button{
background-color: #f37575; background-color: #f37575;

@ -1,28 +1,26 @@
import React from "react"; import React from "react";
export default function ColorGen() { export default function ColorGen() {
let str = '0123456789abcdef';
let hexColor = () => { let hexcolor = () => {
let color = ''; let color = '';
let str = '0123456789abcdef';
for (let i = 0; i < 6; i++) { for (let i = 0; i < 6; i++) {
let hex = Math.floor(Math.random() * str.length); let hex = Math.floor(Math.random() * str.length );
color += str[hex]; color += str[hex];
} }
return '#' + color; return '#' + color;
} }
let style = { let arr = Array(6).fill(0);
backgroundColor: '{hexColor}',
} let sixColor = arr.map((i) => <div className="color" style={{ backgroundColor: `${hexcolor()}` }}>
<h1>{ hexcolor()}</h1>
</div>);
// console.log(hexcolor());
return ( return (
<section className="colorGen"> <section className="colorGen">
<div className="colorContainer" style={style} {sixColor}
>
{hexColor()}
</div>
<button>Genarate</button>
</section> </section>
) )
} }
// I DO NOT KNOW WHAT I AM DONING WRONG IN MY CODE. BUT ICAN'T SEE THE CHANGE OF BACKGROUND COLOR AFTER GIVING THE HEIGHT AND WIDTH TO THE COLOR CONTAINER
Loading…
Cancel
Save