统计
  • 文章总数:248 篇
  • 评论总数:624 条
  • 分类总数:7 个
  • 最后更新:4月2日

typecho 主题添加搜索框

本文阅读 1 分钟
首页 建站项目 正文
暂无AI摘要
摘要由智能技术生成

Typecho 默认都有搜索框的,由于喜欢的某些主题没有搜索框,可以安装下面步骤添加

打开header.php 文件 修改如下

  1. <script type="text/javascript">
  2. function button_search(){
  3. var G=document.getElementById('input_search').value;
  4. G="http://"+window.location.host+"/index.php/search/"+G+"/";
  5. window.location.href=G;
  6. }
  7. function key_search(e){
  8. var evt = window.event || e;
  9. if (evt.keyCode == 13){
  10. var G=document.getElementById('input_search').value;
  11. G="http://"+window.location.host+"/index.php/search/"+G+"/";
  12. window.location.href=G;
  13. }
  14. }
  15. </script>

以下为添加搜索框添加位置 (无内容404)

  1. <li class="island_logo_box">
  2. <div class="search">
  3. <input type="text" placeholder="请输入..." name="" id="input_search" value="" onkeydown="key_search(event);"/>
  4. <button onclick="button_search()"><i>搜索</i></button>
  5. </div>
  6. </li>

以下为添加搜索框添加位置 (带提示)

  1. <li class="island_logo_box">
  2. <div class="search">
  3. <form id="search" class="search-form" method="get" action="<?php $this->options->siteUrl(); ?>" role="search">
  4. <span class="search-box clearfix">
  5. <input type="text" id="input" class="input" name="s" required="true" placeholder="请输入..." maxlength="35" autocomplete="off">
  6. <button type="submit" class="spsubmit"><i class="icon-search"></i>搜索</button>
  7. </span>
  8. </form>
  9. </div>
  10. </li>

css 文件如下

  1. .search{
  2. width: 200px;
  3. display: flex;
  4. margin: 0 auto;
  5. /*border: 1px solid red;*/
  6. }
  7. .search input{
  8. float: left;
  9. flex: 4;
  10. height: 30px;
  11. width: 100px;
  12. outline: none;
  13. border: 1px solid red;
  14. box-sizing: border-box;
  15. padding-left: 10px;
  16. }
  17. .search button{
  18. float: right;
  19. flex: 1;
  20. height: 30px;
  21. width: 50px;
  22. color: lightslategray;
  23. border-style: none;
  24. outline: none;
  25. }
  26. .search button i{
  27. font-style: normal;
  28. }
  29. .search button:hover{
  30. font-style: normal;
  31. }
本文来自投稿,不代表本站立场,如若转载,请注明出处:
-- 展开阅读全文 --
Typecho 文章内链接在新窗口打开实现方式
« 上一篇 09-07
越南版《兄弟想你了》,潇公子完整版!
下一篇 » 09-07

发表评论

  • 泡泡
  • 阿呆
  • 阿鲁
  • 蛆音娘

行为验证™ 安全组件加载中...

V注册会员 L评论等级
R2 条回复
  1. 南柯一梦  广东省
    2022-01-15     Win 10 /    Chrome

    喜欢你的主题,是博主自己做的吗?

    1. 歲月安然  河北省
      2022-06-13     Win 10 /    Chrome

      @南柯一梦

      精简主题改了下

没有更多评论了
AI
AI在线
以确保在用户需要帮助时能够及时提供解答和技术支持
您好,这里是「乙未极客」,请问有什么能帮到您?