I have two buttons refusing to align, as shown in the screenshots. In the last screenshot, you can see the Chrome inspect
my CSS & HTML is provided below
I have tried putting them in a container and setting the height of the container but that didn’t work
body {
background-color: #6A6E64;
font-family: Helvetica, Arial, sans-serif;
color: white;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.question-container {
margin-bottom: 1rem;
}
.navigation {
display: flex;
justify-content: space-between;
}
button {
background-color: #393D32;
color: white;
border: none;
border-radius: 25px;
padding: 0.5rem 1rem;
cursor: pointer;
font-size: 1rem;
transition: background-color 0.3s ease, transform 0.3s ease;
}
button:hover {
background-color: #2B2E23;
transform: scale(1.05);
}
button.share {
margin-top: 1rem;
display: none;
/* hide the share button by default */
}
.copy-message {
font-size: 0.9rem;
margin-top: 0.5rem;
}
.start-screen {
text-align: center;
}
.question-container,
.navigation {
display: none;
}
.option {
display: block;
margin-bottom: 1rem;
}
.options-row {
display: flex;
justify-content: space-between;
margin-bottom: 1rem;
}
.option {
flex: 1;
margin: 0 0.5rem;
box-sizing: border-box;
text-align: center;
padding: 10px;
}
.result-content {
text-align: center;
margin-bottom: 1rem;
}
.results-container {
display: none;
justify-content: center;
align-items: center;
flex-direction: column;
margin-top: 20px;
text-align: center;
}
.hidden {
display: none;
}
button.previous {
display: flex;
}
.restart-quiz {
display: none;
/* hide the restart button by default */
}
/* show the share and restart buttons only on the results page */
.results-container .share {
display: inline-block;
}
.results-container .restart-quiz {
display: inline-block;
}
.button-container {
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
button.restart-quiz,
button.share {
min-height: 40px;
/* You can adjust the value according to your desired height */
display: inline-flex;
align-items: center;
justify-content: center;
line-height: 1.2;
/* Add this line */
}
/* Hide the share and restart buttons on the question pages */
.navigation {
display: none;
}
/* Show the share and restart buttons on the results page */
.results-container .share-container {
display: flex;
}
.results-container button.restart-quiz,
.results-container button.share {
display: inline-block;
}
button {
font-size: 1rem;
/* Adjust the font-size of all buttons */
padding: 0.5rem 1rem;
/* Adjust the padding of all buttons */
}
button.restart-quiz,
button.share {
font-size: 1rem;
/* Adjust the font-size of restart and share buttons to match other buttons */
padding: 0.5rem 1rem;
/* Adjust the padding of restart and share buttons to match other buttons */
}
<div class="quiz-container">
<!-- Add this new div inside the quiz-container div -->
<div class="start-screen">
<h1>Find Your Learning Style</h1>
<button class="start-quiz">Start Quiz</button>
</div>
<div class="question-container">
<!-- Question template -->
</div>
<div class="navigation">
<button class="previous">Previous Question</button>
</div>
</div>
<div class="results-container">
<h2>Your learning style is:</h2>
<h1 class="results-container-text"></h1>
<div class="percentage-container">
<!-- Percentage results template -->
</div>
<div class="button-container">
<button class="restart-quiz">Restart Quiz</button>
<button class="share">Share Quiz</button>
<div class="copy-message hidden">Quiz URL copied to clipboard</div>
</div>
</div>
3
Answers
You’ve added a margin to the Share-Button:
There is a margin-top of 16px on the second button. Removing it will fix the problem.