diff --git a/css/style.css b/css/style.css index 463dc06..f7cf30f 100644 --- a/css/style.css +++ b/css/style.css @@ -1,3 +1,7 @@ button { - margin-top: 50vh + margin-top: 43vh +} +button{ + min-width: 200px; + height: 80px; } \ No newline at end of file diff --git a/js/script.js b/js/script.js index 803c165..c094d84 100644 --- a/js/script.js +++ b/js/script.js @@ -1,12 +1,25 @@ //Choose a random color const button = document.querySelector('button') const body = document.querySelector('body') -const colors = ['red', 'green', 'blue', 'yellow', 'pink', 'purple'] + +// const colors = ['red', 'green', 'blue', 'yellow', 'pink', 'purple']; body.style.backgroundColor = 'violet' button.addEventListener('click', changeBackground) function changeBackground(){ -const colorIndex= parseInt(Math.random()*colors.length) -body.style.backgroundColor = colors[colorIndex] +const red = parseInt(Math.random()*256); +const green = parseInt(Math.random()*256); +const blue = parseInt(Math.random()*256); + +let Bred = 255,Bgreen = 255,Bblue = 255,Btextcolor = 0; +if(red === 255 && green === 255 && blue === 255){ + [Bred,Bgreen,Bblue] = 0; + Btextcolor = 255; +} + +button.style.backgroundColor = `rgb(${Bred}, ${Bgreen}, ${Bblue})`; +button.style.Color = `rgb(${Btextcolor}, ${Btextcolor}, ${Btextcolor})`; + +body.style.backgroundColor = `rgb(${red}, ${green}, ${blue})`; }