使用本地CSS美化搜索页面HTML文件

ChatGPT4o 使用 ChatGPT 4o 回答

问题:

请将以下index文件进行美化,要求使用本地的CSS样式,<!DOCTYPE html>

<html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>搜索页面</title> <!-- 引入Bootstrap CSS --> <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet"> <style> body { display: flex; justify-content: center; align-items: center; height: 100vh; background-color: #f8f9fa; } .search-container { background: #fff; padding: 2rem; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } </style> </head> <body> <div class="search-container"> <h2 class="text-center mb-4">搜索黑名单</h2> <form action="index.php" method="POST"> <div class="form-group"> <input type="text" class="form-control" name="search" placeholder="请输入搜索内
回答:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>搜索页面</title>
    <!-- 引入本地的CSS样式 -->
    <link rel="stylesheet" href="styles.css">
    <style>
        body {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            background-color: #f8f9fa;
            margin: 0;
            font-family: Arial, sans-serif;
        }
        .search-container {
            background: #fff;
            padding: 2rem;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 100%;
            max-width: 400px;
        }
        .search-container h2 {
            margin-bottom: 1.5rem;
            font-size: 1.5rem;
            color: #333;
        }
        .form-group {
            margin-bottom: 1rem;
        }
        .form-control {
            height: 2.5rem;
            padding: 0.5rem;
            font-size: 1rem;
            border: 1px solid #ced4da;
            border-radius: 4px;
        }
        .btn-primary {
            width: 100%;
            padding: 0.5rem;
            font-size: 1rem;
            border: none;
            border-radius: 4px;
            background-color: #007bff;
            color: #fff;
            cursor: pointer;
        }
        .btn-primary:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <div class="search-container">
        <h2 class="text-center">搜索黑名单</h2>
        <form action="index.php" method="POST">
            <div class="form-group">
                <input type="text" class="form-control" name="search" placeholder="请输入搜索内容">
            </div>
            <button type="submit" class="btn btn-primary">搜索</button>
        </form>
    </div>
</body>
</html>

在这个版本中,我移除了对Bootstrap的引用,并使用本地的CSS样式来美化页面。你可以将CSS样式直接嵌入到HTML文件中,也可以将其放在一个单独的CSS文件(如styles.css)中。这样可以确保页面在没有外部依赖的情况下也能正常显示。