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

大家好,我是猿码叔叔,一个 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.mfbz.cn/a/337352.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

[足式机器人]Part2 Dr. CAN学习笔记- 最优控制Optimal Control Ch07-2 动态规划 Dynamic Programming

本文仅供学习使用 本文参考&#xff1a; B站&#xff1a;DR_CAN Dr. CAN学习笔记 - 最优控制Optimal Control Ch07-2 动态规划 Dynamic Programming 1. 基本概念2. 代码详解3. 简单一维案例 1. 基本概念 Richoard Bell man 最优化理论&#xff1a; An optimal policy has the …

宏景-zp_options-get_org_tree-SQL注入漏洞-未公开Day漏洞复现

0x01阅读须知 技术文章仅供参考&#xff0c;此文所提供的信息只为网络安全人员对自己所负责的网站、服务器等&#xff08;包括但不限于&#xff09;进行检测或维护参考&#xff0c;未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。利用此文所提供的信息而造成的…

电脑分区是使用MRB还是GPT呢?看了这篇文章,心理就有底了

在Windows 10或Windows 11上设置一个新磁盘&#xff0c;系统会询问你是要使用MBR&#xff08;主引导记录&#xff09;还是GPT&#xff08;GUID分区表&#xff09;。今天&#xff0c;我们将解释GPT和MBR之间的区别&#xff0c;并帮助你为PC或Mac选择合适的。 GPT带来了许多优点…

linux下vsc的自动切换输入法解决方案

前言 个人使用的是Linux开发加上vsc编辑器&#xff0c;这两个东西一加中国开发者大致上就消失不见了&#xff0c;眼馋idea那个Smartinput很久了&#xff0c;赶上放假了&#xff0c;有空搞搞&#xff0c;如果后期有心情会做的通用点 安装 商店搜索SmartInputLinux安装 使用…

Spring Boot 3.2.2整合MyBatis-Plus 3.5.5依赖不兼容问题

问题演示 导依赖 当你启动项目就会 抛出该异常 java.lang.IllegalArgumentException: Invalid value type for attribute factoryBeanObjectType: java.lang.String 问题原因 mybatis-plus 中 mybatis 的整合包版本不够导致的 解决方案 排除掉mybatis-plus 中 mybatis 的整合…

【Vue3】3-3 : 组件之间是如何进行互相通信的

本书目录&#xff1a;点击进入 一、组件之间为什么要做通信 二、组件之间通信方式 2.1、父传子&#xff1a;由传递属性实现 stage 1&#xff1a;申明 &#xff08;即定义&#xff09; stage 2&#xff1a;注册 stage 3&#xff1a;使用 【示例】&#xff1a;父组件将 tit…

Swift抓取某网站律师内容并做排名筛选

有个很要好的朋友&#xff0c;今天找我说他的朋友欠他钱&#xff0c;因为工程上面的事情&#xff0c;所以一直没拿到款。想让我找个靠谱的律师帮他打官司&#xff0c;因为这个也不是我的强项&#xff0c;也没有这方面的经验。随即从律师网站爬取对应律师口碑以及成功案例&#…

记录一下uniapp 集成腾讯im特别卡(未解决)

uniapp的项目运行在微信小程序 , 安卓 , ios手机三端 , 之前这个项目集成过im,不过版本太老了,0.x的版本, 现在需要添加客服功能,所以就升级了 由于是二开 , 也为了方便 , 沿用之前的webview嵌套腾讯IM的方案 , 选用uniapp集成ui ,升级之后所有安卓用户反馈点击进去特别卡,几…

数据结构代码实现 —— 单链表【Java】

单链表的概述及性质等在篇不做赘述&#xff0c;有需要可移步以下文章&#xff1a; 《数据结构 C语言版 严蔚敏 第2版》&#xff1a;线性表https://blog.csdn.net/weixin_43551213/article/details/134048025 以下仅展示使用 Java 实现单链表 结点结构定义&#xff1a; publ…

中科院罗小舟团队提出 UniKP 框架,大模型 + 机器学习高精度预测酶动力学参数

作者&#xff1a;李宝珠 编辑&#xff1a;三羊 中国科学院深圳先进技术研究院罗小舟团队提出了&#xff0c;基于酶动力学参数预测框架 (UniKP)&#xff0c;实现多种不同的酶动力学参数的预测。 众所周知&#xff0c;生物体内的新陈代谢是通过各种各样的化学反应来实现的。这…

USB转SPI USB转IIC 串口转SPI串口转IIC SPI I2C模块

一款支持USB转SPI、USB转I2C、USB转GPIO、USB转PWM、USB转ADC的模块。提供上位机工具&#xff0c;开发协议。 资料下载&#xff0c;链接&#xff1a;https://pan.baidu.com/s/1sw3RCMwjhrMO4qzUBq9bjA 提取码&#xff1a;qzjp 概述 串口转多协议模组为了客户调试一些功能…

Linux搭建主从DNS服务器

DNS简介&#xff1a; DNS&#xff08;Domain Name System&#xff09;是互联网上的一项服务&#xff0c;它作为将域名和IP地址相互映射的一个分布式数据库&#xff0c;能够使人更方便的访问互联网。 DNS产生的原因&#xff1a; 互联网的不同计算机之间通信是通过IP地址来进行…

【软件测试】学习笔记-网站高可用架构设计

顾名思义&#xff0c;网站高可用指的就是&#xff0c;在绝大多的时间里&#xff0c;网站一直处于可以对外提供服务的正常状态。业界通常使用有多少个“9”来衡量网站的可用性指标&#xff0c;具体的计算公式也很简单&#xff0c;就是一段时间内&#xff08;比如一年&#xff09…

Mybatis原理 - 标签解析

很多开源框架之所以能够流行起来&#xff0c;是因为它们解决了领域内的一些通用问题。但在实际使用这些开源框架的时候&#xff0c;我们都是要解决通用问题中的一个特例问题&#xff0c;所以这时我们就需要使用一种方式来控制开源框架的行为&#xff0c;这就是开源框架提供各种…

Redis原理篇(String)

一.编码方式 String 有三种编码方式 1.RAW编码 type是类型&#xff0c;表示该类型是String类型 encoding是编码方式&#xff0c;表示当前是String的RAW编码方式 ptr指针指向一个SDS&#xff08;动态字符串&#xff09;对象 2.EMBSTR编码 当要存的字符串长度小于44个字节时&…

ElasticSearch 7.x现网运行问题汇集3

问题描述 某现网ElasticSearch 故障&#xff0c;很长时间unassgined_shards的数量都不减少。 原因分析与解决方案&#xff1a; 先了解整体状态&#xff0c;使用Postman请求&#xff0c;如下几个请求命令&#xff1a; GET /_cat/indicesGET /_cat/shardsGET /_cluster/health…

《Python数据分析技术栈》第03章 03 可视化各级数据(Visualizing various levels of data)

03 可视化各级数据&#xff08;Visualizing various levels of data&#xff09; 《Python数据分析技术栈》第03章 03 可视化各级数据&#xff08;Visualizing various levels of data&#xff09; Whenever you need to analyze data, first understand if the data is stru…

【图解数据结构】顺序表实战指南:手把手教你详细实现(超详细解析)

&#x1f308;个人主页&#xff1a;聆风吟 &#x1f525;系列专栏&#xff1a;图解数据结构、算法模板 &#x1f516;少年有梦不应止于心动&#xff0c;更要付诸行动。 文章目录 一. ⛳️线性表1.1 &#x1f514;线性表的定义1.2 &#x1f514;线性表的存储结构 二. ⛳️顺序表…

解决Windows下Goland的Terminal设置为Git Bash失败

路径不要选错了&#xff1a; 如果还是不行&#xff1a; 把bash路径加进去试试 goland设置Terminal

在Qt中通过控制按钮实现登录界面密码与明码的转换

创建控件&#xff1a; 首先&#xff0c;在Qt设计师界面界面上创建QLineEdit类文本框&#xff0c;用于输入密码&#xff0c;并且实现密码与明码相互转化。 设置初始状态&#xff1a; 默认情况下&#xff0c;输入密码的文本框应该是可见的并允许用户输入。 添加切换按钮&…
最新文章