如何将表单与按钮内联对齐?

的HTML

<a href='games'><button><i class='fa fa-gamepad'></i></button></a>
<a href='settings'><button><i class='glyphicon glyphicon-cog'></i></button></a>
<form action='../assets/php/logout_php.php' method='POST'>
   <button id='odhlaseni' type='submit' name='submit'><i class='glyphicon glyphicon-off'></i></button>
</form>


的CSS

/*Just those buttons*/
div div button {
    margin-top: 3px;
    font-size: 17px;
    margin-right: 10px;
    display: inline !important;
    padding-bottom: 1px !important;
    border: 2px solid #474747;
    color: #474747;
    background-color: transparent;

    -webkit-transition: 0.5s;
    transition: 0.5s;
}

/*Hover for those buttons*/
div div button:hover {
  color: #f5f5f5;
  background-color: #474747;
}


我有这样的东西https://imgur.com/a/WjRGl 1 =菜单图标2 =游戏3 =设置4 =我的问题-注销按钮。我要做的就是将第四个按钮与第三个按钮对齐。我可以使用CSS margin-left和-top轻松地做到这一点,但是在移动设备上无法正确显示。然后,我尝试仅创建一个按钮(该按钮与数字2和3完全对齐),但是我在向我的logout.php文件发送ajax请求时遇到了问题。

最佳答案

将其包装在div中并显示为flex



/*Just those buttons*/
div div button {
    margin-top: 3px;
    font-size: 17px;
    margin-right: 10px;
    display: inline !important;
    padding-bottom: 1px !important;
    border: 2px solid #474747;
    color: #474747;
    background-color: transparent;

    -webkit-transition: 0.5s;
    transition: 0.5s;
}

/*Hover for those buttons*/
div div button:hover {
  color: #f5f5f5;
  background-color: #474747;
}

.wrap{
  display:flex;
  flex-flow:row;
}

<div class="wrap">
<a href='games'><button class='marginLeftGames'><i class='fa fa-gamepad'></i></button></a>
<a href='settings'><button><i class='glyphicon glyphicon-cog'></i></button></a>
<form action='../assets/php/logout_php.php' method='POST'>
   <button id='odhlaseni' type='submit' name='submit'><i class='glyphicon glyphicon-off'></i></button>
</form>
</div>

07-24 09:43
查看更多