javascript - 均匀分布div中的按钮

标签 javascript jquery html css

我有以下代码(JSFiddle):

HTML:

<div id="content">
  <div id="mainBox" class="textBox">
    <div id="mainMenuBar">
      <button class="jqueryUIButton">New Diagnosis</button>
      <button class="jqueryUIButton">My Diagnosises</button>
      <button class="jqueryUIButton">My Account</button>
    </div>
  </div>
</div>

CSS:

#mainMenuBar {
    background: linear-gradient(to bottom right, #30273a, #8d78a5);
    padding: 5px;
    -webkit-border-radius: 0px;
    -moz-border-radius: 0px;
    border-radius: 0px;
    resize: none;
    border:1px solid #30273a;
    box-shadow: 0 0 10px #8d78a5;
    border-radius: 15px 15px 15px 15px;
}

#content {
    margin: 0 auto;
    margin-top: 100px; // former 250px
    padding: 0;
    width: 750px;
    max-width: 80%;
    padding-bottom: 40px;
    text-align: center;
}

JS:

$( ".jqueryUIButton" ).button();

现在这三个按钮位于 DIV-Box 的水平中心。但我希望它们均匀分布在整个宽度上。我该怎么做?

希望得到任何建议。谢谢!

最佳答案

只需使用 the flexbox model :

display: flex;
justify-content: space-around;

您还可以使用 space-between,并使用边距和填充来获得微调的外观。

Modified fiddle

关于javascript - 均匀分布div中的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36892039/

相关文章:

javascript - 在我的 Express Controller 中进行 axios 调用,如何返回状态?

javascript - NuxtJS 无法使用变量加载多个 CSS 表

javascript - Handlebars 入门

javascript - 两端分割 url

jquery - 从 html 数据中选中的 jsTree 复选框

javascript - JS 和 PHP 中的正则表达式不同

javascript - 如何创建时间选择器下拉菜单?

php - 提供生成的文件以供从 jQuery post 下载

javascript - 将旧值作为 "ghost"thumb 添加到 &lt;input type ="range"> Slider

javascript - 获取文档未定义,来自 document.getElementById