I have multiple coloumns in the table, the header of the table is fixed. Some of the columns in the header (last coloumns) are not listed inside the panel. Please see the attached demo here
When the number of coloumns are more horizontal scrollbar is appearing, but issue is headers are not scrolling and listed outside the panel. Please find the demo here.
html code:
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<div id="myModal" class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body" id="modal-body">
<table class="table" border="1">
<thead>
<tr>
<td>Namffffffffffffffffffffffffe</td>
<td>phone</td>
<td>Address</td>
<td>Street</td>
<td>City</td>
<td>Pin</td>
<td>Comments</td>
<td>info</td>
<td>Amount</td>
<td>percentage</td>
<td>total</td>
</tr>
</thead>
<tbody>
<tr>
<td>AAAAdddddddddddddddddddddddd</td>
<td>323232</td>
<td>BBBBB</td>
<td>aasdd</td>
<td>dfgdfg</td>
<td>1234</td>
<td>adsadsadashgdhggdhsdfsdgfghsdgfsgdfhsdhfgsdfgsdhfgsdgfsdfg</td>
<td>adasdsadasd</td>
<td>12312</td>
<td>4</td>
<td>555</td>
</tr>
<tr>
<td>AAAAdddddddddddddddddddddddd</td>
<td>323232</td>
<td>BBBBB</td>
<td>aasdd</td>
<td>dfgdfg</td>
<td>1234</td>
<td>adsadsadashgdhggdhsdfsdgfghsdgfsgdfhsdhfgsdfgsdhfgsdgfsdfg</td>
<td>adasdsadasd</td>
<td>12312</td>
<td>4</td>
<td>555</td>
</tr>
<tr>
<td>AAAAdddddddddddddddddddddddd</td>
<td>323232</td>
<td>BBBBB</td>
<td>aasdd</td>
<td>dfgdfg</td>
<td>1234</td>
<td>adsadsadashgdhggdhsdfsdgfghsdgfsgdfhsdhfgsdfgsdhfgsdgfsdfg</td>
<td>adasdsadasd</td>
<td>12312</td>
<td>4</td>
<td>555</td>
</tr>
<tr>
<td>AAAAdddddddddddddddddddddddd</td>
<td>323232</td>
<td>BBBBB</td>
<td>aasdd</td>
<td>dfgdfg</td>
<td>1234</td>
<td>adsadsadashgdhggdhsdfsdgfghsdgfsgdfhsdhfgsdfgsdhfgsdgfsdfg</td>
<td>adasdsadasd</td>
<td>12312</td>
<td>4</td>
<td>555</td>
</tr>
<tr>
<td>AAAAdddddddddddddddddddddddd</td>
<td>323232</td>
<td>BBBBB</td>
<td>aasdd</td>
<td>dfgdfg</td>
<td>1234</td>
<td>adsadsadashgdhggdhsdfsdgfghsdgfsgdfhsdhfgsdfgsdhfgsdgfsdfg</td>
<td>adasdsadasd</td>
<td>12312</td>
<td>4</td>
<td>555</td>
</tr>
<tr>
<td>AAAAdddddddddddddddddddddddd</td>
<td>323232</td>
<td>BBBBB</td>
<td>aasdd</td>
<td>dfgdfg</td>
<td>1234</td>
<td>adsadsadashgdhggdhsdfsdgfghsdgfsgdfhsdhfgsdfgsdhfgsdgfsdfg</td>
<td>adasdsadasd</td>
<td>12312</td>
<td>4</td>
<td>555</td>
</tr> </tbody>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
css code:
.modal-body {
overflow-y: auto;
}
tbody {
display:block;
height:200px;
overflow:auto;
}
thead, tbody tr {
display:table;
width:100%;
table-layout:fixed;
}
thead {
width: calc( 100% - 1em )
}
table {border-collapse:collapse; table-layout:fixed; width:310px;}
table td {border:solid 1px #fab; width:100px; word-wrap:break-word;}
Edited your css code. Hope this helps
.modal-body {
overflow-y: auto;
}
tbody {
}
thead, tbody tr {
}
thead {
width: calc( 100% - 1em )
}
table {border-collapse:collapse; height:300px;overflow: auto;
display: block;}
table td {border:solid 1px #fab; width:100px; word-wrap:break-word;}
Related
I have the index list working as intended but I still have problems with the table and footer.
Known problems:
table header doesn't stay fixed when I scroll
table height is not responsive and overflows into the footer
table x scroll bar is at the bottom of the page and is not at the bottom of the table view. Intended functionality is the same as the code snippets on this site.
footer margin is not enforced on mobile.
footer height causing large white space at the bottom of the div. Most likely due to height property resizing the div.
Below is the intended design.
html {
font-family: Arial, Helvetica, sans-serif;
}
body {
/* padding-bottom: 80px; */
/* height: 100% */
}
main {
/* display: flex; */
/* flex-direction: column; */
/* flex-grow: 1; */
margin-bottom: 80px;
/* overflow: hidden; */
}
footer {
margin-top: 80px;
height: 10vh;
}
.indices-container {
margin: auto;
}
.sp500-table-container {
height: 70vh;
width: 100vw;
overflow: auto;
/* overflow-x: scroll; */
/* overflow-y: scroll; */
position: relative;
/* padding-bottom: 80px; */
/* flex: 1; */
/* margin-bottom: 16px; */
}
<!doctype html>
<html style="font-family: Arial" lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="/static/style.css">
<title></title>
</head>
<body class="bg-dark text-white container-fluid">
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js#2.8.0"></script>
<script src="https://kit.fontawesome.com/f149088b14.js" crossorigin="anonymous"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/hammerjs#2.0.8"></script> -->
<!-- <script src="path/to/chartjs-plugin-zoom/dist/chartjs-plugin-zoom.min.js"></script> -->
<header class="navbar navbar-expand-sm navbar-dark sticky-top bg-dark">
<a class="navbar-brand" href="/">Paper Money</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggler" aria-controls="navbarToggler" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarToggler">
<div class="navbar-nav ml-auto">
<a class="nav-link text-nowrap" href="/auth/register">Register</a>
<a class="nav-link text-nowrap" href="/auth/login">Log In</a>
</div>
</div>
<form id= "searchInput"class="form-inline w-100" action="/company_overview" method="get">
<input class="form-control form-control-dark w-100" name="q" type="search" placeholder="Search by ticker symbol..." aria-label="Search">
</form>
</header>
<main role="main" class="container-fluid">
<div class="indices-container">
<div class="row text-center mx-1">
<div class="col-4 px-1">
<div class="row mx-0">
<div class="col-12 col-md-6 px-0">
VOO<br>
<span class="d-none d-lg-block">$431.05</span>
<span class="d-none d-lg-block">-0.19% 1-Day</span>
26.69% YTD
</div>
<div class="col-12 col-md-6 px-0">
BND<br>
<span class="d-none d-lg-block">$85.23</span>
<span class="d-none d-lg-block">0.21% 1-Day</span>
-1.93% YTD
</div>
</div>
</div>
<div class="col-4 px-1">
<div class="row mx-0">
<div class="col-12 col-md-6 px-0">
VXUS<br>
<span class="d-none d-lg-block">$65.61</span>
<span class="d-none d-lg-block">-0.23% 1-Day</span>
10.80% YTD
</div>
<div class="col-12 col-md-6 px-0">
VEA<br>
<span class="d-none d-lg-block">$51.99</span>
<span class="d-none d-lg-block">-0.76% 1-Day</span>
11.96% YTD
</div>
</div>
</div>
<div class="col-4 px-1">
<div class="row mx-0">
<div class="col-12 col-md-6 px-0">
VWO<br>
<span class="d-none d-lg-block">$51.06</span>
<span class="d-none d-lg-block">-0.18% 1-Day</span>
3.54% YTD
</div>
<div class="col-12 col-md-6 px-0">
BNDX<br>
<span class="d-none d-lg-block">$56.95</span>
<span class="d-none d-lg-block">0.16% 1-Day</span>
-2.10% YTD
</div>
</div>
</div>
</div>
</div>
<div class="sp500-table-container">
<div class="table-responsive" id="sp500Table">
<table class="table table-light table-striped table-sm header-fixed" id="sp500Table">
<thead class="thead-light">
<tr>
<th>#</th>
<th>Symbol</th>
<th>Security</th>
<th>SEC Filings</th>
<th>Sector</th>
<th>Sub Sector</th>
<th>Headquarters</th>
<th>Date First Added</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>MMM</td>
<td>3M</td>
<td>link</td>
<td>Industrials</td>
<td>Industrial Conglomerates</td>
<td>Saint Paul, Minnesota</td>
<td>1976-08-09</td>
</tr>
<tr>
<td>2</td>
<td>ABT</td>
<td>Abbott Laboratories</td>
<td>link</td>
<td>Health Care</td>
<td>Health Care Equipment</td>
<td>North Chicago, Illinois</td>
<td>1964-03-31</td>
</tr>
<tr>
<td>3</td>
<td>ABBV</td>
<td>AbbVie</td>
<td>link</td>
<td>Health Care</td>
<td>Pharmaceuticals</td>
<td>North Chicago, Illinois</td>
<td>2012-12-31</td>
</tr>
<tr>
<td>4</td>
<td>ABMD</td>
<td>Abiomed</td>
<td>link</td>
<td>Health Care</td>
<td>Health Care Equipment</td>
<td>Danvers, Massachusetts</td>
<td>2018-05-31</td>
</tr>
<tr>
<td>5</td>
<td>ACN</td>
<td>Accenture</td>
<td>link</td>
<td>Information Technology</td>
<td>IT Consulting & Other Services</td>
<td>Dublin, Ireland</td>
<td>2011-07-06</td>
</tr>
<tr>
<td>6</td>
<td>ATVI</td>
<td>Activision Blizzard</td>
<td>link</td>
<td>Communication Services</td>
<td>Interactive Home Entertainment</td>
<td>Santa Monica, California</td>
<td>2015-08-31</td>
</tr>
<tr>
<td>7</td>
<td>ADBE</td>
<td>Adobe</td>
<td>link</td>
<td>Information Technology</td>
<td>Application Software</td>
<td>San Jose, California</td>
<td>1997-05-05</td>
</tr>
<tr>
<td>8</td>
<td>AMD</td>
<td>Advanced Micro Devices</td>
<td>link</td>
<td>Information Technology</td>
<td>Semiconductors</td>
<td>Santa Clara, California</td>
<td>None</td>
</tr>
<tr>
<td>9</td>
<td>AAP</td>
<td>Advance Auto Parts</td>
<td>link</td>
<td>Consumer Discretionary</td>
<td>Automotive Retail</td>
<td>Raleigh, North Carolina</td>
<td>2015-07-09</td>
</tr>
<tr>
<td>10</td>
<td>AES</td>
<td>AES Corp</td>
<td>link</td>
<td>Utilities</td>
<td>Independent Power Producers & Energy Traders</td>
<td>Arlington, Virginia</td>
<td>1998-10-02</td>
</tr>
<tr>
<td>11</td>
<td>AFL</td>
<td>Aflac</td>
<td>link</td>
<td>Financials</td>
<td>Life & Health Insurance</td>
<td>Columbus, Georgia</td>
<td>1999-05-28</td>
</tr>
<tr>
<td>12</td>
<td>A</td>
<td>Agilent Technologies</td>
<td>link</td>
<td>Health Care</td>
<td>Health Care Equipment</td>
<td>Santa Clara, California</td>
<td>2000-06-05</td>
</tr>
<tr>
<td>13</td>
<td>APD</td>
<td>Air Products & Chemicals</td>
<td>link</td>
<td>Materials</td>
<td>Industrial Gases</td>
<td>Allentown, Pennsylvania</td>
<td>1985-04-30</td>
</tr>
<tr>
<td>14</td>
<td>AKAM</td>
<td>Akamai Technologies</td>
<td>link</td>
<td>Information Technology</td>
<td>Internet Services & Infrastructure</td>
<td>Cambridge, Massachusetts</td>
<td>2007-07-12</td>
</tr>
<tr>
<td>15</td>
<td>ALK</td>
<td>Alaska Air Group</td>
<td>link</td>
<td>Industrials</td>
<td>Airlines</td>
<td>Seattle, Washington</td>
<td>2016-05-13</td>
</tr>
<tr>
<td>16</td>
<td>ALB</td>
<td>Albemarle Corporation</td>
<td>link</td>
<td>Materials</td>
<td>Specialty Chemicals</td>
<td>Charlotte, North Carolina</td>
<td>2016-07-01</td>
</tr>
<tr>
<td>17</td>
<td>ARE</td>
<td>Alexandria Real Estate Equities</td>
<td>link</td>
<td>Real Estate</td>
<td>Office REITs</td>
<td>Pasadena, California</td>
<td>2017-03-20</td>
</tr>
<tr>
<td>18</td>
<td>ALGN</td>
<td>Align Technology</td>
<td>link</td>
<td>Health Care</td>
<td>Health Care Supplies</td>
<td>San Jose, California</td>
<td>2017-06-19</td>
</tr>
<tr>
<td>19</td>
<td>ALLE</td>
<td>Allegion</td>
<td>link</td>
<td>Industrials</td>
<td>Building Products</td>
<td>New York City, New York</td>
<td>2013-12-02</td>
</tr>
<tr>
<td>20</td>
<td>LNT</td>
<td>Alliant Energy</td>
<td>link</td>
<td>Utilities</td>
<td>Electric Utilities</td>
<td>Madison, Wisconsin</td>
<td>2016-07-01</td>
</tr>
<tr>
<td>21</td>
<td>ALL</td>
<td>Allstate Corp</td>
<td>link</td>
<td>Financials</td>
<td>Property & Casualty Insurance</td>
<td>Northfield Township, Illinois</td>
<td>1995-07-13</td>
</tr>
<tr>
<td>22</td>
<td>GOOGL</td>
<td>Alphabet</td>
<td>link</td>
<td>Communication Services</td>
<td>Interactive Media & Services</td>
<td>Mountain View, California</td>
<td>2014-04-03</td>
</tr>
<tr>
<td>23</td>
<td>GOOG</td>
<td>Alphabet</td>
<td>link</td>
<td>Communication Services</td>
<td>Interactive Media & Services</td>
<td>Mountain View, California</td>
<td>2006-04-03</td>
</tr>
<tr>
<td>24</td>
<td>MO</td>
<td>Altria Group</td>
<td>link</td>
<td>Consumer Staples</td>
<td>Tobacco</td>
<td>Richmond, Virginia</td>
<td>1957-03-04</td>
</tr>
<tr>
<td>25</td>
<td>AMZN</td>
<td>Amazon</td>
<td>link</td>
<td>Consumer Discretionary</td>
<td>Internet & Direct Marketing Retail</td>
<td>Seattle, Washington</td>
<td>2005-11-18</td>
</tr>
<tr>
<td>26</td>
<td>AMCR</td>
<td>Amcor</td>
<td>link</td>
<td>Materials</td>
<td>Paper Packaging</td>
<td>Zurich, Switzerland</td>
<td>2019-06-07</td>
</tr>
<tr>
<td>27</td>
<td>AEE</td>
<td>Ameren Corp</td>
<td>link</td>
<td>Utilities</td>
<td>Multi-Utilities</td>
<td>St. Louis, Missouri</td>
<td>1991-09-19</td>
</tr>
<tr>
<td>28</td>
<td>AAL</td>
<td>American Airlines Group</td>
<td>link</td>
<td>Industrials</td>
<td>Airlines</td>
<td>Fort Worth, Texas</td>
<td>2015-03-23</td>
</tr>
<tr>
<td>29</td>
<td>AEP</td>
<td>American Electric Power</td>
<td>link</td>
<td>Utilities</td>
<td>Electric Utilities</td>
<td>Columbus, Ohio</td>
<td>1957-03-04</td>
</tr>
<tr>
<td>30</td>
<td>AXP</td>
<td>American Express</td>
<td>link</td>
<td>Financials</td>
<td>Consumer Finance</td>
<td>New York City, New York</td>
<td>1976-06-30</td>
</tr>
<tr>
<td>31</td>
<td>AIG</td>
<td>American International Group</td>
<td>link</td>
<td>Financials</td>
<td>Property & Casualty Insurance</td>
<td>New York City, New York</td>
<td>1980-03-31</td>
</tr>
<tr>
<td>32</td>
<td>AMT</td>
<td>American Tower</td>
<td>link</td>
<td>Real Estate</td>
<td>Specialized REITs</td>
<td>Boston, Massachusetts</td>
<td>2007-11-19</td>
</tr>
<tr>
<td>33</td>
<td>AWK</td>
<td>American Water Works</td>
<td>link</td>
<td>Utilities</td>
<td>Water Utilities</td>
<td>Camden, New Jersey</td>
<td>2016-03-04</td>
</tr>
<tr>
<td>34</td>
<td>AMP</td>
<td>Ameriprise Financial</td>
<td>link</td>
<td>Financials</td>
<td>Asset Management & Custody Banks</td>
<td>Minneapolis, Minnesota</td>
<td>2005-10-03</td>
</tr>
<tr>
<td>35</td>
<td>ABC</td>
<td>AmerisourceBergen</td>
<td>link</td>
<td>Health Care</td>
<td>Health Care Distributors</td>
<td>Chesterbrook, Pennsylvania</td>
<td>2001-08-30</td>
</tr>
<tr>
<td>36</td>
<td>AME</td>
<td>Ametek</td>
<td>link</td>
<td>Industrials</td>
<td>Electrical Components & Equipment</td>
<td>Berwyn, Pennsylvania</td>
<td>2013-09-23</td>
</tr>
<tr>
<td>37</td>
<td>AMGN</td>
<td>Amgen</td>
<td>link</td>
<td>Health Care</td>
<td>Biotechnology</td>
<td>Thousand Oaks, California</td>
<td>1992-01-02</td>
</tr>
<tr>
<td>38</td>
<td>APH</td>
<td>Amphenol</td>
<td>link</td>
<td>Information Technology</td>
<td>Electronic Components</td>
<td>Wallingford, Connecticut</td>
<td>2008-09-30</td>
</tr>
<tr>
<td>39</td>
<td>ADI</td>
<td>Analog Devices</td>
<td>link</td>
<td>Information Technology</td>
<td>Semiconductors</td>
<td>Wilmington, Massachusetts</td>
<td>1999-10-12</td>
</tr>
<tr>
<td>40</td>
<td>ANSS</td>
<td>Ansys</td>
<td>link</td>
<td>Information Technology</td>
<td>Application Software</td>
<td>Canonsburg, Pennsylvania</td>
<td>2017-06-19</td>
</tr>
<tr>
<td>41</td>
<td>ANTM</td>
<td>Anthem</td>
<td>link</td>
<td>Health Care</td>
<td>Managed Health Care</td>
<td>Indianapolis, Indiana</td>
<td>2002-07-25</td>
</tr>
<tr>
<td>42</td>
<td>AON</td>
<td>Aon</td>
<td>link</td>
<td>Financials</td>
<td>Insurance Brokers</td>
<td>London, UK</td>
<td>1996-04-23</td>
</tr>
<tr>
<td>43</td>
<td>AOS</td>
<td>A. O. Smith</td>
<td>link</td>
<td>Industrials</td>
<td>Building Products</td>
<td>Milwaukee, Wisconsin</td>
<td>2017-07-26</td>
</tr>
<tr>
<td>44</td>
<td>APA</td>
<td>APA Corporation</td>
<td>link</td>
<td>Energy</td>
<td>Oil & Gas Exploration & Production</td>
<td>Houston, Texas</td>
<td>1997-07-28</td>
</tr>
<tr>
<td>45</td>
<td>AAPL</td>
<td>Apple</td>
<td>link</td>
<td>Information Technology</td>
<td>Technology Hardware, Storage & Peripherals</td>
<td>Cupertino, California</td>
<td>1982-11-30</td>
</tr>
</tbody>
</table>
</div>
</div>
</main>
<footer class="page-footer font-small fixed-bottom">
<div class="container-fluid text-center">
<ul class="list-unstyled list-inline text-center">
<li class="list-inline-item">
GitLab
</li>
<li class="list-inline-item">
About the Author
</li>
<li class="list-inline-item">
About the App
</li>
<li class="list-inline-item">
Code License
</li>
<li class="list-inline-item">
Contact Me
</li>
</ul>
</div>
</footer>
</body>
</html>
Have managed to solve all bugs by changing the CSS file except for the table header being sticky.
Here's the code for it
html {
font-family: Arial, Helvetica, sans-serif;
}
body {
/* padding-bottom: 80px; */
/* height: 100% */
}
main {
/* display: flex; */
/* flex-direction: column; */
/* flex-grow: 1; */
margin-bottom: 80px;
/* overflow: hidden; */
}
footer {
margin-top: 80px;
height: 10vh;
width:100%;
padding:0.4rem 0;
background:#343A40;
}
#media all and (max-width:700px){
footer{
font-size:1rem;
margin:0 1rem;
}
}
.indices-container {
margin: auto;
}
.sp500-table-container {
height: 70vh !important;
width: 100vw;
position: relative;
/* padding-bottom: 80px; */
/* flex: 1; */
/* margin-bottom: 16px; */
}
main{
overflow-x:scroll;
}
I'm backend developer and have spring boot project with template engine thymeleaf.
I have table. Last column has 3 icons-hyperlinks.
My css style:
td.last {
width: 1px;
white-space: nowrap;
}
My html:
<table class="table table-stripped table-bordered">
<thead>
<tr>
<th>Column1</th>
<th>Column2</th>
<th>Column3</th>
<th>Column4</th>
<th class="col-md-1">Column5</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
...
<tr>
<td>9</td>
<td>Foo</td>
<td>Bar</td>
<td></td>
<td>
<span class="glyphicon glyphicon-tasks" aria-hidden="true"></span>
<span>41</span>
</td>
<td>
<span style="display:inline-block;">
<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
<a style="display: null" href="/link2?param1=FooBar"><span class="glyphicon glyphicon glyphicon-stats" aria-hidden="true"></span></a>
</span>
</td>
</tr>
</tbody>
</table>
Why my last column so wide?
I am not seeing classname last on your td.. I think you might mean :last-child. Change your td.last css style to below one..
td:last-child{
width:20px;
display:inline-block;
overflow: hidden;
}
See the Snippet below:
table{
width: 100%;
}
td:last-child{
width:20px;
display:inline-block;
overflow: hidden;
}
<table>
<tr>
<td>Name</td>
<td>Number</td>
<td>Address</td>
<td>Action</td>
</tr>
<tr>
<td>James</td>
<td>1212121</td>
<td>USA</td>
<td>Edit Delete Graph</td>
</tr>
</table>
You can test it here also.
First of all, there are indeed multiple similar questions but they are not working in my case. Related, Other related
The structure is like page > div > div > stuff + table
I am using Gridstack.js and here is my current code
$('.grid-stack').gridstack();
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.2.6/gridstack.min.css" />
<script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.2.6/gridstack.min.js'></script>
<body>
<div class="grid-stack">
<div class="grid-stack-item" data-gs-x="0" data-gs-y="0" data-gs-width="10" data-gs-height="2">
<div class="grid-stack-item-content">
<h3>Title</h3>
<div>
<input type="text">
</div>
<div>
<button>Button A</button>
<button>Button B</button>
</div>
<div>
<a>Link A</a>
<a>Link B</a>
</div>
<table>
<thead>
<tr>
<th>ColA</th>
<th>ColB</th>
<th>ColC</th>
<th>ColD</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mauritius</td>
<td>Castor</td>
<td>F14 3QF</td>
<td>dignissim.pharetra#aliquetmolestietellus.net</td>
</tr>
<tr>
<td>Guyana</td>
<td>Inuvik</td>
<td>67752</td>
<td>Nam.porttitor#sitamet.edu</td>
</tr>
<tr>
<td>Norfolk Island</td>
<td>Sparwood</td>
<td>10899-987</td>
<td>in.consectetuer#ametmetusAliquam.net</td>
</tr>
<tr>
<td>Afghanistan</td>
<td>Sant'Urbano</td>
<td>7142</td>
<td>lectus.convallis#ornareIn.co.uk</td>
</tr>
<tr>
<td>Macao</td>
<td>Bon Accord</td>
<td>16-568</td>
<td>auctor.velit.Aliquam#consectetuerrhoncus.edu</td>
</tr>
<tr>
<td>Philippines</td>
<td>Anghiari</td>
<td>280294</td>
<td>neque.vitae#eu.org</td>
</tr>
<tr>
<td>Bangladesh</td>
<td>Falciano del Massico</td>
<td>90856</td>
<td>id#vitae.edu</td>
</tr>
<tr>
<td>Micronesia</td>
<td>Divinópolis</td>
<td>45-520</td>
<td>scelerisque.neque#vitaesemper.co.uk</td>
</tr>
<tr>
<td>Antigua and Barbuda</td>
<td>Dudzele</td>
<td>728363</td>
<td>dignissim.tempor.arcu#vulputate.net</td>
</tr>
<tr>
<td>Papua New Guinea</td>
<td>Joué-lès-Tours</td>
<td>958173</td>
<td>amet#eleifendnondapibus.net</td>
</tr>
<tr>
<td>Hong Kong</td>
<td>Gateshead</td>
<td>83548-761</td>
<td>fringilla.purus#enimnec.com</td>
</tr>
<tr>
<td>Iran</td>
<td>Minto</td>
<td>80622</td>
<td>adipiscing.ligula#fringillaDonec.edu</td>
</tr>
<tr>
<td>Curaçao</td>
<td>Whitby</td>
<td>59472</td>
<td>ante#anteNunc.org</td>
</tr>
<tr>
<td>Korea, South</td>
<td>Montpelier</td>
<td>L8 2TT</td>
<td>a#sagittisDuisgravida.org</td>
</tr>
<tr>
<td>Papua New Guinea</td>
<td>Dokkum</td>
<td>205204</td>
<td>sed.libero#convallisest.co.uk</td>
</tr>
<tr>
<td>New Zealand</td>
<td>Maisires</td>
<td>9279</td>
<td>ultrices.posuere.cubilia#sem.org</td>
</tr>
<tr>
<td>Panama</td>
<td>Rankweil</td>
<td>30910</td>
<td>elit.fermentum#odio.org</td>
</tr>
<tr>
<td>New Zealand</td>
<td>Melsele</td>
<td>23428</td>
<td>sed.libero.Proin#nequevitaesemper.com</td>
</tr>
<tr>
<td>Cuba</td>
<td>Wolvertem</td>
<td>93687-468</td>
<td>auctor.odio#pellentesqueafacilisis.edu</td>
</tr>
<tr>
<td>Indonesia</td>
<td>Rothesay</td>
<td>919761</td>
<td>augue.scelerisque#asollicitudin.com</td>
</tr>
<tr>
<td>Japan</td>
<td>Inuvik</td>
<td>2899</td>
<td>massa.non#ligulaDonecluctus.org</td>
</tr>
<tr>
<td>Mauritius</td>
<td>Zeitz</td>
<td>603912</td>
<td>consequat#diamPellentesquehabitant.edu</td>
</tr>
<tr>
<td>Curaçao</td>
<td>Lincoln</td>
<td>11148</td>
<td>tristique.neque#Nullamlobortis.org</td>
</tr>
<tr>
<td>Swaziland</td>
<td>Newtown</td>
<td>9616</td>
<td>ipsum#sapien.ca</td>
</tr>
<tr>
<td>Brazil</td>
<td>Rodì Milici</td>
<td>861316</td>
<td>fames#variusultricesmauris.ca</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
Current behavior
While scrolling inside the div there is nothing special, you will first scroll thought the input, links,... then though the table
Expected behavior
While scrolling, when the header hits the top of the div - the header should be fixed on the top of the div (Not the top of the page). When scrolled back, the header should go back to its normal state.
There is no need to check for the end of the div to hide the header. The end of the div will always be the end of the table.
How can this be achieved ? The header should not be fixed to the top of the page but the top of the div
Note: this should work for IE11 also
Add style for your table
table thead tr:nth-child(1) th{
background: RED;
position: sticky;
top: 0;
z-index: 10;
}
support of sticky
$('.grid-stack').gridstack();
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
}
table thead tr:nth-child(1) th{
background: RED;
position: sticky;
top: 0;
z-index: 10;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.2.6/gridstack.min.css" />
<script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.2.6/gridstack.min.js'></script>
<body>
<div class="grid-stack">
<div class="grid-stack-item" data-gs-x="0" data-gs-y="0" data-gs-width="10" data-gs-height="2">
<div class="grid-stack-item-content">
<h3>Title</h3>
<div>
<input type="text">
</div>
<div>
<button>Button A</button>
<button>Button B</button>
</div>
<div>
<a>Link A</a>
<a>Link B</a>
</div>
<table>
<thead>
<tr>
<th>ColA</th>
<th>ColB</th>
<th>ColC</th>
<th>ColD</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mauritius</td>
<td>Castor</td>
<td>F14 3QF</td>
<td>dignissim.pharetra#aliquetmolestietellus.net</td>
</tr>
<tr>
<td>Guyana</td>
<td>Inuvik</td>
<td>67752</td>
<td>Nam.porttitor#sitamet.edu</td>
</tr>
<tr>
<td>Norfolk Island</td>
<td>Sparwood</td>
<td>10899-987</td>
<td>in.consectetuer#ametmetusAliquam.net</td>
</tr>
<tr>
<td>Afghanistan</td>
<td>Sant'Urbano</td>
<td>7142</td>
<td>lectus.convallis#ornareIn.co.uk</td>
</tr>
<tr>
<td>Macao</td>
<td>Bon Accord</td>
<td>16-568</td>
<td>auctor.velit.Aliquam#consectetuerrhoncus.edu</td>
</tr>
<tr>
<td>Philippines</td>
<td>Anghiari</td>
<td>280294</td>
<td>neque.vitae#eu.org</td>
</tr>
<tr>
<td>Bangladesh</td>
<td>Falciano del Massico</td>
<td>90856</td>
<td>id#vitae.edu</td>
</tr>
<tr>
<td>Micronesia</td>
<td>Divinópolis</td>
<td>45-520</td>
<td>scelerisque.neque#vitaesemper.co.uk</td>
</tr>
<tr>
<td>Antigua and Barbuda</td>
<td>Dudzele</td>
<td>728363</td>
<td>dignissim.tempor.arcu#vulputate.net</td>
</tr>
<tr>
<td>Papua New Guinea</td>
<td>Joué-lès-Tours</td>
<td>958173</td>
<td>amet#eleifendnondapibus.net</td>
</tr>
<tr>
<td>Hong Kong</td>
<td>Gateshead</td>
<td>83548-761</td>
<td>fringilla.purus#enimnec.com</td>
</tr>
<tr>
<td>Iran</td>
<td>Minto</td>
<td>80622</td>
<td>adipiscing.ligula#fringillaDonec.edu</td>
</tr>
<tr>
<td>Curaçao</td>
<td>Whitby</td>
<td>59472</td>
<td>ante#anteNunc.org</td>
</tr>
<tr>
<td>Korea, South</td>
<td>Montpelier</td>
<td>L8 2TT</td>
<td>a#sagittisDuisgravida.org</td>
</tr>
<tr>
<td>Papua New Guinea</td>
<td>Dokkum</td>
<td>205204</td>
<td>sed.libero#convallisest.co.uk</td>
</tr>
<tr>
<td>New Zealand</td>
<td>Maisires</td>
<td>9279</td>
<td>ultrices.posuere.cubilia#sem.org</td>
</tr>
<tr>
<td>Panama</td>
<td>Rankweil</td>
<td>30910</td>
<td>elit.fermentum#odio.org</td>
</tr>
<tr>
<td>New Zealand</td>
<td>Melsele</td>
<td>23428</td>
<td>sed.libero.Proin#nequevitaesemper.com</td>
</tr>
<tr>
<td>Cuba</td>
<td>Wolvertem</td>
<td>93687-468</td>
<td>auctor.odio#pellentesqueafacilisis.edu</td>
</tr>
<tr>
<td>Indonesia</td>
<td>Rothesay</td>
<td>919761</td>
<td>augue.scelerisque#asollicitudin.com</td>
</tr>
<tr>
<td>Japan</td>
<td>Inuvik</td>
<td>2899</td>
<td>massa.non#ligulaDonecluctus.org</td>
</tr>
<tr>
<td>Mauritius</td>
<td>Zeitz</td>
<td>603912</td>
<td>consequat#diamPellentesquehabitant.edu</td>
</tr>
<tr>
<td>Curaçao</td>
<td>Lincoln</td>
<td>11148</td>
<td>tristique.neque#Nullamlobortis.org</td>
</tr>
<tr>
<td>Swaziland</td>
<td>Newtown</td>
<td>9616</td>
<td>ipsum#sapien.ca</td>
</tr>
<tr>
<td>Brazil</td>
<td>Rodì Milici</td>
<td>861316</td>
<td>fames#variusultricesmauris.ca</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</body>
It can be done with CSS position: fixed and jQuery script. Check out the snippet below or JSFiddle.
$('.grid-stack').gridstack();
$('thead th').each(function(index) {
$('.fixed-header th').eq(index).css('width', $(this).width());
});
$('.fixed-header-container').height($('.fixed-header').height());
$('.fixed-header-container').hide();
$('.grid-stack-item-content').scroll(function() {
var $table = $('.content-table');
if ($table.offset().top >= 0) {
$('.fixed-header-container').hide();
} else if ($table.offset().top < 0) {
$('.fixed-header-container').show();
}
});
table,
th,
td {
border: 1px solid black;
border-collapse: collapse;
}
.fixed-header {
position: fixed;
background-color: white;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.2.6/gridstack.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/0.2.6/gridstack.min.css" rel="stylesheet" />
<div class="grid-stack">
<div class="grid-stack-item" data-gs-x="0" data-gs-y="0" data-gs-width="10" data-gs-height="2">
<div class="grid-stack-item-content fixed-header-container" style="z-index: 1 !important;">
<table class="fixed-header">
<tr>
<th>ColA</th>
<th>ColB</th>
<th>ColC</th>
<th>ColD</th>
</tr>
</table>
</div>
<div class="grid-stack-item-content">
<div>
<h3>Title</h3>
<input type="text">
<div>
<button>Button A</button>
<button>Button B</button>
</div>
<div>
<a>Link A</a>
<a>Link B</a>
</div>
</div>
<table class="content-table">
<thead>
<tr>
<th>ColA</th>
<th>ColB</th>
<th>ColC</th>
<th>ColD</th>
</tr>
</thead>
<tbody>
<tr>
<td>Mauritius</td>
<td>Castor</td>
<td>F14 3QF</td>
<td>dignissim.pharetra#aliquetmolestietellus.net</td>
</tr>
<tr>
<td>Guyana</td>
<td>Inuvik</td>
<td>67752</td>
<td>Nam.porttitor#sitamet.edu</td>
</tr>
<tr>
<td>Norfolk Island</td>
<td>Sparwood</td>
<td>10899-987</td>
<td>in.consectetuer#ametmetusAliquam.net</td>
</tr>
<tr>
<td>Afghanistan</td>
<td>Sant'Urbano</td>
<td>7142</td>
<td>lectus.convallis#ornareIn.co.uk</td>
</tr>
<tr>
<td>Macao</td>
<td>Bon Accord</td>
<td>16-568</td>
<td>auctor.velit.Aliquam#consectetuerrhoncus.edu</td>
</tr>
<tr>
<td>Philippines</td>
<td>Anghiari</td>
<td>280294</td>
<td>neque.vitae#eu.org</td>
</tr>
<tr>
<td>Bangladesh</td>
<td>Falciano del Massico</td>
<td>90856</td>
<td>id#vitae.edu</td>
</tr>
<tr>
<td>Micronesia</td>
<td>Divinópolis</td>
<td>45-520</td>
<td>scelerisque.neque#vitaesemper.co.uk</td>
</tr>
<tr>
<td>Antigua and Barbuda</td>
<td>Dudzele</td>
<td>728363</td>
<td>dignissim.tempor.arcu#vulputate.net</td>
</tr>
<tr>
<td>Papua New Guinea</td>
<td>Joué-lès-Tours</td>
<td>958173</td>
<td>amet#eleifendnondapibus.net</td>
</tr>
<tr>
<td>Hong Kong</td>
<td>Gateshead</td>
<td>83548-761</td>
<td>fringilla.purus#enimnec.com</td>
</tr>
<tr>
<td>Iran</td>
<td>Minto</td>
<td>80622</td>
<td>adipiscing.ligula#fringillaDonec.edu</td>
</tr>
<tr>
<td>Curaçao</td>
<td>Whitby</td>
<td>59472</td>
<td>ante#anteNunc.org</td>
</tr>
<tr>
<td>Korea, South</td>
<td>Montpelier</td>
<td>L8 2TT</td>
<td>a#sagittisDuisgravida.org</td>
</tr>
<tr>
<td>Papua New Guinea</td>
<td>Dokkum</td>
<td>205204</td>
<td>sed.libero#convallisest.co.uk</td>
</tr>
<tr>
<td>New Zealand</td>
<td>Maisires</td>
<td>9279</td>
<td>ultrices.posuere.cubilia#sem.org</td>
</tr>
<tr>
<td>Panama</td>
<td>Rankweil</td>
<td>30910</td>
<td>elit.fermentum#odio.org</td>
</tr>
<tr>
<td>New Zealand</td>
<td>Melsele</td>
<td>23428</td>
<td>sed.libero.Proin#nequevitaesemper.com</td>
</tr>
<tr>
<td>Cuba</td>
<td>Wolvertem</td>
<td>93687-468</td>
<td>auctor.odio#pellentesqueafacilisis.edu</td>
</tr>
<tr>
<td>Indonesia</td>
<td>Rothesay</td>
<td>919761</td>
<td>augue.scelerisque#asollicitudin.com</td>
</tr>
<tr>
<td>Japan</td>
<td>Inuvik</td>
<td>2899</td>
<td>massa.non#ligulaDonecluctus.org</td>
</tr>
<tr>
<td>Mauritius</td>
<td>Zeitz</td>
<td>603912</td>
<td>consequat#diamPellentesquehabitant.edu</td>
</tr>
<tr>
<td>Curaçao</td>
<td>Lincoln</td>
<td>11148</td>
<td>tristique.neque#Nullamlobortis.org</td>
</tr>
<tr>
<td>Swaziland</td>
<td>Newtown</td>
<td>9616</td>
<td>ipsum#sapien.ca</td>
</tr>
<tr>
<td>Brazil</td>
<td>Rodì Milici</td>
<td>861316</td>
<td>fames#variusultricesmauris.ca</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
This question already has answers here:
HTML table with fixed headers?
(31 answers)
Closed 7 years ago.
I know how to make a fixed table-header a few different ways, however I'm looking for the best way, and I only want to use <table>,<thead>,<tbody>,<tr>,<th>,<td> tags which the HTML spec provides you.
Here is a dummy table structure:
<table>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>field</th>
<th>facility</th>
<th>change</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>name1</td>
<td>field1</td>
<td>facility1</td>
<td>change1</td>
</tr>
<tr>
<td>2</td>
<td>name2</td>
<td>field2</td>
<td>facility2</td>
<td>change2</td>
</tr>
<tr>
<td>3</td>
<td>name3</td>
<td>field3</td>
<td>facility3</td>
<td>change3</td>
</tr>
<tr>
<td>4</td>
<td>name4</td>
<td>field4</td>
<td>facility4</td>
<td>change4</td>
</tr>
<tr>
<td>5</td>
<td>name5</td>
<td>field5</td>
<td>facility5</td>
<td>change5</td>
</tr>
<tr>
<td>6</td>
<td>name6</td>
<td>field6</td>
<td>facility6</td>
<td>change6</td>
</tr>
<tr>
<td>7</td>
<td>name7</td>
<td>field7</td>
<td>facility7</td>
<td>change7</td>
</tr>
<tr>
<td>8</td>
<td>name8</td>
<td>field8</td>
<td>facility8</td>
<td>change8</td>
</tr>
<tr>
<td>9</td>
<td>name9</td>
<td>field9</td>
<td>facility9</td>
<td>change9</td>
</tr>
<tr>
<td>10</td>
<td>name10</td>
<td>field10</td>
<td>facility10</td>
<td>change10</td>
</tr>
<tr>
<td>11</td>
<td>name11</td>
<td>field11</td>
<td>facility11</td>
<td>change11</td>
</tr>
<tr>
<td>12</td>
<td>name12</td>
<td>field12</td>
<td>facility12</td>
<td>change12</td>
</tr>
<tr>
<td>13</td>
<td>name13</td>
<td>field13</td>
<td>facility13</td>
<td>change13</td>
</tr>
<tr>
<td>14</td>
<td>name14</td>
<td>field14</td>
<td>facility14</td>
<td>change14</td>
</tr>
<tr>
<td>15</td>
<td>name15</td>
<td>field15</td>
<td>facility15</td>
<td>change15</td>
</tr>
</tbody>
</table>
Try this working demo. Below code:
table {
display: flex;
flex-flow: column;
height: 100%;
width: 100%;
border-collapse: separate;
border-spacing: 0 1px;
}
table thead {
flex: 0 0 auto;
width: calc(100% - 0.9em);
}
table tbody {
flex: 1 1 auto;
display: block;
overflow-y: scroll;
}
table tbody tr {
width: 100%;
}
table thead,
table tbody tr {
display: table;
table-layout: fixed;
}
tbody td,
thead th {
border-right: 1px solid transparent;
vertical-align: middle;
}
thead th {
height: 35px;
font-size: 16px;
text-align: left;
text-transform: uppercase;
}
tbody td {
text-align: left;
height: 30px;
background: #d5d5d5;
}
.table-cont {
width: 100%;
height: 350px;
}
<div class="table-cont">
<table>
<thead>
<tr>
<th>id</th>
<th>name</th>
<th>field</th>
<th>facility</th>
<th>change</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>name1</td>
<td>field1</td>
<td>facility1</td>
<td>change1</td>
</tr>
<tr>
<td>2</td>
<td>name2</td>
<td>field2</td>
<td>facility2</td>
<td>change2</td>
</tr>
<tr>
<td>3</td>
<td>name3</td>
<td>field3</td>
<td>facility3</td>
<td>change3</td>
</tr>
<tr>
<td>4</td>
<td>name4</td>
<td>field4</td>
<td>facility4</td>
<td>change4</td>
</tr>
<tr>
<td>5</td>
<td>name5</td>
<td>field5</td>
<td>facility5</td>
<td>change5</td>
</tr>
<tr>
<td>6</td>
<td>name6</td>
<td>field6</td>
<td>facility6</td>
<td>change6</td>
</tr>
<tr>
<td>7</td>
<td>name7</td>
<td>field7</td>
<td>facility7</td>
<td>change7</td>
</tr>
<tr>
<td>8</td>
<td>name8</td>
<td>field8</td>
<td>facility8</td>
<td>change8</td>
</tr>
<tr>
<td>9</td>
<td>name9</td>
<td>field9</td>
<td>facility9</td>
<td>change9</td>
</tr>
<tr>
<td>10</td>
<td>name10</td>
<td>field10</td>
<td>facility10</td>
<td>change10</td>
</tr>
<tr>
<td>11</td>
<td>name11</td>
<td>field11</td>
<td>facility11</td>
<td>change11</td>
</tr>
<tr>
<td>12</td>
<td>name12</td>
<td>field12</td>
<td>facility12</td>
<td>change12</td>
</tr>
<tr>
<td>13</td>
<td>name13</td>
<td>field13</td>
<td>facility13</td>
<td>change13</td>
</tr>
<tr>
<td>14</td>
<td>name14</td>
<td>field14</td>
<td>facility14</td>
<td>change14</td>
</tr>
<tr>
<td>15</td>
<td>name15</td>
<td>field15</td>
<td>facility15</td>
<td>change15</td>
</tr>
</tbody>
</table>
</div>
I've a table with caption centered middle. At the right side of the caption, there is a link with refers to another page for detailed view. If my link text is too large, then the caption middle alignment is broken, it is pushed left. All I want to keep the caption at the middle regardless of the placement of link. That means, caption should be middle aligned.
Problem Demo
<div class="col-xs-4">
<table class="table">
<caption>Table Caption<a class="detail-link">large link placed at right</a></caption>
<thead>
<tr>
<th>Name</th>
<th>City</th>
<th>Pincode</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tanmay</td>
<td>Bangalore</td>
<td>560001</td>
</tr>
<tr>
<td>Sachin</td>
<td>Mumbai</td>
<td>400003</td>
</tr>
<tr>
<td>Uma</td>
<td>Pune</td>
<td>411027</td>
</tr>
</tbody>
</table>
</div>
/* CSS used here will be applied after bootstrap.css */
.detail-link {
float: right;
}
It can be done using a div tag combined with some relative positioning as seen below.
<div class="col-xs-4">
<table class="table">
<caption>Table Caption</caption>
<div style="position:relative;float:right;top:20px;">text too long</div>
<thead>
<tr>
<th>Name</th>
<th>City</th>
<th>Pincode</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tanmay</td>
<td>Bangalore</td>
<td>560001</td>
</tr>
<tr>
<td>Sachin</td>
<td>Mumbai</td>
<td>400003</td>
</tr>
<tr>
<td>Uma</td>
<td>Pune</td>
<td>411027</td>
</tr>
</tbody>
</table>
</div>
Positioning it as absolute will achieve your requirement.
.detail-link {
position:absolute;
right: 0;
width: 30%;
}
You could try this:
CSS:
.detail-link {
float:right;
width:30%;
}
span{
position:relative;
left:26px;
}
HTML:
<div class="col-xs-4">
<table class="table">
<caption><span>Table Caption</span><a class="detail-link">large links asfasf asf asdf as at right</a></caption>
<thead>
<tr>
<th>Name</th>
<th>City</th>
<th>Pincode</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tanmay</td>
<td>Bangalore</td>
<td>560001</td>
</tr>
<tr>
<td>Sachin</td>
<td>Mumbai</td>
<td>400003</td>
</tr>
<tr>
<td>Uma</td>
<td>Pune</td>
<td>411027</td>
</tr>
</tbody>
</table>
</div>
span{position:relative;
left:26px;
}
you could do:
Table Caption also should float:right; and replace to after your link
CSS:
/* CSS used here will be applied after bootstrap.css */
.detail-link {
float: right;
}
span {
float:right;
margin-right:15px;
}
HTML:
<div class="col-xs-4">
<table class="table">
<caption><a class="detail-link">large link placed at right</a><span>Table Caption</span></caption>
<thead>
<tr>
<th>Name</th>
<th>City</th>
<th>Pincode</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tanmay</td>
<td>Bangalore</td>
<td>560001</td>
</tr>
<tr>
<td>Sachin</td>
<td>Mumbai</td>
<td>400003</td>
</tr>
<tr>
<td>Uma</td>
<td>Pune</td>
<td>411027</td>
</tr>
</tbody>
</table>
</div>
i hope it's helpfull