我正在尝试制作一个固定在网页底部的固定导航栏,我想知道正确的代码是什么。
我尝试了以下内容; 使用“fixed”类在css文件中格式如下,“button-navbar”类的格式为:
div.fixed {
position: fixed;
bottom: 0;
right: 0;
}
.button-navbar {
background-color: white;
border: 2px solid #ffb90f;
width: 90px;
height: 40px;
color: black;
display: table-cell;
margin: 15px;
vertical-align: middle;
text-align: center;
text-decoration: none;
border-radius: 8px;
line-height: 30px;
font-size: 20px;
font-family: 'Roboto', sans-serif;
-webkit-transition-duration: 0.4s; /* Safari */
-webkit-transition: 0.4s; /*Safari*/
transition: 0.4s;
transition-duration: 0.4s;
}
<div class="fixed">
<a href="homepage.php" class="button-navbar">Back to dashboard</a> <br>
<a href="IntroductionQuiz.php" class="button-navbar"> Retake Quiz</a>
</div>
答案 0 :(得分:0)
删除<br>
并将display: table-cell;
更改为display: inline-block;
如果你想div.fixed为全宽,那么你需要left: 0;
。这使按钮居中。
div.fixed {
position: fixed;
bottom: 0;
right: 0;}
.button-navbar {
background-color: white;
border: 2px solid #ffb90f;
width: 90px;
height: 40px;
color: black;
display: inline-block;
margin: 15px;
vertical-align: middle;
text-align: center;
text-decoration: none;
border-radius: 8px;
line-height: 30px;
font-size: 20px;
font-family: 'Roboto', sans-serif;
-webkit-transition-duration: 0.4s; /* Safari */
-webkit-transition: 0.4s; /*Safari*/
transition: 0.4s;
transition-duration: 0.4s;
&#13;
<div class="fixed">
<a href="homepage.php" class="button-navbar">Back to dashboard</a>
<a href="IntroductionQuiz.php" class="button-navbar"> Retake Quiz</a>
</div>
&#13;