![](/img/trans.png)
[英]How to add custom css of react-bootsrap component in next js
[英]How can I add a location icon in the react bootsrap FormControl text field component?
const LocationSearchComponent = () => {
return (
<Form className="locationForm">
<Form.Group>
<Form.Control
className="locationSearchTextField"
type="text"
placeholder=" Enter your location"
/>
</Form.Group>
</Form>
);
};
您可以使用 CDN 將 font-awesome 添加到index.html
中,如下所示:
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
/>
並將此 css 添加到您的組件中:
.locationSearchTextField::-webkit-input-placeholder {
font-family: Circular, "Font Awesome 5 Free";
font-weight: 900;
}
.locationSearchTextField::-moz-placeholder {
font-family: Circular, "Font Awesome 5 Free";
font-weight: 900;
}
.locationSearchTextField:-ms-input-placeholder {
font-family: Circular, "Font Awesome 5 Free";
font-weight: 900;
}
您可以查看此沙箱,了解此解決方案的實時工作示例。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.