因为喜欢,所以开始,因为热爱,所以坚持
现在位置:首页 > 帮助教程 > 模板设计之头部搜索的实现

模板设计之头部搜索的实现

作者:金沙 分类:帮助教程 时间:2022-12-08 浏览:394 评论:1

不知道对不对,因为没有教程,是摸索的,放在这里
一、普通的写法是form action,然后input
再button,
二、测试成功
我发现很多模板的搜索结果是
http://XXXX.COM/?keyword=十
于是,我改写

 <form method="get" action="/?keyword="  class="search-form d-flex align-items-center">
                              <button type="submit" class="search-submit bg-transparent pl-0 text-start">
                                  <svg class="icon icon-search" width="20" height="20" viewBox="0 0 20 20" fill="none"
                                      xmlns="http://www.w3.org/2000/svg">
                                      <path
                                          d="M7.75 0.250183C11.8838 0.250183 15.25 3.61639 15.25 7.75018C15.25 9.54608 14.6201 11.1926 13.5625 12.4846L19.5391 18.4611L18.4609 19.5392L12.4844 13.5627C11.1924 14.6203 9.5459 15.2502 7.75 15.2502C3.61621 15.2502 0.25 11.884 0.25 7.75018C0.25 3.61639 3.61621 0.250183 7.75 0.250183ZM7.75 1.75018C4.42773 1.75018 1.75 4.42792 1.75 7.75018C1.75 11.0724 4.42773 13.7502 7.75 13.7502C11.0723 13.7502 13.75 11.0724 13.75 7.75018C13.75 4.42792 11.0723 1.75018 7.75 1.75018Z"
                                          fill="black" />
                                  </svg>
                              </button>
                              <div class="search-input mr-4">
                                  <input type="text" placeholder="Search your products..." name="keyword" autocomplete="off">
                              </div>
                              <div class="search-close">
                                  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"
                                      fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
                                      stroke-linejoin="round" class="icon icon-close">
                                      <line x1="18" y1="6" x2="6" y2="18"></line>
                                      <line x1="6" y1="6" x2="18" y2="18"></line>
                                  </svg>
                              </div>
                          </form>

就是在里面,将Action指向?keword,然后input给了个name

推荐阅读:

评论列表
挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

清空信息
关闭评论
听风与梦
听风与梦初来乍到 Lv.1
#1
这个在`module.php`文件不是有吗,侧栏的搜索,直接改到头部就行了
2022-12-10 22:33回复