【发布时间】:2022-01-06 07:16:15
【问题描述】:
我正在使用以下 WordPress 函数来输出 WP 搜索表单:echo get_search_form();
前端顶栏上的结果输出:
<form class="search-form" method="get" action="http://bio-04.eproofs.ca/" role="search">
<label class="search-form-label screen-reader-text" for="searchform-1"> To search, type and hit enter.</label>
<input class="search-form-input" type="search" name="s" id="searchform-1" placeholder=" To search, type and hit enter.">
<input class="search-form-submit" type="submit" value="Search"><meta content="http://bio-04.eproofs.ca/?s={s}">
</form>
我想在占位符内添加一个搜索图标(放大镜)。目前我只有占位符内的文本。我尝试使用 before 伪元素没有运气。类似于:
label:before {
content: "";
position: absolute;
left: 10px;
top: 0;
bottom: 0;
width: 20px;
background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='25' height='25' viewBox='0 0 25 25' fill-rule='evenodd'%3E%3Cpath d='M16.036 18.455l2.404-2.405 5.586 5.587-2.404 2.404zM8.5 2C12.1 2 15 4.9 15 8.5S12.1 15 8.5 15 2 12.1 2 8.5 4.9 2 8.5 2zm0-2C3.8 0 0 3.8 0 8.5S3.8 17 8.5 17 17 13.2 17 8.5 13.2 0 8.5 0zM15 16a1 1 0 1 1 2 0 1 1 0 1 1-2 0'%3E%3C/path%3E%3C/svg%3E") center / contain no-repeat;
}
该网站可以在这里找到:http://bio-04.eproofs.ca/
是否可以仅使用 css 和输出的现有类来做到这一点?
【问题讨论】: