Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap table-hover is not working

I am using bootstrap 3.3.4 and I have a problem. If I check the bootstrap.css file which I am loading, there is a table-hover class, but I can't use it, it just doesn't work, as I can see, table-bordered for example works. I have checked that the bootstrap.js is also loaded. Did anyone else have the same problem? I tried to search it for so long. Thanks in advance

like image 561
Jakub Folejtar Avatar asked May 23 '15 09:05

Jakub Folejtar


People also ask

Why Hover is not working in bootstrap?

It's because the default Bootstrap styling is more specific. Save this answer. Show activity on this post. Without seeing exactly whats going on, the issue you're having may be related to not specifying a class on your unordered list.

What is table responsive in bootstrap?

Responsive TablesThe .table-responsive class creates a responsive table. The table will then scroll horizontally on small devices (under 768px).

What is table-striped?

.table-striped. Adds zebra-striping to any table row within <tbody> (not available in IE8) Try it. .table-bordered. Adds border on all sides of the table and cells.


1 Answers

From the docs on table hover, make sure to add the .table-hover class to your table element.

Also, as Daniel pointed out, bootstrap looks for a tbody to group your rows because it doesn't want to apply hover styling on the header area.

Also, for some screens, the default hover color can appear very dim so you can try making it darker with the following code:

.table-hover > tbody > tr:hover {
  background-color: #D2D2D2;
}

Here's a working demo in Stack Snippets

<link href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.2/css/bootstrap.css" rel="stylesheet"/>


<table class="table table-hover">
  <thead>
    <tr>
      <th>#</th>
      <th>First Name</th>
      <th>Last Name</th>
      <th>Username</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <th scope="row">1</th>
      <td>Mark</td>
      <td>Otto</td>
      <td>@mdo</td>
    </tr>
    <tr>
      <th scope="row">2</th>
      <td>Jacob</td>
      <td>Thornton</td>
      <td>@fat</td>
    </tr>
    <tr>
      <th scope="row">3</th>
      <td>Larry</td>
      <td>the Bird</td>
      <td>@twitter</td>
    </tr>
  </tbody>
</table>
like image 155
KyleMit Avatar answered Sep 26 '22 10:09

KyleMit