skip to Main Content

I am having some issues making my table responsive.

In fact the headings aren’t aligning with the content below. Can someone help me out?

/* Latest compiled and minified CSS included as External Resource*/

/* Optional theme */
@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-theme.min.css');

body {
    margin: 10px;
}
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<div class="container">
    <div class="row">
    
    <div class="table-responsive">

<table>

	<thead>
		<th>Subject</th>
		<th>Dates</th>
		<th>Time</th>
		<th>With</th>
		<th>Cost</th>
	</thead>

<tr style="display:block"><td class="elist-title"><a href="/events/winter/">Winter</a></td><td class="elist-date">27 February 2016 </td><td class="elist-time">10:00am - 4:00pm</td><td class="elist-with">Gordon Peterson&nbsp;</td><td class="elist-cost"></td></tr>

</table>

</div>
    
    </div>
</div>

Demo: https://jsfiddle.net/ppq3xxwv/

Thank you.

2

Answers


  1. remove inline style in tr & Add class table like table

    <tr /*style="display:block"*/><td class="elist-title"><a href="/events/winter/">Winter</a></td><td class="elist-date">27 February 2016 </td><td class="elist-time">10:00am - 4:00pm</td><td class="elist-with">Gordon Peterson&nbsp;</td><td class="elist-cost"></td></tr>
    
    <table class="table">
    

    https://jsfiddle.net/ppq3xxwv/1/

    Login or Signup to reply.
  2. Add class “table” and tbody tab to your HTML. this will fix your issue.I made the changes in code below:

        <div class="table-responsive">
    
    <table class="table">
    
        <thead>
            <th>Subject</th>
            <th>Dates</th>
            <th>Time</th>
            <th>With</th>
            <th>Cost</th>
        </thead>
    <tbody>
    <tr><td ><a href="/events/winter/">Winter</a></td><td >27 February 2016 </td><td >10:00am - 4:00pm</td><td >Gordon Peterson&nbsp;</td><td class="elist-cost"></td></tr>
    </tbody>
    </table>
    
    </div>
    
        </div>
    </div>
    

    example code here CODEPEN

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search