Html 想让字体图标可以点击吗
所以我对网络开发还不熟悉,我正在尝试将字体很棒的图标链接到我的社交档案中,但我不确定如何做到这一点。我尝试使用a href标签,但它使所有图标都将我带到一个站点,而不是我想要的站点。代码如下:Html 想让字体图标可以点击吗,html,font-awesome,Html,Font Awesome,所以我对网络开发还不熟悉,我正在尝试将字体很棒的图标链接到我的社交档案中,但我不确定如何做到这一点。我尝试使用a href标签,但它使所有图标都将我带到一个站点,而不是我想要的站点。代码如下: <i class="fa fa-dribbble fa-4x"></i> <i class="fa fa-behance-square fa-4x"></i> <i class="fa fa-linkedin-square fa-4x">&
<i class="fa fa-dribbble fa-4x"></i>
<i class="fa fa-behance-square fa-4x"></i>
<i class="fa fa-linkedin-square fa-4x"></i>
<i class="fa fa-twitter-square fa-4x"></i>
<i class="fa fa-facebook-square fa-4x"></i>
我想让这些图标中的每一个都转到各自的配置文件。有什么建议吗?您可以将这些元素包装在锚定标记中 像这样
<a href="your link here"> <i class="fa fa-dribbble fa-4x"></i></a>
<a href="your link here"> <i class="fa fa-behance-square fa-4x"></i></a>
<a href="your link here"> <i class="fa fa-linkedin-square fa-4x"></i></a>
<a href="your link here"> <i class="fa fa-twitter-square fa-4x"></i></a>
<a href="your link here"> <i class="fa fa-facebook-square fa-4x"></i></a>
注意:将
href=“此处的链接”
替换为所需的链接,例如href=”https://www.stackoverflow.com“
如果您不想将其添加到链接中,您可以将其包含在一个范围内,这样就可以了
在css中,您可以:
#clickableAwesomeFont {
cursor: pointer
}
然后在java脚本中,您只需添加一个单击处理程序
如果它实际上是而不是链接,我认为这会更干净,使用链接会改变其语义并滥用其含义。使用bootstrap和font-awesome
<a class="btn btn-large btn-primary logout" href="#">
<i class="fa fa-sign-out" aria-hidden="true">Logout</i>
</a>
我发现这最适合我的用例:
<i class="btn btn-light fa fa-dribbble fa-4x" href="#"></i>
<i class="btn btn-light fa fa-behance-square fa-4x" href="#"></i>
<i class="btn btn-light fa fa-linkedin-square fa-4x" href="#"></i>
<i class="btn btn-light fa fa-twitter-square fa-4x" href="#"></i>
<i class="btn btn-light fa fa-facebook-square fa-4x" href="#"></i>
在css中添加一个类:
.fa-clickable {
cursor:pointer;
outline:none;
}
然后将该类添加到可单击图标(也是一个id,以便您可以区分单击):
你所要做的就是在HTML中包装你的字体图标链接
用锚定标签。
采用以下格式:
请按以下方式使用。
可以使用以上选项,以便显示fa图标,也可以打开fa图标
单击功能可以编写逻辑
你有这样的例子吗?这与我的案例不符。这对2014年给出的答案有什么补充?
<i class="fa fa-dribbble fa-4x fa-clickable" id="epd-dribble"></i>
<i class="fa fa-behance-square fa-4x fa-clickable" id="epd-behance"></i>
<i class="fa fa-linkedin-square fa-4x fa-clickable" id="epd-linkedin"></i>
<i class="fa fa-twitter-square fa-4x fa-clickable" id="epd-twitter"></i>
<i class="fa fa-facebook-square fa-4x fa-clickable" id="epd-facebook"></i>
$(document).on("click", "i", function(){
switch (this.id) {
case "epd-dribble":
// do stuff
break;
// add additional cases
}
});
<a href="#"><i class="fab fa-facebook-square"></i></a>
<a href="#"><i class="fab fa-twitter-square"></i></a>
<a href="#"><i class="fas fa-basketball-ball"></i></a>
<a href="#"><i class="fab fa-google-plus-square"></i></a>
All you have to do is wrap your font-awesome icon link in your HTML
with an anchor tag.
Following this format:
<a href="Link here"> <font-awesome icon code> </a>
Please use Like below.
<a style="cursor: pointer" **(click)="yourFunctionComponent()"** >
<i class="fa fa-dribbble fa-4x"></i>
</a>