我有两个按钮拒绝对齐,如屏幕截图所示。在最后一个屏幕截图中,您可以看到Chrome检查
https://prnt.sc/d2tazgP5Beyb
https://prnt.sc/0rIx25Zx5Ko5
https://prnt.sc/VcvpkVRC54y0
我的CSS和HTML如下所示
我试过把它们放进一个容器里,并设置容器的高度,但那不起作用
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>
4条答案
按热度按时间tgabmvqs1#
我很难阅读CSS,但我只是删除了.button -container中的显示Flex。它做的工作。
.button-container { gap:10px }
我希望它帮助
kdfy810k2#
您已向共享按钮添加了边距:
9cbw7uwe3#
第二个按钮上有一个16px的边距。删除它将解决问题。
a9wyjsp74#