html - Div 对齐不起作用

标签 html css

我有一个主 div PricingBar 里面有 3 个子 div。同时保持 PricingBar height: auto; 子 div 显示在 PricingBar

之外

enter image description here

这里绿色边框是PricingBar

选项A、选项B、选项C是子div的

html代码:

<div id="PriceBar">
   <div id="OptionA">
     <h2>Option A</h2>
     <table class="optiontable">
        <tr><td class="column1">Setup Fee: </td><td><span>&#36;250.00</span> (includes 10 customized apparel pieces)</td></tr>
         <tr><td class="column1">Monthly Fee:</td><td><span>&#36;25.00</span></td></tr>
     </table>
   </div>
   <div id="OptionB">
     <h2>Option B</h2>
     <table class="optiontable">
        <tr><td class="column1">Setup Fee:</td><td><span>&#36;99.00</span> (includes 10 customized apparel pieces)</td></tr>
        <tr><td class="column1">Monthly Fee:</td><td><span>&#36;40.00</span></td></tr>
      </table>
   </div>
   <div id="OptionC">
     <h2>Option C</h2>
     <table class="optiontable">
          <tr><td class="column1">Setup Fee:</td><td>Refund</td></tr>
          <tr><td class="column1">Monthly Fee:</td><td>Refunded</td></tr>
      </table>
   </div>
</div>

CSS 代码:

#PriceBar{
    width: 1004px;
    position: relative;
    height:auto;
    padding:10px;
    border: 2px solid green;
    background:#930;
    float: inherit;

}

#OptionA, #OptionB, #OptionC{
    margin: 10px 20px;
    padding: 5px;
    float: left;
    width: 283px;
    height: auto;
    background-color: #FFF;
    -webkit-border-radius:15px;
    -mox-border-radius:15px;
    border-radius:15px;
}

#OptionA h2, #OptionB h2, #OptionC h2{
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    color: #006A8E;
}
table.optiontable tr td{
    padding: 10px 5px;
    color: #B9B196;
}
td.column1{
    width:100px;
    vertical-align: top;
    font-size: 12px;
    font-weight: bold;
    font-family: Verdana, Geneva, sans-serif;
    color: #252525 !important;
}
table.optiontable tr td span{
    font-weight: bold;
}

最佳答案

由于所有 div 元素都是 float 的,“红色条”基本上“忘记”了它是它们的容器。只需添加 overflow:auto; 即可记住。我也倾向于为 IE 添加 zoom:1

关于html - Div 对齐不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11536142/

相关文章:

contenteditable - 使 contenteditable div 中的 span 不可编辑

html - 在 HTML/CSS 中实现 "Named Theorem"环境

html - 卡片组件内的 Bootstrap 4 按钮具有单击事件

html - ASP :linkbutton after asp:linkbutton not to jump lines

html - 调整大小时使 Nav 低于 H1

html - 如何仅使用 HTML/CSS/SVG 使 IE 中的文本大小和行为与其他浏览器相匹配?

php - 如何设置 php 回显表的样式

javascript - Css 类激活

css - Tailwind CSS 响应式断点在 Vue 中不起作用

javascript - 在 Backbone 的所有路由中默认显示一个 View