溢出-X不显示滚动条

问题描述 投票:0回答:1

我有我用来保存表的容器,和我想申请溢出-x属性,但有什么不妥的地方。我有一个工作codepen,我将在稍后发布,但问题是,它并没有去响应。当视口关闭就可以了,它只是“大棒”(我真的不能解释它比这更好的Codepen显示它虽然)。下面是代码:

<section class='main-container'>
    <h6>Users</h6>

    <table>

        <thead>
            <tr>
                <th class='name'>Name</th>
                <th class='email'>Email</th>
                <th class='role'>Role</th>
                <th class='status'>Status</th>
                <th class='alerts'>Alerts/Actions</th>
                <th class='delete'></th>
            </tr>
        </thead>

        <tbody>
    <tr>
      <td class='name'>Joe Bob</td>
      <td class='email'>[email protected]</td>
      <td class='role'>This is the role</td>
      <td class='status'>Approved</td>
      <td class='alerts'>There's an alert</td>
      <td class='delete'></td>
    </tr>
    <tr>
      <td class='name'>Joe Bob</td>
      <td class='email'>[email protected]</td>
      <td class='role'>This is the role</td>
      <td class='status'>Approved</td>
      <td class='alerts'>There's an alert</td>
      <td class='delete'></td>
    </tr>
    <tr>
      <td class='name'>Joe Bob</td>
      <td class='email'>[email protected]</td>
      <td class='role'>This is the role</td>
      <td class='status'>Approved</td>
      <td class='alerts'>There's an alert</td>
      <td class='delete'></td>
    </tr>
    <tr>
      <td class='name'>Joe Bob</td>
      <td class='email'>[email protected]</td>
      <td class='role'>This is the role</td>
      <td class='status'>Approved</td>
      <td class='alerts'>There's an alert</td>
      <td class='delete'></td>
    </tr>
    <tr>
      <td class='name'>Joe Bob</td>
      <td class='email'>[email protected]</td>
      <td class='role'>This is the role</td>
      <td class='status'>Approved</td>
      <td class='alerts'>There's an alert</td>
      <td class='delete'></td>
    </tr>

        </tbody>

    </table>

</section>

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scroll-behavior: smooth;
    border: none;
    color: #425563;
    -webkit-tap-highlight-color: transparent;
}

.main-container {

    --away-left: 20px;
  --border-radius: 2px;
  --shine-brand-blue: #425563;
  --shine-gray-two: #eceeef;
  --shine-gray-one: #f1f2f3;

  display: flex;
    width: calc(100% - 80px);
  max-width: 600px;
    margin-right: 40px;
    margin-left: 40px;
    margin-top: 40px;
    background-color: #fff;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.2);
    flex-flow: column nowrap;
    justify-content: flex-start;
    overflow-x: scroll;

    h6 {
        font-size: 16px;
        height: 50px;
        font-family: var(--main-font);
        color: var(--shine-brand-blue);
        line-height: 40px;
        width: 100%;
        border-bottom: 1px solid var(--shine-gray-two);
        padding-left: var(--away-left);
        display: flex;
        align-items: center;
        justify-content: flex-start;
    }

    table {
        margin: 25px 0;
        width: calc(100% - 40px);
        margin-left: 20px;
        margin-right: 20px;
        border-collapse: collapse;

        th, td {
            text-align: left;
            border-bottom: 1px solid #e0e3e5;
            &.name {min-width: 149px;}
            &.email {min-width: 230px;}
            &.role {min-width: 148px;}
            &.status {min-width: 82px;}
            &.alerts {min-width: 195px;}
            &.delete {min-width: 15px;}
        }

        th {
            font-size: 10px;
            font-weight: 500;
            color: #7d8d9a;
            text-transform: uppercase;
        }

        td {  
            font-size: 12px;
            font-weight: 500;
            line-height: 50px;
            color: var(--shine-brand-blue);

            select {
                height: 40px;
                width: 90%;
                min-width: 140px;
                border-radius: var(--border-radius);
                background-color: var(--shine-gray-one);
                cursor: pointer;
            }

        }

        tbody tr { 
            transition: all .3s;

            &:hover { background-color: #f5f6f7; }

        }

    }
}

main.next-to-aside {
    position: absolute;
    top: 60px;
    right: 0px;
}

我怎样才能获得表行动响应,而不只是“坚持”喜欢怎么做这个Codepen?:https://codepen.io/adammcgurk/pen/aXyZxm

html css html5 css3 responsive-design
1个回答
0
投票

所以我其实是有包装的表格中div。仅使用section是行不通的,因为它包含的不仅仅是table更多的孩子。所以样板代码是这样的:

<style>
    .responsive-table {
        overflow-x: scroll;
    }
</style>

<section class='main-container'>
    <!-- other content -->
    <div class='responsive-table'>
        <table>
             <!-- table content -->
        </table>
    </div>
</section>
© www.soinside.com 2019 - 2024. All rights reserved.