我在HTML元素的内容与内容之间存在换行问题:在内容之后。 这是一张可分类的桌子,在桌子的头部是一个小箭头。
你可以在这个小提琴http://jsfiddle.net/ceuwob93/或这张照片中看到它:
显然我不希望箭头前面有这个换行符。
table {
width: 300px;
}
thead {
background-color: #ddd;
border-bottom: 1px solid #bbb;
}
th.sort-down:after {
content: '';
float: right;
margin-top: 7px;
border-width: 0 4px 4px;
border-style: solid;
border-color: #404040 transparent;
}
答案 0 :(得分:1)
不要浮动伪元素,而是尝试绝对定位。
table {
width: 300px;
vertical-align: top;
}
thead {
background-color: #ddd;
border-bottom: 1px solid #bbb;
}
.sort-down {
position: relative;
padding-right: 12px;
}
.sort-down:after {
content: '';
position: absolute;
bottom: 0;
right: 0;
border-width: 0 4px 4px;
border-style: solid;
border-color: #404040 transparent;
}

<table>
<thead>
<tr>
<th>Column 1</th>
<th class="sort-down">Problem</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Some long long long Text</td>
<td>Yes</td>
<td>Some other long long long text</td>
</tr>
</tbody>
</table>
&#13;
答案 1 :(得分:1)
您可以按照建议进行操作,并为列提供固定宽度,或者如果您想要更灵活的方法,可以使用定位:after元素。
table {
width: 300px;
}
thead {
background-color: #ddd;
border-bottom: 1px solid #bbb;
}
.sort-down {
padding-right: 1.5em;
position:relative;
}
.sort-down:after {
content: '';
position:absolute;
top:7px;
right:5px;
border-width: 0 4px 4px;
border-style: solid;
border-color: #404040 transparent;
}
&#13;
<table>
<thead>
<tr>
<th>Column 1</th>
<th class="sort-down">Problem</th>
<th>Column 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Some long long long Text</td>
<td>Yes</td>
<td>Some other long long long text</td>
</tr>
</tbody>
</table>
&#13;
答案 2 :(得分:-1)