HTML+CSS 動態菜單和登錄框

摘要

實現了一個現代化的登錄/注冊界面,包含導航欄和彈窗表單。

HTML結構采用了響應式設計,包含Logo、導航鏈接和登錄按鈕。

CSS樣式實現了背景圖片、導航欄懸浮效果和表單美化,使用偽元素實現鏈接下劃線動畫。

JavaScript實現了彈窗切換功能。

界面整體簡潔美觀,使用了Ionic圖標庫增強視覺效果,適合作為網站的用戶認證模塊。

效果

在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述
在這里插入圖片描述

在這里插入圖片描述

代碼

HTML

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"></meta><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Document</title><link rel="stylesheet" href="style.css"></link>
</head><body><header><h2 class="logo">Logo</h2><nav class="navigation"><a href="#">Home</a><a href="#">About</a><a href="#">Services</a><a href="#">Contact</a><button class="btnLogin-popup">Login</button></nav></header><div class="wrapper"><span class="icon-close"><ion-icon name="close"></ion-icon></span><div class="form-box login"><h2>Login</h2><div class="input-box"><span class="icon"><ion-icon name="mail"></ion-icon></span><input type="email" required><label>Email</label></div><div class="input-box"><span class="icon"><ion-icon name="lock-closed"></ion-icon></span><input type="password" required><label>Password</label></div><div class="remember-forget"><label for=""><input type="checkbox">Remember me</label><a href="#">Forgot Password</a></label></div><button type="submit" class="btn">Login</button><div class="login-register"><p>Don't have an account? <a href="#" class="register-link">Register</a></p></div></div><div class="form-box register"><h2>Registration</h2><div class="input-box"><span class="icon"><ion-icon name="person"></ion-icon></span><input type="text" required><label>Username</label></div><div class="input-box"><span class="icon"><ion-icon name="mail"></ion-icon></span><input type="email" required><label>Email</label></div><div class="input-box"><span class="icon"><ion-icon name="lock-closed"></ion-icon></span><input type="password" required><label>Password</label></div><div class="remember-forget"><label for=""><input type="checkbox">I agree to the terms & conditions</label></label></div><button type="submit" class="btn">Register</button><div class="login-register"><p>Already have an account? <a href="#" class="login-link">Login</a></p></div></div></div><script src="script.js"></script><!-- https://ionic.io/ionicons --><script type="module" src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.esm.js"></script><script nomodule src="https://unpkg.com/ionicons@7.1.0/dist/ionicons/ionicons.js"></script>
</body></html>

CSS

* {margin: 0;padding: 0;box-sizing: border-box;
}body {display: flex;justify-content: center;align-items: center;min-height: 100vh;background: url('bg.jpg') no-repeat;background-size: cover;background-position: center;
}header {position: fixed;top: 0;left: 0;width: 100%;padding: 20px 100px;/* background-color: red; */display: flex;justify-content: space-between;align-items: center;z-index: 99;
}.logo {font-size: 2em;color: #fff;-webkit-user-select: none;user-select: none;
}.navigation a {position: relative;font-size: 1.1em;color: #fff;text-decoration: none;font-weight: 500;margin-left: 40px;
}.navigation a::after {content: '';position: absolute;left: 0;bottom: -6px;width: 100%;height: 3px;background-color: #fff;border-radius: 5px;transform-origin: right;transform: scaleX(0);transition: transform 0.3s ease-in-out;
}.navigation a:hover::after {transform-origin: left;transform: scaleX(1);
}.navigation .btnLogin-popup {width: 130px;height: 50px;background-color: transparent;border: 2px solid #fff;outline: none;border-radius: 6px;cursor: pointer;font-size: 1.1em;color: #fff;font-weight: 500;margin: 0 40px;transition: 0.5s;
}.navigation .btnLogin-popup:hover {background-color: #fff;color: #162938;
}.wrapper {position: relative;width: 400px;height: 440px;background: transparent;border: 2px solid rgba(255, 255, 255, 0.5);border-radius: 20px;-webkit-backdrop-filter: blur(20px);backdrop-filter: blur(20px);box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);display: flex;justify-content: center;align-items: center;overflow: hidden;transform: scale(0);transition: transform 0.5s ease, height 0.2s ease-in-out;
}.wrapper.active-popup{transform: scale(1);
}.wrapper.active{height: 520px;
}.wrapper .icon-close{position: absolute;top: 0;right: 0;width: 45px;height: 45px;background-color: #162938;font-size: 2em;color: #fff;display: flex;justify-content: center;align-items: center;border-bottom-left-radius: 20px;cursor: pointer;z-index: 1;
}.wrapper .form-box {width: 100%;padding: 40px;
}.wrapper .form-box.login{/* display: none; */transition: transform 0.18s ease-in-out;transform: translateX(0);
}
.wrapper.active .form-box.login{/* display: none; */transition: none;transform: translateX(-400px);
}.wrapper .form-box.register{/* display: none; */position: absolute;transition: none;transform: translateX(400px);
}.wrapper.active .form-box.register{/* display: none; */transition: transform 0.18s ease-in-out;transform: translateX(0);
}.wrapper .form-box h2 {font-size: 2em;color: #162938;text-align: center;
}.input-box {position: relative;width: 100%;height: 50px;border-bottom: 2px solid #162938;margin: 30px 0;
}.input-box label {position: absolute;top: 50%;left: 5px;transform: translateY(-50%);font-size: 1em;color: #162938;font-weight: 500;pointer-events: none;transition: .5s;
}.input-box input:focus~label,
.input-box input:valid~label {top: -5px;
}.input-box input {width: 100%;height: 100%;background: transparent;border: none;outline: none;font-size: 1em;color: #162938;font-weight: 600;padding: 0 35px 0 5px;
}.input-box .icon {position: absolute;right: 8px;font-size: 1.2em;color: #162938;line-height: 57px;
}.remember-forget {font-size: 0.9em;color: #162938;font-weight: 500;margin: -25px 0 15px;display: flex;justify-content: space-between;
}.remember-forget label input {accent-color: #162938;margin: 0 5px 0 0;
}.remember-forget a {color: #162938;text-decoration: none;
}.remember-forget a:hover {text-decoration: underline;
}.btn {width: 100%;height: 45px;background-color: #162938;border: none;outline: none;border-radius: 6px;cursor: pointer;font-size: 1em;color: #fff;font-weight: 500;
}.login-register{font-size: 0.9em;color: #162938;text-align: center;font-weight: 500;margin: 25px 0 10px ;
}
.login-register a{color: #162938;text-decoration: none;font-weight: 600;
}
.login-register a:hover{text-decoration: underline;
}

JavaScript

const wrapper = document.querySelector('.wrapper');
const loginLink = document.querySelector('.login-link');
const registerLink = document.querySelector('.register-link');
const btnPopup = document.querySelector('.btnLogin-popup');
const iconClose = document.querySelector('.icon-close');registerLink.addEventListener('click', () => {wrapper.classList.add('active');
});loginLink.addEventListener('click', () => {wrapper.classList.remove('active');
});
btnPopup.addEventListener('click', () => {wrapper.classList.add('active-popup');
});
iconClose.addEventListener('click', () => {wrapper.classList.remove('active-popup');
});

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/bicheng/84821.shtml
繁體地址,請注明出處:http://hk.pswp.cn/bicheng/84821.shtml
英文地址,請注明出處:http://en.pswp.cn/bicheng/84821.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

抖音AI數字人對口型軟件LatentSync最新版整合包,音頻驅動口型講話

本次和大家分享一個字節跳動開發的強大的音頻驅動口型數字人視頻制作軟件LatentSync&#xff0c;我以前也分享過不少類似軟件了&#xff0c;比如&#xff1a;EchoMimic、VideoReTalking、hallo。字節的推出的這個效果稍微更好一點&#xff0c;我制作了最新版的一鍵啟動整合包。…

深入理解 PyTorch:從基礎到高級應用

在深度學習的浪潮中&#xff0c;PyTorch 憑借其簡潔易用、動態計算圖等特性&#xff0c;迅速成為眾多開發者和研究人員的首選框架。本文將深入探討 PyTorch 的核心概念、基礎操作以及高級應用&#xff0c;帶你全面了解這一強大的深度學習工具。? 一、PyTorch 簡介? PyTorch…

Java 中的 synchronized 與 Lock:深度對比、使用場景及高級用法

&#x1f4a1; 前言 在多線程并發編程中&#xff0c;線程安全問題始終是開發者需要重點關注的核心內容之一。Java 提供了多種機制來實現同步控制&#xff0c;其中最常用的兩種方式是&#xff1a; 使用 synchronized 關鍵字使用 java.util.concurrent.locks.Lock 接口&#xf…

Notepad++如何列選

在 Notepad 中&#xff0c;你可以通過 列模式&#xff08;Column Mode&#xff09; 進行垂直選擇文本&#xff08;列選&#xff09;&#xff0c;以下是具體操作方法&#xff1a; 方法 1&#xff1a;鍵盤 鼠標列選 按住 Alt 鍵&#xff08;或 Alt Shift&#xff09;。 按住鼠…

華為OD機考-水仙花數Ⅰ-邏輯分析(JAVA 2025B卷)

import java.util.*; public static Integer get(int count,int c){if(count<3||count>7){return -1;}//存儲每位數的最高位……最低位int[] arr new int[count];List<Integer> res new ArrayList<>();for(int i(int) Math.pow(10,count-1);i<(int) Math…

基于 STL+VMD 二次分解的 Informer-LSTM 并行預測模型詳解與案例

一、背景與動機 在時間序列預測中,如電力負荷、風速、交通流量等復雜數據常表現為: 非線性:趨勢+季節+突變+噪聲 多尺度:高頻擾動與低頻變化共存 長時依賴:遠期信息也影響當前預測 傳統模型(如 ARIMA、LSTM)往往無法兼顧全局趨勢建模與局部擾動感知,因此我們提出一種 …

【Linux Learning】SSH連線出現警告:WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

問題&#xff1a;WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is al…

輕量級密碼算法PRESENT的C語言實現(無第三方庫)

一、PRESENT算法介紹 PRESENT是一種超輕量級分組密碼算法&#xff0c;由Bogdanov等人在2007年提出&#xff0c;專門為資源受限環境如RFID標簽和傳感器網絡設計。該算法在硬件實現上僅需1570個門等效電路(GE)&#xff0c;在保持較高安全性的同時實現了極小的硬件占用空間。PRES…

if的簡化書寫,提高執行效率

很多時候可能有下面判斷 if(a0) {b1;} else if(a1) {b0;} 就是ba的反向值&#xff1a; a0;b1&#xff1b; a1;b0; 這時&#xff0c;可以簡化如下&#xff1a; ba^1 使用異或&#xff0c;程序更簡潔&#xff0c;執行效率也更高 其他的也可以類似使用按位異或優化代碼

Vim 調用外部命令學習筆記

Vim 外部命令集成完全指南 文章目錄 Vim 外部命令集成完全指南核心概念理解命令語法解析語法對比 常用外部命令詳解文本排序與去重文本篩選與搜索高級 grep 搜索技巧文本替換與編輯字符處理高級文本處理編程語言處理其他實用命令 范圍操作示例指定行范圍處理復合命令示例 實用技…

bash挖礦木馬事件全景復盤與企業級防御實戰20250612

&#x1f427; CentOS “-bash 挖礦木馬” 事件全景復盤與企業級防御實戰 ?? 作者&#xff1a;Narutolxy | &#x1f4c5; 日期&#xff1a;2025-06-12 | &#x1f3f7;? 標簽&#xff1a;Linux 安全、應急響應、運維加固、實戰復盤 &#x1f4d8; 內容簡介 本文是一場真實…

「Linux中Shell命令」Shell命令基礎

知識點詳細解析 Shell簡介 Shell是Linux操作系統系統中用戶與操作系統內核交互的接口。它既是命令解釋器,負責接收用戶輸入的命令并將其轉換為內核能夠理解的指令,也是一種腳本編程語言。作為Linux操作系統的重要組成部分,Shell扮演著用戶與系統內核之間的"中間人"…

202557讀書筆記|《夢里花落知多少(輕經典)》——有你在的地方才最美

《夢里花落知多少&#xff08;輕經典&#xff09;》作者三毛&#xff0c;物極必反&#xff0c;陰晴圓缺&#xff0c;小滿即萬全么&#xff1f;因為幸福過于滿溢。所以幸福被收走了。 沒有看過太多三毛的作品&#xff0c;給我的感覺她是很敏感&#xff0c;多愁善感及沒有安全感…

對象映射 C# 中 Mapster 和 AutoMapper 的比較

Mapster和AutoMapper是C#領域兩大主流對象映射庫&#xff0c;各具特色。Mapster以高性能著稱&#xff0c;使用表達式樹實現零反射映射&#xff0c;首次編譯后執行效率極高&#xff0c;適合對性能敏感的場景&#xff1b;AutoMapper則提供更豐富的功能集&#xff0c;如條件映射和…

QEMU源碼全解析 —— 塊設備虛擬化(26)

接前一篇文章:QEMU源碼全解析 —— 塊設備虛擬化(25) 本文內容參考: 《趣談Linux操作系統》 —— 劉超,極客時間 《QEMU/KVM源碼解析與應用》 —— 李強,機械工業出版社 Virt

微軟PowerBI考試 PL300-選擇 Power BI 模型框架【附練習數據】

微軟PowerBI考試 PL300-選擇 Power BI 模型框架 20 多年來&#xff0c;Microsoft 持續對企業商業智能 (BI) 進行大量投資。 Azure Analysis Services (AAS) 和 SQL Server Analysis Services (SSAS) 基于無數企業使用的成熟的 BI 數據建模技術。 同樣的技術也是 Power BI 數據…

RED DA認證-EN18031網絡安全常見問題以及解答

Q&#xff1a;RED DA是否對所有無線模塊和設備強制要求&#xff1f; A&#xff1a;是的&#xff0c;RED DA適用于歐盟境內銷售的所有無線設備&#xff0c;包括WWAN、藍牙或Wi-Fi模塊。唯一例外是GNSS模塊&#xff08;僅支持接收功能&#xff0c;無需認證&#xff09;。 Q&…

騰訊開源 ovCompose 跨平臺框架:實現一次跨三端(Android/iOS/鴻蒙)

在移動應用開發領域&#xff0c;跨平臺技術一直是開發者們追求的目標&#xff0c;它能夠幫助企業降低開發成本、提高開發效率&#xff0c;同時保證應用在不同平臺上的一致性體驗。2025 年 6 月 3 日&#xff0c;騰訊視頻團隊迎來了一個重要的里程碑 —— 正式發布 ovCompose 跨…

對3D對象進行形變分析

1&#xff0c;目的 分析3D實例對象相對標準參照物的形變。 一般用于質地較軟的材質&#xff08;例如橡膠&#xff0c;布料&#xff09;查找&#xff0c;檢查等。 標準參考模型 需匹配的實例&#xff1a; 形變后的模型&#xff1a;* 形變后的模型&#xff1a; 實例形變后的…

寶塔面板WordPress中使用Contact Form 7插件收不到郵件的解決方法

如果是寶塔面板的環境下&#xff0c;在WordPress中使用Contact Form 7插件提交表單時顯示成功&#xff0c;但郵箱未收到郵件&#xff0c;可能是由于服務器郵件功能配置問題。以下是幾種常見解決方法&#xff1a; 1. 檢查郵件發送方式 默認情況下&#xff0c;Contact Form 7 使…