【实用】一个移动端简单的UI弹窗组件,虽算不上高大上,但至少耐看

简介: 【实用】一个移动端简单的UI弹窗组件,虽算不上高大上,但至少耐看

点击图片放大看效果



上代码


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover">
    <style>
        /*弹窗----------------------------------------*/
        .alert {background: #00000055;position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 999;display: flex;justify-content: center;align-items: center;}  .alert[hidden] {display: none;}  .alert-win {width: 384px;border-radius: 6px;background: #fff;box-shadow: 0 4px 14px 0 rgba(0, 0, 0, .2);overflow: hidden;}  .alert-win .header {background: #f2f5fa;padding: 24px 32px;}  .alert-win .header .header-top {display: flex;justify-content: space-between;align-items: center;}  .alert-win .header .header-top h3 {margin: 0;padding: 0;}  .alert-win .header p {padding: 0;margin: 16px 0 0 0;font-size: 14px;color: rgba(41, 47, 58, .7);letter-spacing: 0;line-height: 22px;}  .alert-win .footer {display: flex;justify-content: space-between;padding: 16px 32px;background: #fff;box-shadow: 0 -1px 0 0 rgba(192, 196, 204, .4);text-align: right;}  .alert-win .footer > * {margin: 0 5px;}  .alert-win .footer > *:first-of-type {margin-left: 0;}  .alert-win .footer > *:last-of-type {margin-right: 0;}
 
        /*关闭按钮----------------------------------------*/
        .close-btn {tap-highlight-color: transparent !important;-webkit-tap-highlight-color: transparent !important;width: 24px;height: 24px;font-size: 16px;cursor: pointer;display: inline-block;font-style: normal;position: relative;text-align: center;user-select: none;}  .close-btn:after {content: "";position: absolute;margin-top: -21px;display: block;width: 100%;height: 100%;border-radius: 100%;background-color: rgba(0, 0, 0, .08);opacity: 0;transform: scale(.5);transition: all .2s cubic-bezier(.175, .885, .32, 1.275);}  .close-btn:hover:after {opacity: 1;transform: scale(1.4);}
 
        /*蓝色按钮----------------------------------------*/
        button {tap-highlight-color: transparent !important;-webkit-tap-highlight-color: transparent !important;transition: .2s ease-out;cursor: pointer;height: 50px;width: 100%;border: 1px solid rgba(51, 100, 237, .35);color: #fff;font-size: 16px;font-weight: bold;border-radius: 3px;background: linear-gradient(180deg, #648CFF 0%, #4172FA 100%);box-shadow: 0 3px 4px 0 rgba(44, 71, 146, .32), inset 0 -2px 0 0 #3262e6;text-align: center;line-height: 46px;user-select: none;}  button:hover {opacity: .9;box-shadow: none;}  button:focus, button:active {outline: none;background: linear-gradient(180deg, #4d7bff, #154deb);transform: scale(.97);}  button[disabled] {color: #fff;background: #b0c7ff;pointer-events: none;cursor: default;box-shadow: none;}
 
        /*白色按钮----------------------------------------*/
        button[white] {tap-highlight-color: transparent !important;-webkit-tap-highlight-color: transparent !important;transition: .2s ease-out;cursor: pointer;width: 100%;height: 50px;border: none;border-radius: 3px;font-size: 16px;font-weight: bold;color: #292f3a;letter-spacing: 0;outline: none;background: linear-gradient(-180deg, #fff 8%, #f2f2f7 97%);box-shadow: 0 2px 3px 0 rgba(44, 71, 146, .32), 0 -1px 1px 0 rgba(44, 71, 146, .1);}  button[white]:hover {background: linear-gradient(-180deg, #f2f2f7 20%, #f2f2f7 97%);box-shadow: none;color: #3973ff;border: none;}  button[white]:active, button[white]:active {background: #d8dde6;transform: scale(.97);}  button[white][disabled] {background: rgba(216, 221, 230, .8) !important;pointer-events: none;cursor: default;color: white;box-shadow: none;}
 
    </style>
</head>
<body>
 
<button onclick="showAlert()">点击显示弹窗</button>
<div class="alert" hidden>
    <div class="alert-win">
        <div class="header">
            <div class="header-top"><h3>对话框标题</h3><i class="close-btn" onclick="hideAlert()">✕</i></div>
            <p>使用 AI 动态判断网站当前的攻击势态,并结合每次请求的多维度数据组合,AI 能够做到对每一次请求使用不同的防御能力组合。</p></div>
        <div class="content">
            <br>
            <br>
            <p style="text-align: center;">正文内容</p>
            <br>
            <br>
        </div>
        <div class="footer">
            <button white onclick="hideAlert()">取消</button>
            <button onclick="hideAlert()">确定</button>
        </div>
    </div>
</div>
</body>
<script>
    function showAlert() {
        document.querySelector(".alert").removeAttribute("hidden");
    }
 
    function hideAlert() {
        document.querySelector(".alert").setAttribute("hidden", true);
    }
</script>
</html>


相关文章
|
1月前
|
Android开发 算法 架构师
android的基础ui组件,这些知识点你会吗
android的基础ui组件,这些知识点你会吗
android的基础ui组件,这些知识点你会吗
|
1月前
|
Android开发 缓存 双11
android的基础ui组件,Android开发社招面试经验
android的基础ui组件,Android开发社招面试经验
android的基础ui组件,Android开发社招面试经验
|
2天前
|
API Android开发 开发者
`RecyclerView`是Android API 21引入的UI组件,用于替代ListView和GridView
【6月更文挑战第26天】`RecyclerView`是Android API 21引入的UI组件,用于替代ListView和GridView。它提供高效的数据视图复用,优化的布局管理,支持多种布局(如线性、网格),并解耦数据、适配器和视图。RecyclerView的灵活性、性能(如局部刷新和动画支持)和扩展性使其成为现代Android开发的首选,特别是在处理大规模数据集时。
16 2
|
21天前
|
XML Android开发 数据格式
【Android UI】中间对齐UI组件
【Android UI】中间对齐UI组件
13 1
|
24天前
|
开发框架 JavaScript 前端开发
微软官方开源免费的Blazor UI组件库 - Fluent UI Blazor
微软官方开源免费的Blazor UI组件库 - Fluent UI Blazor
|
1月前
Vue3+Vite+Pinia+Naive后台管理系统搭建之四:Naive UI 组件库的安装和使用
Vue3+Vite+Pinia+Naive后台管理系统搭建之四:Naive UI 组件库的安装和使用
48 1
|
1月前
|
前端开发 搜索推荐 UED
【Flutter前端技术开发专栏】Flutter中的高级UI组件应用
【4月更文挑战第30天】探索Flutter的高级UI组件,如`TabBar`、`Drawer`、`BottomSheet`,提升应用体验和美观度。使用高级组件能节省开发时间,提供内置交互逻辑和优秀视觉效果。示例代码展示了如何实现底部导航栏、侧边导航和底部弹出菜单。同时,自定义组件允许个性化设计和功能扩展,但也带来性能优化和维护挑战。参考Flutter官方文档和教程,深入学习并有效利用这些组件。
【Flutter前端技术开发专栏】Flutter中的高级UI组件应用
|
1月前
|
前端开发 JavaScript UED
前端UI组件
前端UI组件
36 0
|
1月前
|
编解码 JavaScript 数据可视化
【vue3】 vue3 几款值得推荐的UI组件库
【vue3】 vue3 几款值得推荐的UI组件库
163 0
|
1月前
|
前端开发 搜索推荐 开发者
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍
SAP UI5 sap.m.Column 控件的 minScreenWidth 属性介绍