Html 将类应用于td/span中的文本?
我想将超链接类应用于td下的文本,而不是完整的tdHtml 将类应用于td/span中的文本?,html,css,Html,Css,我想将超链接类应用于td下的文本,而不是完整的td <td id="myClass"> Apply Class to text </td> #myClass { cursor: pointer; padding-right: 100px ; padding-bottom: 100px; padding-right: 100px; } 将类应用于文本 #我的班级{ 光标:指针; 右边填充:100px; 填充
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}
将类应用于文本
#我的班级{
光标:指针;
右边填充:100px;
填充底部:100px;
右边填充:100px;
}
我试过了
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}
<td> <span id="myClass"> Apply Class to text </span></td>
将类应用于文本
但它不起作用,因为这也会应用于完整的td区域。您必须像这样hiperlink
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}
<td>
<a href="url" id="myClass">Apply Class to text</a>
</td>
我希望我能帮助您:-D为跨度创建一个边界,并检查它是否占用了整个td。如果是,那么您的代码工作得很好。您可以调整跨度的边距,使其在td内创建光标不会改变的空间。您需要先了解一些事情
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}
元素的id
不应命名为“myClass”。它只是不正确——命名约定
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}
其次,您只将CSS应用于元素。您可以通过以下方式使用该元素的`id来指定:
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}
如果您的html为:
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}
<td>
Some random text here
<span id="linkTypeSpan"> Apply Class to text </span> Some other text here
</td>
还有其他方法可以实现这一点(其他选择器)。你应该读一下
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}
希望这有帮助 我想我想要的是改变
边距的填充
,比如:
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}
#myClass {
cursor: pointer;
color:blue;
margin-right: 100px ;
margin-bottom: 100px;
margin-right: 100px;
}
在这里它似乎工作得很好:但是如果你创建一个标签的超链接,什么是超链接类?我认为您需要展示一个代码不在JSFIDLE上工作的示例,因为td和span高度和宽度相同,所以它看起来就像您所说的那样..边距底部没有任何影响?即使在您的小提琴示例中,如果我更改边距底部,它也不会显示任何影响
<td id="myClass"> Apply Class to text </td>
#myClass {
cursor: pointer;
padding-right: 100px ;
padding-bottom: 100px;
padding-right: 100px;
}