前端开发:实战项目之拉勾网

实战项目之拉勾网

实战项目之拉勾网:拉勾网是一个知名的招聘网站,通过实战项目可以学习如何制作一个响应式的招聘网站,包括职位列表、搜索框、个人信息页面等。
  1. 首页 (index.html)
  2. 职位详情页 (job-detail.html)
  3. 个人信息页 (profile.html)

1. 首页 (index.html)

<!DOCTYPE html><html lang="zh"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>招聘网首页</title>
    <link rel="stylesheet" href="styles.css"></head><body>
    <header>
        <div class="container">
            <h1>招聘网</h1>
            <nav>
                <a href="index.html">首页</a>
                <a href="profile.html">个人信息</a>
            </nav>
        </div>
    </header>
    <main>
        <div class="container">
            <section class="search-bar">
                <input type="text" id="search" placeholder="搜索职位...">
                <button onclick="searchJobs()">搜索</button>
            </section>
            <section class="job-list">
                <!-- 职位列表将通过JavaScript动态生成 -->
            </section>
        </div>
    </main>
    <footer>
        <div class="container">
            <p>&copy; 2024 招聘网 - 版权所有</p>
        </div>
    </footer>
    <script src="script.js"></script></body></html>

2. 职位详情页 (job-detail.html)

<!DOCTYPE html><html lang="zh"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>职位详情</title>
    <link rel="stylesheet" href="styles.css"></head><body>
    <header>
        <div class="container">
            <h1>招聘网</h1>
            <nav>
                <a href="index.html">首页</a>
                <a href="profile.html">个人信息</a>
            </nav>
        </div>
    </header>
    <main>
        <div class="container">
            <section class="job-detail">
                <!-- 职位详细信息将通过JavaScript动态生成 -->
            </section>
        </div>
    </main>
    <footer>
        <div class="container">
            <p>&copy; 2024 招聘网 - 版权所有</p>
        </div>
    </footer>
    <script src="script.js"></script></body></html>

3. 个人信息页 (profile.html)

<!DOCTYPE html><html lang="zh"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人信息</title>
    <link rel="stylesheet" href="styles.css"></head><body>
    <header>
        <div class="container">
            <h1>招聘网</h1>
            <nav>
                <a href="index.html">首页</a>
                <a href="profile.html">个人信息</a>
            </nav>
        </div>
    </header>
    <main>
        <div class="container">
            <section class="profile">
                <h2>个人信息</h2>
                <p>姓名: 张三</p>
                <p>邮箱: zhangsan@example.com</p>
                <!-- 更多个人信息 -->
            </section>
        </div>
    </main>
    <footer>
        <div class="container">
            <p>&copy; 2024 招聘网 - 版权所有</p>
        </div>
    </footer></body></html>

CSS (styles.css)

body {
    font-family: 'Arial', sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
}

header {
    background: #007bff;
    color: white;
    padding: 10px 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

header .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
}

nav a {
    color: white;
    margin: 0 15px;
    text-decoration: none;
    font-weight: bold;
}

nav a:hover {
    text-decoration: underline;
}

main {
    padding: 20px 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.search-bar {
    margin-bottom: 30px;
    text-align: center;
}

.search-bar input {
    padding: 10px;
    width: 60%;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.search-bar button {
    padding: 10px 20px;
    border: none;
    background: #007bff;
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.search-bar button:hover {
    background: #0056b3;
}

.job-list {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.job-item {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.job-item h2 {
    margin: 0;
    font-size: 18px;
}

.job-item a {
    text-decoration: none;
    color: #007bff;
}

.job-item a:hover {
    text-decoration: underline;
}

.job-detail {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.profile {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

footer {
    background: #333;
    color: white;
    padding: 10px 0;
    text-align: center;
}

footer .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

JavaScript (script.js)

// 示例职位数据const jobs = [
    { id: 1, title: '前端开发工程师', company: 'ABC科技', location: '北京', description: '负责前端开发工作' },
    { id: 2, title: '后端开发工程师', company: 'XYZ科技', location: '上海', description: '负责后端系统开发' }
];

function renderJobList() {
    const jobListElement = document.querySelector('.job-list');
    jobListElement.innerHTML = jobs.map(job => `
        <div class="job-item">
            <h2><a href="job-detail.html?id=${job.id}">${job.title}</a></h2>
            <p>公司: ${job.company}</p>
            <p>地点: ${job.location}</p>
        </div>
    `).join('');
}

function renderJobDetail() {
    const params = new URLSearchParams(window.location.search);
    const jobId = parseInt(params.get('id'));
    const job = jobs.find(job => job.id === jobId);
    
    if (job) {
        const jobDetailElement = document.querySelector('.job-detail');
        jobDetailElement.innerHTML = `
            <h2>${job.title}</h2>
            <p>公司: ${job.company}</p>
            <p>地点: ${job.location}</p>
            <p>描述: ${job.description}</p>
        `;
    }
}

function searchJobs() {
    const query = document.getElementById('search').value.toLowerCase();
    const filteredJobs = jobs.filter(job => job.title.toLowerCase().includes(query));
    const jobListElement = document.querySelector('.job-list');
    jobListElement.innerHTML = filteredJobs.map(job => `
        <div class="job-item">
            <h2><a href="job-detail.html?id=${job.id}">${job.title}</a></h2>
            <p>公司: ${job.company}</p>
            <p>地点: ${job.location}</p>
        </div>
    `).join('');
}

// 在首页加载时渲染职位列表if (document.querySelector('.job-list')) {
    renderJobList();
}

// 在职位详情页加载时渲染职位详情if (document.querySelector('.job-detail')) {
    renderJobDetail();
}

要点

  1. 响应式设计:使用了 max-widthflex 布局来确保页面在不同设备上的适配性。
  2. 现代化样式:使用了更多现代的 CSS 样式,如圆角、阴影和更清晰的按钮样式。
  3. 容器中心化:通过 .container 类确保内容在大屏幕上居中,并保持适当的边距。
  4. 提升可读性:增加了更显著的颜色对比和按钮的悬停效果,提升了用户体验。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值