简体   繁体   English

如何使右侧的滚动按钮不在表格中间?

[英]How can I make the scroll button on the right side not in the middle of table?

HTML Codes HTML 代码

<table id="container", cellspacing="0">
     <thead>
         <tr>
             <th>Commands</th>
             <th>Aliases</th>
             <th>Description</th>
         </tr>
     </thead>
     <tbody>
         <tr>
             <td>help</td>
             <td>Help</td>
             <td>List all available commands on AnVolt with description</td>
         </tr>
         <tr>
             <td>clean</td>
             <td>Purge</td>
             <td>Clean total messages in current channel</td>
         </tr>
         <tr>
             <td>userinfo</td>
             <td>Profile</td>
             <td>Gives you information about specific users, default is your profile</td>
         </tr>
         <tr>
             <td>serverinfo</td>
             <td>GuildInfo</td>
             <td>Gives you information about current server/guild, such a member count</td>
         </tr>
     </tbody>
 </table>

CSS Codes CSS 代码

table {
    border-collapse: collapse;
    box-sizing: border-box;
    box-shadow: 0 0 10px #000;
    text-align: left;
    overflow: hidden;
    width: 65%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    position: fixed;
    border-radius: 10px;
}

table thead {
    background-color: #000;
    color: #fff;
}

table th,
table td {
    padding: 16px 32px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 15px;
    font-weight: 700;
}

table tbody {
    display:block;
    height:100px;
    overflow:auto;
    float:right;
    width:100%;
}

Image related to the Table: Image .与表相关的图像:图像 The image shows that the scroll button is in the middle of the image but I want to make it on the right side, anyone can help me out?图像显示滚动按钮在图像中间,但我想使它在右侧,有人可以帮我吗?

Edit: I've been added my HTML Codes.编辑:我已经添加了我的 HTML 代码。 If there's any problem or any unnecessary codes, you can delete or edit the codes.如果有任何问题或任何不必要的代码,您可以删除或编辑代码。 Thanks!谢谢!

This way you can do it:这样你就可以做到:

<div class="table-responsive">
    <table class="table">
      <thead>
        <tr>
          <th scope="col">Command</th>
          <th scope="col">Status</th>
          <th scope="col">Description</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        <tr>
          <th scope="row">
            Command Text
          </th>
          <td scope="row">Yes</td>
          <td scope="row">Description Description Description Description Description Description Description
            Description Description Description Description Description</td>
        </tr>
        
      </tbody>
    </table>
  </div>
.table-responsive {
    border: 1px solid #D4D4D4;
    border-radius: 5px;
    vertical-align: middle !important;
    -webkit-box-shadow: rgb(0 0 0 / 10%) 0 2px 4px;
    -moz-box-shadow: rgb(0 0 0 / 10%) 0 2px 4px;
    box-shadow: rgb(0 0 0 / 10%) 0 2px 4px;
    height: 400px;
    overflow-y: auto;
    overflow-x: auto;
}
table {
    box-sizing: border-box;
    text-align: left;
    width: 100%;
    color: #212529;
    border: 1px solid #D4D4D4;
    caption-side: bottom;
    border-collapse: collapse;
    display: table;
    text-indent: initial;
    border-spacing: 2px;
}

table thead {
    position: sticky;
    top: 0px;
    z-index: 2;
    vertical-align: bottom;
}
table thead th{ 
    background-color: #2b2d3b;
    vertical-align: middle !important;
    color: #fff;
    font-weight: 500;
    font-size: 14px;
    line-height: 16px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    height: 42px;
    padding: 0.5rem 0.5rem;
 }
 table thead th:first-child {
    border-radius: 5px 0 0 0;
}
table thead th:last-child {
    border-radius: 0 5px 0 0;
}
table tbody {
    border-top: inherit !important;
    vertical-align: middle !important;
}
table tbody td, table tbody th{  
height: 46px;
padding: 0.5rem 0.5rem;
line-height: 36px;
padding-top: 5px;
padding-bottom: 5px;
background-color: #fff;
border-bottom-color: #D4D4D4;
vertical-align: middle !important;
color: #545454;
font-weight: 400;
font-size: 14px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
border-bottom: 1px solid #D4D4D4;
}

Or check in jsfiddle example link : https://jsfiddle.net/DeveloperSandip/5jhpv0xq/6/或查看 jsfiddle 示例链接: https ://jsfiddle.net/DeveloperSandip/5jhpv0xq/6/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我怎样才能让按钮向右移动,修复中间部分并使所有内容都可以调整大小 - How can I make button go right, fix middle section and make everything resizible 当滚动到达容器末尾时,如何使左/右按钮消失? - How can I make left/right button disappear when the scroll gets to the end of the container? 如何使页面右侧滚动而左侧不滚动? - How to make right side of page scroll and left side not? 如何将右侧的按钮放入 div 中? - How can I put a button to right side into the div? 如何将此按钮移动到我的div的右上角? - How can i move this button to the upper right side of my div? 如何在div的右侧制作悬停框? - How can I make hover box on the right side of my div? 如何使导航栏菜单选项在右侧移动? - How can i make the navbar menu options to move in the right side? 如何使滚动条自动位于内容的中心或右侧? - How can I make a scrollbar automatically be in the center or right side of content? 如何对这个 HTML 表的定位进行排序? - 我需要右侧的提交按钮,需要删除左侧的间距 - How can I sort the positioning of this HTML Table? - I need the Submit button on the right hand side and need to remove the spacing on the left 如何将桌子放在屏幕的右侧? - how can i put the table on the right side on the screen?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM