web第三次作业

弹窗案例

1.首页代码

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>综合案例</title>

    <style>

        *{

            margin: 0;

            padding: 0;

            box-sizing: border-box;

        }

        html,body{

            width: 100%;

            height: 100%;

        }

        .container{

            width: 100%;

            height: 100%;

            background-color: #f2f1f2;

        }

        header{

            width: 1200px;

            height: 50px;

            background-color: #fff;

            margin: 0 auto;

            display: flex;

            justify-content: space-between;

            align-items: center;

        }

        header div:nth-of-type(2){

            display: flex;

            gap: 20px;

            cursor: pointer;

        }

        header div:nth-of-type(2) span:hover{

            font-weight: bolder;

            color: red;

        }

        .login-box{

            display: none;    

            overflow: hidden;

            width: 300px;

            height: 200px;

            background-color: #fff;

            border: solid 1px orangered;

            border-radius: 8px;

            box-shadow: rgba(255,0,0,0.5) 5px 5px 5px;

            position: absolute;

            left: 1150px;

            top: 50px;

        }

        .login-box .header{

            height: 40px;

            background-color: orangered;

            display: flex;

            justify-content: space-between;

            align-items: center;

            color: white;

            cursor: pointer;

            padding: 0 10px;

        }

    </style>

</head>

<body>

    <div class="container">

        <header>

            <div>

                <span>欢迎访问OPENLAB EDU</span>

            </div>

            <div>

                <span id="login">登录</span>

                <span id="register">注册</span>

            </div>

            <div class="login-box" id="login-box">

                <div class="header" id="header">

                    <span>会员登录</span>

                    <span id="close">[关闭]</span>

                </div>

            </div>

        </header>

    </div>



    <script>

        let _login=document.getElementById("login");

        let _login_box=document.getElementById("login-box");



        _login.onclick=function(){

            _login_box.style.display="block";

        }



        let _close=document.getElementById("close");

        _close.onclick=function(){

            _login_box.style.display="none";

        }



        let _header=document.getElementById("header");



        document.onmousedown=function(event){

            let offsetX=event.offsetX;

            let offsetY=event.offsetY;



            _header.onmousemove=function(event2){

                let mouseX=event2.clientX;

                let mouseY=event2.clientY;



                let loginX=mouseX-offsetX;

                let loginY=mouseY-offsetY;



                if(loginX<=0){

                    loginX=0;

                }

                if(loginY<=0){

                    loginY=0;

                }



                let iw=window.innerWidth;

                let lw=getComputedStyle(_login_box).width;

                lw=parseInt(lw);

                if(loginX>=(iw-lw)){

                    loginX=iw-lw;

                }

                let ih=window.innerHeight;

                let lh=getComputedStyle(_login_box).height;

                lh=parseInt(lh);

                if(loginY>=(ih-lh)){

                    loginY=ih-lh;

                }



                _login_box.style.left=loginX+"px";

                _login_box.style.top=loginY+"px";

            }

        }

        document.onmouseup=function(){

            _header.onmousemove=null;

        }

    </script>

</body>

</html>

2.展示效果

### Web前端第三次作业要求与示例教程 #### 一、项目概述 本次作业旨在让学生深入理解并掌握Web前端开发的核心技能,包括但不限于HTML5、CSS3和JavaScript的应用。学生需创建一个具有特定主题的动态网页,此过程不仅考察学生的编码能力,还测试其创意表达和技术实现水平。 #### 二、具体要求 ##### 1. 主题选定 选择一个感兴趣的主题作为网站的内容核心,比如四川旅游网页设计制作[^1]。这可以激发创作者的热情,并使作品更加个性化。 ##### 2. 技术栈应用 - **HTML5**: 构建页面结构的基础语法; - **CSS3**: 实现视觉风格的设计工具,允许适当使用现代特性如Flexbox布局[^2]; - **JavaScript**: 添加交互功能的关键编程语言; 注意遵循相关标准指南,在非HTML5环境下谨慎选用某些高级CSS属性[^3]。 ##### 3. 功能模块规划 确保站点至少包含以下几个部分: - 首页:提供导航链接至其他子页面; - 关于我们/作者简介:简要介绍自己或团队背景信息; - 特色展示区:突出所选主题的独特之处; - 用户反馈表单:收集访问者的建议意见; ##### 4. 设计原则遵守 重视用户体验(UX),保持界面简洁明了的同时也要注重美观度。合理安排色彩搭配方案,字体大小适中易读性强。对于移动设备友好型响应式布局也是加分项之一。 ```html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>我的第三次Web前端作业</title> <!-- 引入外部资源 --> <link rel="stylesheet" href="./styles.css"/> </head> <body> <header> <h1>欢迎来到我的特色主页</h1> <nav> <ul> <li><a href="#home">首页</a></li> <li><a href="#about">关于我们</a></li> <li><a href="#features">特色展示</a></li> <li><a href="#contact">联系我们</a></li> </ul> </nav> </header> <main id="content"> <section id="home"></section> <section id="about"></section> <section id="features"></section> <form action="#" method="post" id="contact"> ... </form> </main> <footer> © 2024 All rights reserved. </footer> <script src="./scripts.js"></script> </body> </html> ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值