【发布时间】:2021-07-20 23:44:00
【问题描述】:
我是编程新手。我正在尝试将顶部的多个按钮对齐到页面的中心,我尝试过 text-align 和 margin: 0;这些都没有奏效。现在,我已将按钮居中,但按钮位于彼此下方。有什么解决办法吗?我究竟如何居中?我正在使用烧瓶。
CSS:
#navBar {
border: 2px solid black;
margin: auto;
height: 30px;
width: 43%;
padding: 5px;
}
#searchInput {
position: absolute;
top: 20px;
right: 0;
height: 35px;
width: 185px;
border-radius: 10px;
font-family: 'Roboto', sans-serif;
font-size: 20px;
outline: none;
}
/*The buttons that I want centered*/
#dealsButton, #burgersButton, #drinksButton, #sidesButton, #dessertsButton{
border: none;
outline: none;
background-color: transparent;
color: #606060;
top: 30px;
font-size: 27px;
font-family: 'Roboto', sans-serif;
width: 40%;
margin-left: 30%;
margin-right: 30%;
}
这是图片。边框与中心对齐,并且应该包含彼此相邻的按钮作为导航栏。我也希望每个按钮都居中。我希望所有按钮都集中在同一个位置,然后我将每个按钮分别向左和向右移动。但是,如果您知道一种将所有这些并排居中的方法,请告诉我。
【问题讨论】: