浮头导航网

专注编程技术分享的开发者社区

教你从头开始写课堂签到的微信小程序(二)实现签到及视频播放

一、签到子页面布局

子页面主要是一个签到按钮,然后下方是签到记录列表。

一文搞懂flex(弹性盒布局)

1、什么是弹性布局

Flex是Flexible Box的缩写,翻译成中文就是“弹性盒子”,用来为盒装模型提供最大的灵活性。任何一个容器都可以指定为Flex布局。

easyui datagrid 查询会触发onUncheck问题

datagrid 开启多选框,如果你在页面选择后,去搜索,查询刷新数据会触发onUncheck(全不选)事件;那么就不采用查询而是采用load(重载)就不会触发;

例如:做列表多选,并支持跨页、查询多选,遇到历史选中的数据能显示选中状态;

<table data-toggle="topjui-datagrid" data-options="id: 'xxxDg',showFooter:true,
                  checkOnSelect:true,onDblClickRow:doDbClickCancelCheckbox, nowrap:true,autoRowHeight:false,onCheck:function(index,row){checkFee(index,row,1)},onUncheck:function(index,row){checkFee(index,row,2)},
                 onCheckAll:function(rows){checkAllFee(rows,1)},onUncheckAll:function(rows){checkAllFee(rows,2)},onBeforeLoad:function(param){param.check_ids=$('#fee_ids').val()},
                    url:'xxx.com?xxx=xxx'">
        <thead>
        <tr>
            <th data-options="field:'for_what',title:'事由',sortable:true,width:300"></th>
           <!--        ……      -->
        </tr>
        </thead>
    </table>
<!-- 表格工具栏开始 -->
<div id="xxxDg-toolbar" class="topjui-toolbar" data-options="grid:{ type:'datagrid', id:'xxxDg'}">
    <form id="xxxDgForm" class="search-box">
        <input type="text" name="apply_username"  data-toggle="topjui-combobox"
               data-options="prompt:'申请人',width:100 ,data:[],editable:true,hasDownArrow:false,panelHeight:0,onChange:xxxDgChange">
<!--        ……      -->
        <a href="javascript:void(0)" id="xxxDgSubmit" data-toggle="topjui-menubutton"
           data-options="method:'query', iconCls:'fa fa-search',   btnCls:'topjui-btn-blue',
               form:{id:'xxxDgForm'},
               grid:{type:'datagrid','id':'xxxDg'}">查询</a>
    </form>
</div>
<script>
     //当双击一行时,取消复选框选中状态
    function doDbClickCancelCheckbox(index, row) {
        $('#xxxDg').iDatagrid('uncheckRow',index);
    }
 //当改变下拉列表值时,执行此函数
     function xxxDgChange(nv,ov) {
         $('#xxxDg').iDatagrid('load',$('#xxxDgForm').serializeObject());
         // $('#xxxDgSubmit').trigger('click')
     }            
 </script>

前端能限制用户截图吗?

摘要: 在某些业务场景下,保护屏幕信息的私密性,防止用户随意截图分享,成为了前端开发者的一个棘手需求。但浏览器和操作系统的设计,真的允许网页开发者完全掌控用户的截图行为吗?本文将深入探讨前端限制截图的技术原理、挑战、尝试方案及其局限性,并提供一些更具可行性的替代策略。

用豆包生成的BMI计算器

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>BMI 计算器</title>
    <style>
        :root {
            --body-bg-start: #e8eaf6;
            --body-bg-end: #d1c4e9;
            --card-bg: rgba(255, 255, 255, 0.9);
            --button-gradient-start: #7e57c2;
            --button-gradient-end: #9575cd;
            --button-hover-gradient-start: #673ab7;
            --button-hover-gradient-end: #8e67c7;
            --input-border: #bdbdbd;
            --input-focus-border: #7e57c2;
            --underweight-bg: #b3e5fc;
            --normal-bg: #c8e6c9;
            --overweight-bg: #ffe0b2;
            --obese-bg: #ffcdd2;
            --text-color: #212121;
            --shadow-color: rgba(0, 0, 0, 0.1);
        }

        body {
            font-family: 'Roboto', sans-serif;
            background: linear-gradient(to bottom, var(--body-bg-start), var(--body-bg-end));
            color: var(--text-color);
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            margin: 0;
        }

        .card {
            background-color: var(--card-bg);
            border-radius: 20px;
            box-shadow: 0 16px 32px var(--shadow-color);
            padding: 60px;
            width: 90%;
            max-width: 700px;
            box-sizing: border-box;
        }

        h1 {
            text-align: center;
            font-size: 32px;
            margin-bottom: 40px;
        }

        .input-group {
            margin-bottom: 30px;
        }

        label {
            display: block;
            margin-bottom: 12px;
            font-size: 20px;
            font-weight: 500;
        }

        input[type="number"] {
            width: 100%;
            padding: 18px;
            border: 1px solid var(--input-border);
            border-radius: 10px;
            transition: border-color 0.3s ease;
            font-size: 18px;
            box-sizing: border-box;
        }

        input[type="number"]:focus {
            border-color: var(--input-focus-border);
            outline: none;
        }

        button {
            width: 100%;
            padding: 18px;
            background: linear-gradient(to right, var(--button-gradient-start), var(--button-gradient-end));
            color: white;
            border: none;
            border-radius: 10px;
            box-shadow: 0 8px 16px var(--shadow-color);
            cursor: pointer;
            transition: background 0.3s ease;
            font-size: 20px;
            font-weight: 500;
        }

        button:hover {
            background: linear-gradient(to right, var(--button-hover-gradient-start), var(--button-hover-gradient-end));
        }

        #result {
            margin-top: 40px;
            padding: 30px;
            border-radius: 10px;
            text-align: center;
            display: none;
            font-size: 22px;
        }

        #result .bmi-value {
            font-size: 32px;
            font-weight: 700;
        }

        .danmaku {
            position: fixed;
            top: 0;
            right: 0;
            pointer-events: none;
            z-index: 999;
            white-space: nowrap;
            padding: 16px 32px;
            border-radius: 30px;
            color: white;
            background-color: hsl(calc(var(--random-hue, 0) * 360), 30%, 60%);
            animation: danmakuMove linear;
        }

        @keyframes danmakuMove {
            from {
                transform: translateX(100%);
            }
            to {
                transform: translateX(-100vw);
            }
        }
    </style>
</head>

<body>
    <div class="card">
        <h1>BMI 计算器</h1>
        <div class="input-group">
            <label for="height">你的身高(cm)</label>
            <input type="number" id="height" placeholder="请输入身高">
        </div>
        <div class="input-group">
            <label for="weight">你的体重(kg)</label>
            <input type="number" id="weight" placeholder="请输入体重">
        </div>
        <button onclick="calculateBMI()">计算 BMI</button>
        <div id="result"></div>
    </div>

    <script>
        function calculateBMI() {
            const height = parseFloat(document.getElementById('height').value);
            const weight = parseFloat(document.getElementById('weight').value);

            if (isNaN(height) || isNaN(weight) || height <= 0 || weight <= 0) {
                alert('请输入有效的身高和体重值。');
                return;
            }

            const bmi = (weight / ((height / 100) * (height / 100))).toFixed(2);
            let category = '';
            let message = '';
            let resultBg = '';

            if (bmi < 18.5) {
                category = '偏瘦';
                message = '风一吹,你怕是要像风筝一样飘走咯!';
                resultBg = getComputedStyle(document.documentElement).getPropertyValue('--underweight-bg');
            } else if (bmi >= 18.5 && bmi < 24) {
                category = '正常';
                message = '嘿,你这身材,老天爷赏饭吃的 “刚刚好” 呀!';
                resultBg = getComputedStyle(document.documentElement).getPropertyValue('--normal-bg');
            } else if (bmi >= 24 && bmi < 28) {
                category = '超重';
                message = '再胖点,你能去给熊猫当替身咯!';
                resultBg = getComputedStyle(document.documentElement).getPropertyValue('--overweight-bg');
            } else {
                category = '肥胖';
                message = '你不是胖,你是可爱到膨胀啦';
                resultBg = getComputedStyle(document.documentElement).getPropertyValue('--obese-bg');
            }

            const resultDiv = document.getElementById('result');
            resultDiv.innerHTML = `你的 BMI 值是:<span class="bmi-value">${bmi}</span>,体重分类:${category}`;
            resultDiv.style.display = 'block';
            resultDiv.style.backgroundColor = resultBg;

            generateDanmaku(message);
        }

        function generateDanmaku(message) {
            const numDanmaku = Math.floor(window.innerHeight / 50);
            for (let i = 0; i < numDanmaku; i++) {
                const danmaku = document.createElement('div');
                danmaku.classList.add('danmaku');
                danmaku.style.top = `${i * 50}px`;
                danmaku.style.setProperty('--random-hue', Math.random());
                danmaku.style.animationDuration = `${Math.random() * 8 + 4}s`;
                danmaku.textContent = message;
                document.body.appendChild(danmaku);

                danmaku.addEventListener('animationend', () => {
                    danmaku.remove();
                });
            }
        }
    </script>
</body>

</html>
    

高德地图经纬度坐标批量拾取

使用方法

在桌面上新建一个index.txt文件,把下面的代码复制进去保存,再把文件名改成index.html保存,双击运行打开即可

功能:

悠然晨光!一道 CSS 面试题,开启技术提升宁静时刻

清晨的微风轻轻拂过窗纱,案头的绿植随着风轻轻摇晃,这样宁静的时光最适合与代码来一场温柔对话。前端的朋友们,不必为面试的难题感到焦虑,每天清晨和上午,让我们暂且放下忙碌,静下心来,一起探索一道 CSS 高频面试题。就像晨跑能唤醒身体机能,此刻的学习也能唤醒你对技术的热情,为成长之路点亮一盏灯。

最近,“CSS 动态效果”“前端面试经典题型”“CSS 创新布局” 等关键词频频登上技术热搜,这些都是面试官检验能力的重要标尺。今天,我们就来攻克一道兼具创意与实用性的题目 ——

单元格竖排文字该怎么设置?

在不同软件中将表格中的文字设置为竖排的方法略有不同,以下是常见工具的详细步骤:


一、Microsoft Excel 竖排文字

<< 1 >>
控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言