我有以下代码:
<td>
<a class="action--edit"><i class="icon-edit">Edit</i></a>
<a class="action--delete"><i class="icon-delete">Delete</i></a>
</td>
我需要什么:
我尝试了什么:
[class^=table--] td a i { display: block }
然后我添加了文本范围:
<td>
<a class="action--edit"><i class="icon-edit"></i><span>Edit</span></i></a>
<a class="action--delete"><i class="icon-delete"></i><span>Delete</span></a>
</td>
[class^=table--] td a i, [class^=table--] td a span {
display: block; }
图标,我是一个字体图标:
[class*=" icon-"]:before {
font-family: "c" !important;
speak: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
在这两种情况下,锚点都会改变,而不是我需要的东西:
我没有尝试浮动锚(a),因为在td需要居中
见下图:
答案 0 :(得分:1)
请将anchor
标记内容与center
对齐。
td {
min-width: 150px;
border: 1px dotted red;
height: 50px;
display: flex;
justify-content: space-around;
align-items: center;
}
td i,
td span {
display: block;
}
td a {
text-align: center;
}
&#13;
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body>
<table>
<td>
<a class="action--edit"><i class="fa fa-edit"></i><span>Edit</span></a>
<a class="action--delete"><i class="fa fa-trash"></i><span>Delete</span></a>
</td>
</table>
</body>
&#13;
答案 1 :(得分:1)
根据你的形象,这样的事情?图标需要是具有自动边距的块,因此文本可以降到下面。
html,body {
font: normal 100%/1 sans-serif;
}
.btn-icon {
display: inline-block;
width: 65px; /* Optional to keep buttons same size */
padding: 10px 0;
color: black;
text-decoration: none;
text-align: center;
}
.btn-icon i {
font-size: 28px;
display: block;
margin: 0 auto;
}
.btn-icon:hover {
color: blue;
background: #efefef;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<table>
<tr>
<td>
<a href="#" class="btn-icon"><i class="fa fa-pencil"></i> Edit</a>
<a href="#" class="btn-icon"><i class="fa fa-trash"></i> Delete</a>
</td>
</tr>
</table>