Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions Sprint-3/quote-generator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title here</title>
<script defer src="quotes.js"></script>
<title>Quote generator app</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>hello there</h1>
<p id="quote"></p>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a semantic html element you could use here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely, I have applied blockquote and cite

<p id="author"></p>
<button type="button" id="new-quote">New quote</button>
<script defer src="quotes.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions Sprint-3/quote-generator/quotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,14 @@ const quotes = [
];

// call pickFromArray with the quotes array to check you get a random quote

function displayQuote() {
const picked = pickFromArray(quotes);
document.getElementById("quote").innerText = picked.quote;
document.getElementById("author").innerText = picked.author;
}

document.addEventListener("DOMContentLoaded", () => {
displayQuote();
document.getElementById("new-quote").addEventListener("click", displayQuote);
});
14 changes: 13 additions & 1 deletion Sprint-3/quote-generator/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
/** Write your CSS in here **/

h1, p, button{
margin: 30px;
text-align: center;
}

#new-quote {
margin: 20px;
position: absolute;
left: 50%;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to center this button? It's not quite exactly centre, can you figure out how to fix that?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! The extra margin: 20px was fighting with the left: 50% transformation, throwing off the center alignment. I've stripped out the absolute positioning and refactored it using block margins (margin: 20px auto) to make it perfectly centered.

-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
Loading