CSS——利用bootstrap实现搜索界面

小序

纵有风情万种,依然情有独钟
生活的样子,大抵是不一样的
看清风拂过,看人潮汹涌
向生活说
你好!

正文

继之前的CSS内容,大抵上阐述了简单的用法
今天为了更好地实现网页的设计,我们可以利用bootstrap实现相关的内容
不管是简单的按钮、表格,还是布局、导航… 可以说,这十分便利我们的代码编写
我们仅仅需要导入相关的css和js 文件,即可应用相关的样式内容

bootstrap用法

下载

想要使用bootstrap ,首先需要下载相关的内容
下载链接如下: bootstrap下载
可根据需要进行选择,可只要css和js 的文件,也可选择全部的文件

导入

// 导入css、js
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
<script src="/static/js/bootstrap.min.js"></script>

示例

按钮

<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-light">Light</button>
<button type="button" class="btn btn-dark">Dark</button>

按钮样式
layout

<div class="container text-center">
  <div class="row align-items-start">
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
    <div class="col">
      One of three columns
    </div>
  </div>
</div>

布局情况

应用——搜索功能实现

本次是借助bootstrap 实现一个类似于百度搜索功能的页面
下面我们老规矩,直接步入正题,以代码展现功能
搜索页面——search.html

<!DOCTYPE html>
<html>
<head>
    <title>Search</title>
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
    <style>
        .container {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 500px;
        }

        .container input[type="text"] {
            width: 800px;
            padding: 10px;
        }
    </style>
</head>
<body>
    <h1 style="text-align: center;">fancymeng</h1>
    <form method="POST">
        <div class="container">
            <input type="text" class="text" name="query" placeholder="Enter your query">
            <a id="submit" href="/data" class="btn btn-primary" role="button">搜索</a>
        </div>
    </form>
    <script>
        document.getElementById('submit').addEventListener('click', function() {
          var query = document.getElementsByName('query')[0].value;
          this.href = '/data?query=' + query;
        });
    </script>
</body>
</html>

搜索页面实现如下
实现
result.html

<!DOCTYPE html>
<html>
<head>
    <title>Result</title>
    <link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css">
</head>
<body>
    <h1 style="text-align: center; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;">fancymeng</h1>
    <table id="data-table" class="table table-striped table-hover">
        <thead>
            <tr>
                <th>First_word</th>
                <th>word</th>
                <th>explain</th>
            </tr>
        </thead>
        <tbody>
            {% for row in data %}
            <tr>
                <td>{{ row[0] }}</td>
                <td>{{ row[1] }}</td>
                <td>{{ row[2] }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</body>
</html>

搜索应用示例
本应用搜索采用了模糊索引
在这里插入图片描述
在这里插入图片描述
可以看到,上面的效果基本上都依靠了bootstrap 来实现
输入框、链接(以按钮形式显现)
最终结果以表格形式展现(渐变色)上面的bootstrap 链接有相关的形式

本文主要是介绍css 的相关内容,就不再多言相关的其他应用了
以后可更新相关的内容时会再次提及此项目
对全部内容感兴趣的友友们,欢迎评论或者私信
也可关注后续的内容,会对文本处理、数据库内容(MySQL)以及前后端搭建的实现会陆续发文
相关的资源会在日后同步

结束语

向生活说你好,
向当下说你好,
向自己说,
You can do it !

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

fancymeng

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值