如何用H5+CSS+JS写一个简单的招聘网站

news2024/9/20 7:46:10

大家好,我是猿码叔叔,一个 Java 语言开发者。应网友要求,写一个简单的招聘页面。由于技术原因,页面相对简单,朋友们可以选择性的阅读,如果对您有帮助,也可直接拿去使用,因为接下来除了闲言碎语还有源代码干货。

一、内容介绍

这个简单的招聘网站,具备简单的响应式功能。页面元素包含:横向菜单、职位搜索与选择、简历表格、轮播图。页面没有实现与后端交互的功能,后续有需要可以更新,包括更丰富的功能都可以持续更新与扩展。

二、谈谈我对响应式的理解

  • 布局

我们应当做好页面的布局设计。一般的网站布局都会大致分为 Header、Body 和 Footer 以及 Others 四个部分。对于前三个部分仍然可以再细分为相应的“块”,每个块包含相应要展示的内容。这些块可以是竖着排列,或者是横向并排排列,亦或是复杂的瀑布式排列。排列的布局应当符合人类的基本审美标准,比如对称、右重左轻等等。

  • 自适应调整

自适应调整就是根据不同的设备来调整页面的属性,达到不同的设备布局仍然排列有序,符合我们的审美标准。这一点是建立在我们事先做好了页面布局的工作。

常见的自适应调整,我们可以使用 @media、flex、grid 和 multiCol 来实现。具体的功能大家可以去阅读 MDN Web Docsicon-default.png?t=N7T8https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Responsive_Design

这篇文章详细介绍了以上属性的各个功能。

三、代码

        注:以下代码页面布局借鉴某招聘网站。

  • CSS部分
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

#main-menu {
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 100%;
    box-shadow: 2px 2px 6px 2px rgba(0, 0, 0, 0.3);
}

.main-body {
    position: relative;
    padding: 30px;
    display: flex;
    justify-content: center;
}

.carousel-space {
}

.search-space {
    margin-bottom: 20px;
}

.fake-input-box {
    border: solid 1px lightgrey;
    height: 45px;
    position: relative;
    border-radius: 2px;
    display: flex;
    justify-content: center;
}

.fake-input-search {
    height: 100%;
    border: none;
    width: 80px;
    background: red;
    color: white;
    border-top-right-radius: 2px;
    border-bottom-right-radius: 2px;
    float: right;
    cursor: pointer;
}

.none-style-input {
    border: none;
    height: 100%;
    width: 100%;
    padding: 2px 5px;
    outline-style: none;
}

.none-style-ul {
    list-style: none;
}

.main-menu-ul {
    display: flex;
    justify-content: center;
}

.main-menu-item {
    padding: 12px 16px;
}

.main-menu-item:not(li:first-child) {
    cursor: pointer;
}

.main-menu-item:first-child {
    margin-right: 50px;
}

.main-menu-item:last-child {
    margin-left: 50px;
    color: blue;
}

.main-menu-item:hover:not(li:first-child, li:last-child) {
    background: red;
    color: white;
}

.addr-switch {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 3px;
}

.addr-switch:hover {
    color: dodgerblue;
}

.main-footer {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    flex: 1;
    border-top: solid 1px rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.5);
    font-size: 12px;
    line-height: 20px;
    padding: 10px 0;
}

.company-info {
    align-items: center;
}

.hiring-info {
    margin-right: 10px;
    text-align: center;
    color: rgba(0, 0, 0, 0.7);
}

.alternative-info {

}

.hiring-info-title {
    margin-top: 16px;
}

.jobs-selection {
    margin-top: 30px;
}

.jobs-selection > ul > li {
    padding: 20px 26px;
    border-top: solid 1px rgba(0, 0, 0, 0.1);
    cursor: pointer;
}

.jobs-selection > ul > li:first-child {

}

.drawer-container {
    position: fixed;
    height: 100%;
    width: 600px;
    right: -600px;
    top: 0;
    background: white;
    box-shadow: 2px 2px 6px 2px rgba(0, 0, 0, 0.2);
    transition: transform 1.5s;
    max-width: 100%;
}

.show {
    transform: translateX(-600px); /* 展开抽屉 */
    transition: transform 1.5s;
}

.drawer-header {
    padding: 10px 16px;
    border-bottom: solid 1px rgba(0, 0, 0, 0.2);
    color: lightslategray;
}

.drawer-body {
    padding: 10px;
    height: auto;
}

.close-icon {
    float: right;
    cursor: pointer;
}

.form-item:first-child {
    display: flex;
    flex-direction: row;
}

.form-item {
    padding: 10px;
    width: 100%;
    height: auto;
}

.form-item > label {
    display: flex;
    flex: 2;
}

.form-item > label > span {
    width: 30%;
    vertical-align: bottom;
    color: rgba(0, 0, 0, 0.6);
}

.form-item > label > input {
    width: 100%;
    height: 30px;
    padding: 4px;
}

.drawer-footer {
    float: right;
}

.confirm-btn {
    background: red;
}

.close-btn {
    background: rgba(0, 0, 0, 0.4);
}

.confirm-btn, .close-btn {
    outline-style: none;
    border: none;
    padding: 4px 6px;
    margin-right: 8px;
    cursor: pointer;
    color: white;
}

img {
    max-width: 100%;
}
  • H5+JS部分
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0,
        minimum-scale=1.0, user-scale=0">
    <title>Title</title>
    <link type="text/css" rel="stylesheet" href="css/a.css">

</head>
<body>
<div class="main">
    <header class="main-header">
        <menu id="main-menu"></menu>
    </header>
    <main class="main-body">
        <div class="hiring-info">
            <div class="hiring-info-title">
                <h5>选择你心仪的职业</h5>
            </div>
            <div class="jobs-selection" id = 'jobs-selection'>
            </div>
        </div>
        <div class="carousel-space">
            <div class="search-space">
                <div class="fake-input-box">
                    <input class="none-style-input" placeholder="搜索热门职业">
                    <button class="fake-input-search">搜索</button>
                </div>
            </div>
            <div class="carousel-img-group">
                <div>
                    <img id="carousel-img" alt="" width="600px" height="500px" src="carouselImg/c.jpg">
                </div>
            </div>
        </div>
        <div class="other-info"></div>
    </main>
    <footer class="main-footer">
        <div class="company-info">
            <p>未经 xxxxxx.com 同意,不得转载本网站之所有招聘信息及作品 xxxxx招聘网版权所有</p>
            <p>京ICP备xxxxxxx号  合字xx-xxxxxx</p>
            <p>京公网安备 1xxxxxxxxxxxxx号  人力资源许可证:xxxxxxxxxxxxxxxxx号</p>
            <p>网上有害信息举报专区  违法不良信息举报电话:400-xxx-xxxx 关爱未成年举报热线:400-xxx-xxxx-x</p>
            <p>xx区人力资源与社会保障局监督电话</p>
        </div>
        <div class="alternative-info">
            <p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
            <p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
            <p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
            <p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
            <p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>
        </div>
    </footer>
    <div class="drawer-container">
        <div class="drawer-header">
            <span>
                填写你的应聘信息
            </span>
            <span onclick="closeDrawerContainer()" class="close-icon">×</span>
        </div>
        <div class="drawer-body">
            <form>
                <p class="form-item">
                    <label for="employee-name">
                        <span>姓名: </span>
                        <input id="employee-name"/>
                    </label>
                </p>
                <p class="form-item">
                    <label for="employee-age">
                        <span>年龄: </span>
                        <input id="employee-age"/>
                    </label>
                </p>
                <p class="form-item">
                    <label for="employee-address">
                        <span>目前住址: </span>
                        <input id="employee-address"/>
                    </label>
                </p>
                <p class="form-item">
                    <label for="workplace-expected">
                        <span>希望工作的城市: </span>
                        <input id="workplace-expected"/>
                    </label>
                </p>
                <p class="form-item">
                    <label for="employee-eduction">
                        <span>您的学历: </span>
                        <input id="employee-eduction"/>
                    </label>
                </p>
                <p class="form-item">
                    <label for="employee-major">
                        <span>您的专业:</span>
                        <input id="employee-major"/>
                    </label>
                </p>
                <p class="form-item">
                    <label for="employee-work-experiences">
                        <span>工作经历:</span>
                        <input id="employee-work-experiences"/>
                    </label>
                </p>
            </form>
        </div>
        <div class="drawer-footer">
            <button class="confirm-btn" onclick="">确定</button>
            <button class="close-btn" onclick="closeDrawerContainer()">关闭</button>
        </div>
    </div>
</div>
</body>
<script src="js/utils.js"></script>
<script type="text/javascript">

    window.onload = ()=> {
        this.initializeMenu();
        const intervalId = this.triggerCarousel();
        this.initializeCarousel(intervalId);
        this.initializeJobGenres();
    }

    const menuNames = [
        {id: '0', name: '全国', icon: ''},
        {id: '1', name: '首页', icon: ''},
        {id: '2', name: '城市频道', icon: ''},
        {id: '3', name: '政企招聘', icon: ''},
        {id: '4', name: '校园招聘', icon: ''},
        {id: '5', name: '高端职位', icon: ''},
        {id: '6', name: '海外招聘', icon: ''},
        {id: '7', name: '我要投简历', icon: ''},
    ];

    const jobGenre = ['技术', '产品', '设计', '市场', '运营', '销售', '管理'];

    const carouselPics = ['a', 'b', 'c'];
    function initializeCarousel(id) {
        const carousel = iDomById('carousel-img');
        carousel.onmouseover = () => {
            clearInterval(id);
        }

        carousel.onmouseleave = () => {
            this.initializeCarousel(triggerCarousel());
        }
    }

    function closeDrawerContainer() {
        const drawer = document.querySelector('.drawer-container');
        if (drawer.classList.contains('show')) {
            drawer.classList.remove('show'); // 关闭抽屉
        } else {
            drawer.classList.add('show'); // 打开抽屉
        }
    }

    function initializeJobGenres() {
        const parent = iDomById('jobs-selection');
        const ul = document.createElement('ul');
        ul.className = 'none-style-ul';
        const frag = document.createDocumentFragment();
        for (const name of jobGenre) {
            const li = document.createElement('li');

            li.onmouseover = () => {
                li.style.background = 'coral';
                li.style.color = 'white';
            }

            li.onmouseleave = () => {
                li.style.background = 'white';
                li.style.color = 'rgba(0, 0, 0, 0.7)';
            }

            li.innerText = name;
            frag.append(li);
        }
        ul.appendChild(frag);
        parent.appendChild(ul);
    }

    function triggerCarousel() {
        const obj = {x: 0};
        return setInterval(setCarouselSrc, 2000, obj);
    }

    function setCarouselSrc(obj) {
        obj.x = (obj.x + 1) % carouselPics.length;
        iDomById('carousel-img').src = `carouselImg/${carouselPics[obj.x]}.jpg`;
    }

    function initializeMenu() {
        const menu = iDomById('main-menu');
        const menuUl = document.createElement('ul');
        menuUl.className = 'main-menu-ul none-style-ul';
        const fragment = document.createDocumentFragment();
        for (const obj of menuNames) {
            const li = document.createElement('li');
            li.className = 'main-menu-item';

            const icon = document.createElement('span');
            icon.className = 'menu-item-icon';
            icon.innerText = obj.icon;

            const txt = document.createElement('span');
            txt.className = 'menu-item-name';
            txt.innerText = obj.name;

            li.appendChild(icon);
            li.appendChild(txt);

            fragment.append(li);
        }
        menuUl.appendChild(fragment);
        menu.appendChild(menuUl);


        const firstChild = menuUl.firstChild;
        const btn = document.createElement('button');
        btn.className = 'addr-switch';
        btn.innerText = '[切换]'
        firstChild.appendChild(btn);

        btn.onclick =()=> {
            addrSwitch();
        }

        const menuLi = document.getElementsByClassName('main-menu-item');
        const lastLi = menuLi[menuLi.length - 1];
        lastLi.onclick = () => {
            closeDrawerContainer();
        };
    }

    function addrSwitch() {

    }

</script>
</html>
  • utils.js部分 
function iDomById(id) {
    return document.getElementById(id);
}

四、结语 

最后,感谢阅读。由于还在学习前端技术当中,文章内容不是很全面和系统,后续有机会还会持续补充!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1399009.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Linux ---- 小玩具

目录 一、安装&#xff1a; 1、佛祖保佑&#xff0c;永不宕机&#xff0c;永无bug 2、小火车 3、艺术字和其它 天气预报 艺术字 4、会说话的小牦牛 5、其他趣味图片 我爱你 腻害 英雄联盟 帅 忍 龙 你是猪 福 好运连连 欢迎 加油 想你 忘不了你 我错了 你…

介绍几个免费的国内chatgpt网站

概述&#xff1a;水点文章。 第一&#xff1a;chataa网站 chataa (chat778.com) 进去之后注册一下&#xff0c;即可免费使用。 第二&#xff1a;AlchatOS网站 AIchatOS 第三&#xff1a;ChatGPT在线聊天 ChatGPT在线聊天 (zxf7460.cn) 第四&#xff1a;说我真帅&#xff0…

重构改善既有代码的设计-学习(一):封装

1、封装记录&#xff08;Encapsulate Record&#xff09; 一些记录性结构&#xff08;例如hash、map、hashmap、dictionary等&#xff09;&#xff0c;一条记录上持有什么字段往往不够直观。如果其使用范围比较宽&#xff0c;这个问题往往会造成许多困扰。所以&#xff0c;记录…

pytest + allure(windows)安装

背景 软硬件环境&#xff1a; windows11&#xff0c;已安装anaconda&#xff0c;python&#xff0c;pycharm用途&#xff1a;使用pytest allure 生成报告allure 依赖java&#xff0c;点击查看java安装教程 allure 下载与安装 从 allure下载网址下载最新版本.zip文件 放在自…

火速收藏!2024 新年微信红包封面领取全攻略

2024“龙”重登场&#xff01;今年有哪些令人期待的红包封面&#xff1f; 前方大批精美红包封面来袭&#xff0c;全新品牌氛围红包封面上线&#xff0c;支持品牌定制特色氛围元素&#xff0c;沉浸感受浓浓年味儿&#xff0c;收获满满惊喜&#xff01; 新年开好运&#xff0c;微…

7 python快速上手

数据类型&#xff08;下&#xff09; 数据类型&#xff08;下&#xff09;1.集合&#xff08;set&#xff09;1.1 定义1.2 独有功能1.3 公共功能1.4 转换1.5 其他1.5.1 集合的存储原理1.5.2 元素必须可哈希1.5.3 查找速度特别快1.5.4 对比和嵌套 强插&#xff1a;None类型2.字典…

CloudPanel file-manager/backend/makefile接口存在远程命令执行漏洞CVE-2023-35885

@[toc] 免责声明:请勿利用文章内的相关技术从事非法测试,由于传播、利用此文所提供的信息或者工具而造成的任何直接或者间接的后果及损失,均由使用者本人负责,所产生的一切不良后果与文章作者无关。该文章仅供学习用途使用。 1. CloudPanel 简介 微信公众号搜索:南风漏…

Vulnhub靶机:EvilBox-One

一、介绍 运行环境&#xff1a;Virtualbox 攻击机&#xff1a;kali&#xff08;10.0.2.15&#xff09; 靶机&#xff1a;EvilBox-One&#xff08;10.0.2.25&#xff09; 目标&#xff1a;获取靶机root权限和flag 靶机下载地址&#xff1a;https://www.vulnhub.com/entry/e…

python中Pytest常用的插件

前言 除了框架本身提供的功能外&#xff0c;Pytest还支持上百种第三方插件&#xff0c;良好的扩展性可以更好的满足大家在用例设计时的不同需求。本文将为大家详细介绍下面5项常用的插件。 1. 用例依赖 编写用例的时候&#xff0c;我们会注意用例之间的独立性&#xff0c;但部…

Python爬虫IP池

目录 一、介绍 1.1 为什么需要IP池&#xff1f; 1.2 IP池与代理池的区别 二、构建一个简单的IP池 三、注意事项 一、介绍 在网络爬虫的世界中&#xff0c;IP池是一个关键的概念。它允许爬虫程序在请求网页时使用多个IP地址&#xff0c;从而降低被封禁的风险&#xff0c;提高…

【2024最新】如何有效搭建自动化测试框架?

前言 最近好多小伙伴都在说接口自动化测试&#xff0c;那么究竟什么是接口自动化测试呢&#xff1f;让我们一起往下看就知道了&#xff0c;首先我们得先弄清楚下面这个问题。 为什么要做&#xff08;自动化&#xff09;接口测试&#xff1f; 1、由于现在各个系统的复杂度不断…

Jenkins环境配置篇-更换插件源

作为持续集成的利器 Jenkins 已经得到了广泛地应用&#xff0c;仅仅作为一个工具&#xff0c;Jenkins 已然有了 自己的生态圈&#xff0c;支持其的 plugin 更是超过 1300。在实际中如何使用以及如何更好地使用 jenkins&#xff0c;一直是大家在实践并讨论的。本系列文章将会从如…

正则表达式第三四个作用:替换、切割

目录 方法二 replaceAll&#xff1a; 方法三&#xff1a;spilt&#xff1a; 方法一之前已经见过了&#xff1a; 方法二 replaceAll&#xff1a; 形参中&#xff1a; 参数regex表示一个正则表达式。可以将当前字符串中匹配regex正则表达式的字符串替换为newStr。 代码演示 S…

容器技术1-容器与镜像简介

目录 1、容器与虚拟化 2、容器发展历程 3、镜像简介 4、镜像原理 &#xff08;1&#xff09;分层存储 &#xff08;2&#xff09;写时复制 &#xff08;3&#xff09;内容寻址 &#xff08;4&#xff09;联合挂载 1、容器与虚拟化 容器技术在操作系统层面实现了对计算机…

全志D1-H芯片Tengine支持

简介 ​ Tengine 是 OPEN AI LAB 推出的边缘 AI 计算框架&#xff0c;致力于解决 AIoT 产业链碎片化问题&#xff0c;加速 AI 产业化落地。Tengine 为了解决 AIoT 应用落地问题&#xff0c;重点关注嵌入式设备上的边缘 AI 计算推理&#xff0c;为海量 AIoT 应用和设备提供高性…

makefile里面的变量使用,系统变量

文章目录 makefile里面的变量使用 makefile里面的变量使用 calc:add.o sub.o multi.ogcc add.o sub.o multi.o calc.cpp -o calcadd.o:add.cppgcc -c add.cpp -o add.osub.o:sub.cppgcc -c sub.cpp -o sub.omulti.o:multi.cppgcc -c multi.cpp -o multi.oclean:rm -rf *.o cal…

每日一练【最大连续1的个数】

一、题目描述 给定一个二进制数组 nums 和一个整数 k&#xff0c;如果可以翻转最多 k 个 0 &#xff0c;则返回 数组中连续 1 的最大个数 。 二、题目解析 本题同样是利用滑动窗口的解法。 首先进入窗口&#xff0c;如果是1&#xff0c;就直接让right&#xff0c;但是如果是…

【奶奶看了都会】用AI工具制作微信动态红包封面保姆级教程,附动态红包封面领取

AI一天&#xff0c;人间一年。我是卷福同学&#xff0c;一个在福报厂修过福报的程序员 今年微信红包封面新出了动态封面&#xff0c;点开红包之后是个动图&#xff0c;而且有的还能加上音乐&#xff0c;可以说逼格非常高。假如你在朋友之间发红包用上这么一个封面&#xff0c;朋…

CodeWave学习笔记--采购管理系统

1.CodeWave是什么&#xff1f; CodeWave是一款智能低代码开发平台&#xff0c;基于网易自研拥有大规模参数和深度学习能力的智能模型底座产品架构&#xff0c;为企业级应用提供更加智能化研发的软件生产方式。IT人员可以轻易实现从“智能生成”到“可视化拖拽调整”的全栈低代…

使用Python监听并下载微信聊天表情包

实现的功能 只要有人给你发了表情包&#xff0c;不管是群聊还是个人发的&#xff0c;都将它保存到本地。也许某天斗图的时候就能用到&#xff0c;不过即使有了表情包&#xff0c;还需要一个检索功能&#xff0c;不然这一张一张看也太费眼睛了。 检索表情包 检索表情包的功能…