Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

made dark colors only #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ body {
color: white;
font-family: 'Amatic SC', cursive;
background-color: rgb(95,207,128);
min-height: 100vh;
display: flex;
justify-content: center;
flex-direction: column;
}
#quote-box {
position: absolute;
/* position: absolute;
top: 14%;
left: 10%;
right: 10%;
right: 10%; */
width: 80%;
margin: 0 auto;
line-height: .5;
}
.quote {
Expand Down Expand Up @@ -62,12 +67,15 @@ body {

#loadQuote {
font-size: 2.5rem;;
position: fixed;
/* position: fixed; */
width: 7em;
display: inline-block;
left: 50%;
margin-left: -6em;
bottom: 150px;
/* display: inline-block; */
/* left: 50%; */
/* margin-left: -6em; */
/* bottom: 150px; */
display: grid;
place-content: center;
margin: 0 auto;
border-radius: 4px;
border: 2px solid #fff;
color: #fff;
Expand Down
33 changes: 20 additions & 13 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Random Quotes</title>
<link href="https://fonts.googleapis.com/css?family=Amatic+SC" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<head>
<meta charset="UTF-8" />
<title>Random Quotes</title>
<link
href="https://fonts.googleapis.com/css?family=Amatic+SC"
rel="stylesheet"
type="text/css"
/>
<link rel="stylesheet" href="css/normalize.css" />
<link rel="stylesheet" href="css/styles.css" />
</head>
<body>
<div id="quote-box">
<p class="quote">You can do anything but not everything</p>
<p class="source">David Allen<span class="citation">Making It All Work</span><span class="year">2009</span></p>
<p class="source">
David Allen<span class="citation">Making It All Work</span
><span class="year">2009</span>
</p>
</div>
<button id="loadQuote">Show another quote</button>
</div>
<script src="js/script.js"></script>
</body>
</html>

<script src="js/script.js"></script>
</body>
</html>
26 changes: 18 additions & 8 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,23 @@ function getRandomQuote () {
}

//Function to select random rgb color value
function getRandomColor () {
var red = Math.floor(Math.random() * 256 );
var green = Math.floor(Math.random() * 256 );
var blue = Math.floor(Math.random() * 256 );
var randomColor = 'rgb(' + red + ',' + green + ',' + blue + ')';
return randomColor;
}
// function getRandomColor () {
// var red = Math.floor(Math.random() * 256 );
// var green = Math.floor(Math.random() * 256 );
// var blue = Math.floor(Math.random() * 256 );
// var randomColor = 'rgb(' + red + ',' + green + ',' + blue + ')';
// return randomColor;
// }
const getRandomNumber = (limit) => {
return Math.floor(Math.random() * limit);
};

function setBackgroundColor () {
const h = getRandomNumber(360);
const randomColor = `hsl(${h}deg, 50%, 10%)`;

document.body.style.backgroundColor = randomColor;
};

//Function to call the getRandomQuote function and stores the returned quote object in a variable
//Constructs a string containing the different properties of the quote object
Expand All @@ -191,7 +201,7 @@ function printQuote () {
quoteContainer.innerHTML = quoteString;

//assigns random color value to document background color
document.body.style.backgroundColor = getRandomColor ();
document.body.style.backgroundColor = setBackgroundColor();
}

//Quote automatically refreshes every 15 seconds
Expand Down