我正在桌面上创建一个功能区但面临一些问题。 我无法在桌子上制作丝带。有些看起来很奇怪。
.sash {
position: relative;
overflow: hidden;
width: 300px;
}
.sash:after {
content: "Sash";
position: absolute;
width: 90px;
height: 30px;
background: red;
top: 0;
right: 0;
transform: rotate(49deg);
}
<table style="border:1px solid black" class="sash">
<tr>
<td>one line text</td>
<td>two line text</td>
<td>three line text</td>
<td>four line text</td>
<td width="100"></td>
</tr>
<tr>
<td>one line text</td>
<td>two line text</td>
<td>three line text</td>
<td>four line text</td>
<td width="100"></td>
</tr>
</table>
答案 0 :(得分:4)
也许:
.sash {
position: relative;
overflow: hidden;
width: 300px;
}
.sash:after {
content: attr(data-ribbon);
position: absolute;
width: 90px;
height: 30px;
background: red;
top: 5px;
text-align: center;
line-height: 30px;
right: -27px;
transform: rotate(49deg);
}
&#13;
<table style="border:1px solid black" class="sash" data-ribbon="Sach">
<tr>
<td>one line text</td>
<td>two line text</td>
<td>three line text</td>
<td>four line text</td>
<td width="100"></td>
</tr>
<tr>
<td>one line text</td>
<td>two line text</td>
<td>three line text</td>
<td>four line text</td>
<td width="100"></td>
</tr>
</table>
&#13;
每行:
.sash tr td:last-child {
position: relative;
overflow: hidden;
width: 300px;
}
.sash tr td:last-child:after {
content: attr(data-ribbon);
position: absolute;
width: 90px;
height: 30px;
background: red;
top: 5px;
text-align: center;
line-height: 30px;
right: -12px;
transform: rotate(49deg);
}
&#13;
<table style="border:1px solid black" class="sash">
<tr>
<td>one line text</td>
<td>two line text</td>
<td>three line text</td>
<td>four line text</td>
<td width="100" data-ribbon="One"></td>
</tr>
<tr>
<td>one line text</td>
<td>two line text</td>
<td>three line text</td>
<td>four line text</td>
<td width="100" data-ribbon="Two"></td>
</tr>
</table>
&#13;
答案 1 :(得分:0)
那个有点漂亮:)
.sash tr td{
position: relative;
overflow: hidden;
width: 200px;
height: 100px;
}
.sash tr td.prova:after {
content: attr(data-ribbon);
position: absolute;
width: 90px;
height: 40px;
background: #428bca;
color: white;
top: -5px;
text-align: center ;
line-height: 50px;
right: -34px;
transform: rotate(45deg);
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
<table style="border:1px solid black" class="sash">
<tr>
<td>one line text</td>
<td>two line text</td>
<td>three line text</td>
<td>four line text</td>
<td class="prova" data-ribbon="★">hhgfghg</td>
</tr>
<tr>
<td>one line text</td>
<td>two line text</td>
<td>three line text</td>
<td >fouer line text</td>
<td class="prova" data-ribbon="★"></td>
</tr>
</table>