当前位置: 首页 > 知识库问答 >
问题:

尝试将2个响应表居中放在页面中心

琴镜
2023-03-14

由于某些原因,这2个表不会居中,我尝试了引导容器类,尝试了边距0自动。但他们不会打中间的,知道吗?

我希望两个表居中,并在中间水平显示并排。

在这里的codepen上:在这里输入链接描述http://codepen.io/satearn/pen/ybvxlr

  .z
 {position :absolute ;
 top:50%;
 left:50%;
  transform :translate(-50%,-50%) ;}

共有2个答案

鲁鹤轩
2023-03-14

像这样?我用了bootstrap。为了简单起见,我减少了表中的数据

null

html {
  background-color: #3e94ec;
}


/*** Table Styles **/

.table-fill {
  border-radius: 3px;
  border-collapse: collapse;
  padding: 5px;
}

th {
  color: #D5DDE5;
  background: #1b1e24;
  border-bottom: 4px solid #9ea7af;
  border-right: 1px solid #343a45;
  font-size: 23px;
  font-weight: 100;
  padding: 24px;
  text-align: left;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
  vertical-align: middle;
}

th:first-child {
  border-top-left-radius: 3px;
}

th:last-child {
  border-top-right-radius: 3px;
  border-right: none;
}

tr {
  border-top: 1px solid #C1C3D1;
  border-bottom-: 1px solid #C1C3D1;
  color: #666B85;
  font-size: 16px;
  font-weight: normal;
  text-shadow: 0 1px 1px rgba(256, 256, 256, 0.1);
}

tr:hover td {
  background: #4E5066;
  color: #FFFFFF;
  border-top: 1px solid #22262e;
  border-bottom: 1px solid #22262e;
}

tr:first-child {
  border-top: none;
}

tr:last-child {
  border-bottom: none;
}

tr:nth-child(odd) td {
  background: #EBEBEB;
}

tr:nth-child(odd):hover td {
  background: #4E5066;
}

tr:last-child td:first-child {
  border-bottom-left-radius: 3px;
}

tr:last-child td:last-child {
  border-bottom-right-radius: 3px;
}

td {
  background: #FFFFFF;
  padding: 20px;
  text-align: left;
  vertical-align: middle;
  font-weight: 300;
  font-size: 18px;
  text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.1);
  border-right: 1px solid #C1C3D1;
}

td:last-child {
  border-right: 0px;
}

th.text-left {
  text-align: left;
}

th.text-center {
  text-align: center;
}

th.text-right {
  text-align: right;
}

td.text-left {
  text-align: left;
}

td.text-center {
  text-align: center;
}

td.text-right {
  text-align: right;
}

.middlepage {
  margin: 0 auto;
}

#outer-cont {
  text-align: center;
}

#target-element-to-center {
  display: inline-block;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
  <div class="row">
    <table class="table-fill col-xs-6" id="a">
      <thead>
        <tr>
          <th class="text-center" colspan="2">Month</th>
        </tr>
      </thead>
      <tbody class="table-hover">
        <tr>
          <td class="text-left">January</td>
          <td class="text-left">$ 50,000.00</td>
        </tr>
      </tbody>
    </table>
    <table class="table-fill col-xs-6" id="a">
      <thead>
        <tr>
          <th class="text-center" colspan="2">Strategies</th>
        </tr>
      </thead>
      <tbody class="table-hover">
        <tr>
          <td class="text-left">January</td>
          <td class="text-left">$ 50,000.00</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
萧宣
2023-03-14

要居中对齐,只需移除宽度:100%;从下面的CSS代码。

.table-fill {
    background: white;
    border-radius:3px;
    border-collapse: collapse;
    height: 320px;
    margin: auto;
    max-width: 300px;
    padding:5px;
    width: 100%;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.1);
    animation: float 5s infinite;
  }
 类似资料:
  • 问题内容: 我需要使用引导程序通过将div定位在页面中心来创建响应页面,如下面提到的布局。 问题答案: Bootstrap 4的更新 使用flex-box简化垂直网格对齐 Bootstrap 3的解决方案 这是一个以所有屏幕尺寸为中心的水平和垂直div的简单示例。

  • 我想找到一种从USSD代码中得到响应的方法。 我正在使用索尼爱立信Xperia Ray,我只在手机屏幕上找到了弹出的消息。我没有从后台得到任何响应代码。

  • 问题内容: 我正在使用NetBeans GUI构建器来处理我的布局(我对LayoutManagers很糟糕),并试图放置一个简单的JLabel,以使其始终(水平)居于其父JPanel内部。理想情况下,即使调整了JPanel的大小,这也将保持正确,但是,如果这是一个疯狂的编码,比第一次创建JPanel时居中就足够了。 我自己尝试处理布局已经很糟糕了,但是由于NetBeans GUI Builder自

  • 问题内容: 在页面上垂直和水平居中放置元素的最佳方法? 我知道这将以水平为中心,但是垂直进行的最佳方法是什么? 问题答案: 该演示的主要技巧是元素的正常流动是从上到下,因此将其设置为零。然而,绝对定位的元件作用为自由空间分布是相同的,并且类似地可以垂直在指定为中心并且(不IE7工作)。 此技巧适用于的任何大小div。

  • 我不太了解React Material UI网格系统。如果我想使用表单组件进行登录,那么在所有设备(移动设备和桌面设备)上将其置于屏幕中心的最简单方法是什么?

  • 问题内容: 我正在尝试在屏幕的正中央为我的网站中心的目标网页创建一个div,但是它不起作用。 这是我的代码 CSS: HTML: 谢谢。 问题答案: 注意: 如果您尝试将div水平和垂直居中放置,建议您查看flexbox。您仍然需要提供后备支持,但是flexbox是未来,这太神奇了。 更新: 现在所有现代浏览器都支持flexbox 。 首先,您需要给div静态宽度和高度。 其次,你必须设置和那么你