gpt4 book ai didi

html - 使用 :after 将 Font Awesome 图标添加到输入类型

转载 作者:太空宇宙 更新时间:2023-11-03 21:09:20 25 4
gpt4 key购买 nike

我正在尝试在输入字段上使用 :after CSS,但它不起作用。

我做错了什么?我应该使用另一个选择器吗?

._ght{
width: 100%;
display: inline-block;
text-align: center;
margin-top: 10px;
}
._ght input[type="text"]{
width: 48%;
line-height: 32px;
font-size: 26px;
border: solid 1px #94a6ae;
}
._ght input:after{
font-family: FontAwesome;
content: "\f06e";
}
<div class="_ght">
<input type="text" name="">
</div>

这里的例子:

enter image description here

最佳答案

正如@zgood 所写::before:after 仅适用于 html 元素。

我建议使用额外的 span 在该输入后显示您的图标。

  <span class="addon"></span>

无需额外的 HTML,将您的图标添加到输入容器的 :after 元素中。

._ght{
width: 100%;
display: inline-block;
text-align: center;
margin-top: 10px;
}
._ght input[type="text"]{
width: 48%;
line-height: 32px;
font-size: 26px;
margin-left: 10px;
border: solid 1px #94a6ae;
}
._ght:after{
font-family: FontAwesome;
font-size: 25px;
content: "\f06e";
border: 1px solid grey;
padding: 6px 4px 3px 4px;
margin-left: -5px;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

<div class="_ght">
<input type="text" name="">
</div>

关于html - 使用 :after 将 Font Awesome 图标添加到输入类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48648588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com