Html 使用:after将字体图标添加到输入类型
我试图在输入字段上使用Html 使用:after将字体图标添加到输入类型,html,css,Html,Css,我试图在输入字段上使用:afterCSS,但它不起作用 我做错了什么?我应该使用另一个选择器吗 \u右{ 宽度:100%; 显示:内联块; 文本对齐:居中; 边缘顶部:10px; } .\u右输入[type=“text”]{ 宽度:48%; 线高:32px; 字号:26px; 边框:实心1px#94a6ae; } .右输入:后{ 字体系列:Fontsome; 内容:“\f06e”; } 这应该可以解决您的问题 <link rel="stylesheet" href="https://cd
:after
CSS,但它不起作用
我做错了什么?我应该使用另一个选择器吗
\u右{
宽度:100%;
显示:内联块;
文本对齐:居中;
边缘顶部:10px;
}
.\u右输入[type=“text”]{
宽度:48%;
线高:32px;
字号:26px;
边框:实心1px#94a6ae;
}
.右输入:后{
字体系列:Fontsome;
内容:“\f06e”;
}
这应该可以解决您的问题
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
search{
float: left; width: 800px;
margin-left: 220px
}
.search input[type=text]{
padding: 10px;
width: 600px;
border-right: none;
border: 1px solid #f1f1f1;
float: left;
border-bottom-left-radius: 5px;
border-top-left-radius: 5px;
}
.search button[type=submit]{
padding:9px 20px;
border-left: none;
float: left;
border: 1px solid #f1f1f1;
border-bottom-right-radius: 5px;
border-top-right-radius: 5px;
color: #888;
}
</style>
<div class="search">
<form id="search">
<input type="text" placeholder="Search for Products and Services"/>
<button type="submit">
<i class="fa fa-search" style="font-size: 18px;"></i>
</button>
</form>
</div>
搜寻{
浮动:左;宽度:800px;
左边距:220px
}
.search输入[类型=文本]{
填充:10px;
宽度:600px;
边界权:无;
边框:1px实心#f1f1;
浮动:左;
边框左下半径:5px;
边框左上半径:5px;
}
.搜索按钮[类型=提交]{
填充:9px 20px;
左边界:无;
浮动:左;
边框:1px实心#f1f1;
边框右下半径:5px;
边框右上角半径:5px;
颜色:#888;
}
这应该可以解决您的问题
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
search{
float: left; width: 800px;
margin-left: 220px
}
.search input[type=text]{
padding: 10px;
width: 600px;
border-right: none;
border: 1px solid #f1f1f1;
float: left;
border-bottom-left-radius: 5px;
border-top-left-radius: 5px;
}
.search button[type=submit]{
padding:9px 20px;
border-left: none;
float: left;
border: 1px solid #f1f1f1;
border-bottom-right-radius: 5px;
border-top-right-radius: 5px;
color: #888;
}
</style>
<div class="search">
<form id="search">
<input type="text" placeholder="Search for Products and Services"/>
<button type="submit">
<i class="fa fa-search" style="font-size: 18px;"></i>
</button>
</form>
</div>
搜寻{
浮动:左;宽度:800px;
左边距:220px
}
.search输入[类型=文本]{
填充:10px;
宽度:600px;
边界权:无;
边框:1px实心#f1f1;
浮动:左;
边框左下半径:5px;
边框左上半径:5px;
}
.搜索按钮[类型=提交]{
填充:9px 20px;
左边界:无;
浮动:左;
边框:1px实心#f1f1;
边框右下半径:5px;
边框右上角半径:5px;
颜色:#888;
}
正如@zgood所写::before
和:after
只处理html元素
我建议在输入之后使用额外的span
来显示图标
<span class="addon"></span>
正如@zgood所写::before
和:after
只处理html元素
我建议在输入之后使用额外的span
来显示图标
<span class="addon"></span>
:在
之前和:在
之后,不要使用
。只有可以包含html内容的元素才能访问。您试图实现什么?也许我们可以帮你。@Friday Ameh像这样@Stickers我有编辑标题你可以使用:after在\u ght
元素:before
和:after
上不使用
。只有可以包含html内容的元素才能访问。您试图实现什么?也许我们可以帮助你。@Friday Ameh像这样@Stickers我有编辑标题你可以使用:在\u ght
元素上之后这是一个更好的解决方案,但可以使用更好的解释。这是一个更好的解决方案,但可以使用更好的解释。