【发布时间】:2018-11-06 08:06:28
【问题描述】:
我正在尝试创建具有以下两个功能的表:
我在某些网站上看到的某种“带阴影的显眼”或“3d 效果”,感觉非常愉快。
鼠标光标应该有一个“手”图标,表明该行是可点击的。
每当用户将鼠标悬停在表格的行上时,我都需要显示这些功能。我尝试使用 Bootstrap 4 的 table-hover 类的功能,但无法实现这两个功能中的任何一个。
对于第一个功能,我想为悬停的<tr> 添加一个带阴影的类。但是,不知道这是否是最好的方法。 是否有一些已经定义的类可以实现这种行为?
对于第二个功能,我不知道。有什么建议吗?
这是我的代码:
<div class="container">
<div class="table-wrapper">
<table class="table">
<thead id="thead_st" class="thead">
<tr>
<th class="thead-row" scope="col"></th>
<th class="thead-row" scope="col">1</th>
<th class="thead-row" scope="col">2</th>
<th class="thead-row" scope="col">3</th>
<th class="thead-row" scope="col">4</th>
<th class="thead-row" scope="col"></th>
</tr>
</thead>
<tbody>
<tr class="trow">
<th scope="row"></th>
<td class="score">4.7</td>
<td>Bla bla</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
</div>
CSS:
.table-wrapper {
border-radius: 8px;
overflow: hidden;
}
.container {
margin-top: 50px;
margin-bottom: 50px;
background: white;
border-radius: 8px;
padding: 0px;
}
body {
background: #ECEEF1;
font-family: 'Roboto', sans-serif;
color: #2C3A56;
}
tr {
font-size: 16.5px;
line-height: 50px;
padding: 0px;
font-weight: 100;
}
td, th {
display: table-cell;
text-align: center;
}
#thead_st {
background-color: #F6CE52;
border: 3px solid #F6CE52;
color: white;
}
.thead-row {
line-height: 20px;
font-weight: 100;
}
.trow:hover {
cursor:pointer; //set the cursor to pointer (hand)
background-color: blue; //sets hovered row's background color to blue
box-shadow: 5px 10px #888888;
}
【问题讨论】:
标签: css html twitter-bootstrap html-table