2017-12-27 3 views
1

Ich versuche, die Farbe einer Zeile einer Tabelle bei Hover zu ändern. mit Zeile: Hover, aber auf diese Weise ist es nur eine perticular Zelle schweben, die offensichtlich ist. aber wenn ich versuche, row cell: hover zu verwenden, dann hat es keine Wirkung. Das ist mein HTML.Wie ändere ich die Farbe einer Zeile einer Tabelle bei Hover

JSfiddle: https://jsfiddle.net/f4ojhxco/2/

<div id="table"> 
    <div class="header-row row"> 
<span class="cell">SI. No.</span> 
    <span class="cell">Application Date</span> 
    <span class="cell">Customer Name</span> 
    <span class="cell">Loan Amount</span> 
    <span class="cell">Loan Status</span> 
    <span class="cell">Action</span> 
    </div> 
<div class="row" *ngFor="let item of customerList ; let i= index;"> 
    <input type="radio" name="expand"> 
<span class="cell" data-label="SI. No.">{{i+1}}</span> 
<span class="cell" data-label="Application Date">{{item.date}}</span> 
<span class="cell" data-label="Customer Name"> 
    {{item.name}}</span> 
<span class="cell" data-label="Loan Amount">{{item.amount}}</span> 
<span class="cell" data-label="Loan Status">{{item.status}}</span> 
<span class="cell" data-label="Action"> 
    <a href="https://www.w3schools.com">More Details</a> 
</span> 
    </div> 
</div> 
+0

Arbeitsbeispiel in Code-Stift oder Geige hinzufügen. – kmg

+1

https://jsfiddle.net/f4ojhxco/2/ –

Antwort

7

den Stil geben, wie durch Entfernen der Raum zwischen der Klasse .row und :hover folgt.

.row:hover { 
    background: green; 
} 
0

Versuchen Sie, diese

#table .row:hover { 
/*add your css here*/ 
} 
0

Try This:

\t body { 
 
\t background: #cacaca; 
 
\t margin: 0; 
 
\t padding: 20px; 
 
\t font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; 
 
\t font-weight: 300; 
 
\t } 
 

 
\t #table { 
 
\t display: table; 
 
    width: 100%; 
 
\t background: #fff; 
 
\t margin: 0; 
 
\t box-sizing: border-box; 
 
\t } 
 

 
\t .caption { 
 
\t display: block; 
 
\t width: 100%; 
 
\t background: #64e0ef; 
 
\t height: 55px; 
 
\t padding-left: 10px; 
 
\t color: #fff; 
 
\t font-size: 20px; 
 
\t line-height: 55px; 
 
\t text-shadow: 1px 1px 1px rgba(0, 0, 0, .3); 
 
\t box-sizing: border-box; 
 
\t } 
 

 
\t .header-row { 
 
\t background: #8b8b8b; 
 
\t color: #fff; 
 
\t } 
 

 
\t .row { 
 
\t display: table-row; 
 
    } 
 

 
    .row :hover { 
 
    background: green; 
 
    } 
 

 

 

 
\t .cell { 
 
\t display: table-cell; 
 
\t padding: 23px; 
 
\t border-bottom: 1px solid #e5e5e5; 
 
\t text-align: center; 
 
\t } 
 

 
\t .primary { 
 
\t text-align: left; 
 
\t } 
 

 
\t input[type="radio"], 
 
\t input[type="checkbox"] { 
 
\t display: none; 
 
\t } 
 

 
\t @media only screen and (max-width: 760px) { 
 
\t body { 
 
\t  padding: 0; 
 
\t } 
 
\t #table { 
 
\t  display: block; 
 
\t  margin: 44px 0 0 0; 
 
\t } 
 
\t .caption { 
 
\t  position: fixed; 
 
\t  top: 0; 
 
\t  text-align: center; 
 
\t  height: 44px; 
 
\t  line-height: 44px; 
 
\t  z-index: 5; 
 
\t  border-bottom: 2px solid #999; 
 
\t } 
 
\t .row { 
 
\t  position: relative; 
 
\t  display: block; 
 
\t  border-bottom: 1px solid #ccc; 
 
\t } 
 
\t .header-row { 
 
\t  display: none; 
 
\t } 
 
\t .cell { 
 
\t  display: block; 
 
\t  border: none; 
 
\t  position: relative; 
 
\t  height: 45px; 
 
\t  line-height: 45px; 
 
\t  text-align: left; 
 
\t } 
 
\t .primary:after { 
 
\t  content: ""; 
 
\t  display: block; 
 
\t  position: absolute; 
 
\t  right: 20px; 
 
\t  top: 18px; 
 
\t  z-index: 2; 
 
\t  width: 0; 
 
\t  height: 0; 
 
\t  border-top: 10px solid transparent; 
 
\t  border-bottom: 10px solid transparent; 
 
\t  border-right: 10px solid #ccc; 
 
\t } 
 
\t .cell:nth-of-type(n+2) { 
 
\t  display: none; 
 
\t } 
 
\t input[type="radio"], 
 
\t input[type="checkbox"] { 
 
\t  display: block; 
 
\t  position: absolute; 
 
\t  z-index: 1; 
 
\t  width: 99%; 
 
\t  height: 100%; 
 
\t  opacity: 0; 
 
\t } 
 
\t input[type="radio"]:checked, 
 
\t input[type="checkbox"]:checked { 
 
\t  z-index: -1; 
 
\t } 
 
\t input[type="radio"]:checked~.cell, 
 
\t input[type="checkbox"]:checked~.cell { 
 
\t  display: block; 
 
\t  border-bottom: 1px solid #eee; 
 
\t } 
 
\t input[type="radio"]:checked~.cell:nth-of-type(n+2), 
 
\t input[type="checkbox"]:checked~.cell:nth-of-type(n+2) { 
 
\t  background: #e0e0e0; 
 
\t } 
 
\t input[type="radio"]:checked~.cell:nth-of-type(n+2):before, 
 
\t input[type="checkbox"]:checked~.cell:nth-of-type(n+2):before { 
 
\t  content: attr(data-label); 
 
\t  display: inline-block; 
 
\t  width: 60px; 
 
\t  background: #999; 
 
\t  border-radius: 10px; 
 
\t  height: 20px; 
 
\t  margin-right: 10px; 
 
\t  font-size: 12px; 
 
\t  line-height: 20px; 
 
\t  text-align: center; 
 
\t  color: white; 
 
\t } 
 
\t input[type="radio"]:checked~.primary, 
 
\t input[type="checkbox"]:checked~.primary { 
 
\t  border-bottom: 2px solid #999; 
 
\t } 
 
\t input[type="radio"]:checked~.primary:after, 
 
\t input[type="checkbox"]:checked~.primary:after { 
 
\t  position: absolute; 
 
\t  right: 18px; 
 
\t  top: 22px; 
 
\t  border-right: 10px solid transparent; 
 
\t  border-left: 10px solid transparent; 
 
\t  border-top: 10px solid #ccc; 
 
\t  z-index: 2; 
 
\t } 
 
\t } 
 
    .cell{ 
 
    height:10px; 
 
    background:green; 
 
    
 
    } 
 
    .cell:hover{ 
 
    background:red; 
 
    }
<div id="table"> 
 
    <div class="header-row row"> 
 
<span class="cell">SI. No.</span> 
 
    <span class="cell">Application Date</span> 
 
    <span class="cell">Customer Name</span> 
 
    <span class="cell">Loan Amount</span> 
 
    <span class="cell">Loan Status</span> 
 
    <span class="cell">Action</span> 
 
    </div> 
 
<div class="row" > 
 
    <input type="radio" name="expand"> 
 
<span class="cell" data-label="SI. No.">1</span> 
 
<span class="cell" data-label="Application Date">5-jan-2017</span> 
 
<span class="cell" data-label="Customer Name"> 
 
    mr xyz</span> 
 
<span class="cell" data-label="Loan Amount">60k</span> 
 
<span class="cell" data-label="Loan Status">open</span> 
 
<span class="cell" data-label="Action"> 
 
    <a href="https://www.w3schools.com">More Details</a> 
 
</span> 
 
    </div> 
 
</div>

0

Entfernen Sie einfach Raum zwischen .row und :hover

.row:hover{ 
    background: green; 
} 
Verwandte Themen