php 遮罩设置,下拉半透背景遮罩

这篇博客介绍了如何使用CSS和JavaScript实现响应式的导航菜单,包括在屏幕宽度超过768px时的布局样式和导航菜单的半透明背景遮罩效果。当鼠标悬停在菜单项上时,遮罩会根据子菜单的高度动态调整,并改变颜色。同时,还涉及了输入框和按钮的样式调整以及jQuery代码实现菜单项的悬停效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下拉半透背景遮罩

@media only screen and (min-width: 768px) {

/* Add your Desktop Styles here */

/*nav width*/

/*.main_menu {

width: 100%;

padding-left: 300px;

}

.avia-menu {

display: table;

width: 100%;

}

.av-main-nav {

display: table-row;

}

.av-main-nav > li {

display: table-cell;

float: none !important;

}

*/

/*nav background*/

.avia-menu2 {

display: table;

opacity:0;

width: 100%;

height:250px;

background: rgba(0,0,0,0.7);

}

/*nav buttom width*/

.av-main-nav > li > a {padding: 0 23px; !important}

.menu-item ul { background-color:transparent !important;box-shadow: none !important;}

.menu-item a { background-color:transparent !important;}

#top #wrap_all .av-main-nav ul > li > a{ color: #fff !important; font-weight:bold;}

#top #wrap_all .av-main-nav ul > li:hover > a{ color: #ca2151 !important;}

.av-main-nav ul { width: 400px !important;}

.av_secondary_right nav.sub_menu { right:-120px; }

.av_icon_active_right ul.social_bookmarks { right:170px; position:relative;}

.av_secondary_right nav.sub_menu #avia2-menu ul.sub-menu li { position: relative; right:-45px;}

.av_secondary_right nav.sub_menu #avia2-menu ul.sub-menu li:hover a { color: #ca2151 !important;}

#header_main .main_menu .sub-menu li span.avia-menu-text img{

width:60px; height:60px;    vertical-align: middle;

display:inline; padding:0; margin:0 10px 0 0;}

}

form.wpcf7-form textarea.wpcf7-textarea, form.wpcf7-form input.wpcf7-text {

width: 100% !important;

margin-bottom: 0 !important;

margin-top: 7px !important;

display: inline !important;

min-width: 50px !important;

padding: 13px !important;

border-radius: 2px !important;

}

form.wpcf7-form textarea.wpcf7-textarea {

height: 90px;

}

form.wpcf7-form input[type='submit'] {

transition: all 0.3s ease-in-out !important;

margin: 0 !important;

padding: 16px 20px !important;

border-radius: 2px !important;

border-bottom-width: 1px !important;

border-bottom-style: solid !important;

font-weight: normal !important;

font-size: 0.92em !important;

min-width: 142px !important;

outline: none !important;

}

form.wpcf7-form input[type='submit']:hover {

background-color: #d5063d !important;

color: #000000 !important;

border-color: #b3041b !important;

}

form.wpcf7-form input.wpcf7-file{

width:50% !important;

}

jQuery(document).ready(function($)

{

/*start*/

$("nav.main_menu").append("

$("#avia-menu li.menu-item-has-children").hover(function(){

var btmHeight = $(this).children("ul.sub-menu").height()+10;

if(btmHeight<250){btmHeight=250}

$(".avia-menu2").css({"opacity":"1","height":btmHeight});

},function(){

$(".avia-menu2").css({"opacity":"0","height":"0px"});

});

/*end*/

}) 

©著作权归作者所有:来自51CTO博客作者yangzhuozhuo的原创作品,如需转载,请注明出处,否则将追究法律责任

<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="style/css/common.css" rel="stylesheet"> <title>硬件运维系统 - 报告管理</title> <link href="style/css/report.css" rel="stylesheet"> </head> <body> <div id="header-container"></div> <div class="container"> <h2 class="page-title">报告管理</h2> <div class="action-bar"> <div class="search-box"> <input type="text" id="search-report" placeholder="搜索报告名称/类型"> <button class="btn" id="search-btn">搜索</button> </div> <div> <button class="btn" id="sort-by-date">按日期排序</button> <button class="btn btn-download" id="download-all">下载全部报告</button> <button class="btn" id="add-report">新增报告</button> </div> </div> <!-- 新增:添加滚动容器 --> <div class="report-container"> <div id="report-list" class="report-list"> <!-- 报告卡片将动态生成 --> </div> </div> </div> <!-- 报告编辑模态框 --> <div id="report-modal" class="modal"> <div class="modal-content"> <div class="modal-header"> <h2 id="modal-title">新增报告</h2> <span class="close">×</span> </div> <form id="report-form"> <input type="hidden" id="report-id"> <div class="form-group"> <label for="report-name">报告名称</label> <input type="text" id="report-name" required> </div> <div class="form-group"> <label for="report-type">报告类型</label> <select id="report-type" required> <option value="硬件故障处理报告">硬件故障处理报告</option> <option value="软件运维报告">软件运维报告</option> <option value="设备健康度报告">设备健康度报告</option> <option value="产线运行分析报告">产线运行分析报告</option> <option value="硬件日志采集报告">硬件选择 - 获取指定时间段的日志</option> </select> </div> <!-- 日志时间段选择区 --> <div class="form-group log-time-range"> <label for="log-start-date">日志开始日期</label> <input type="date" id="log-start-date" required> <label for="log-end-date" style="margin-top: 10px;">日志结束日期</label> <input type="date" id="log-end-date" required> </div> <div class="form-group"> <label for="report-date">报告生成日期</label> <input type="date" id="report-date" required> </div> <div class="form-group"> <label for="report-content">报告内容</label> <div class="template-desc" id="content-desc">请根据报告类型填写内容...</div> <textarea id="report-content" required></textarea> </div> <div class="modal-footer"> <button type="button" class="btn" id="cancel-btn">取消</button> <button type="submit" class="btn">保存</button> </div> </form> </div> </div> <!-- 引入本地 jQuery --> <script src="style/js/jquery.min.js"></script> <script> // 检查登录状态 if (localStorage.getItem('isLogin') !== '1') { window.location.href = 'login.html'; } // 初始化报告数据和硬件日志数据 let reports = []; let hardwareLogs = []; // DOM 元素缓存 const $reportList = $('#report-list'); const $reportModal = $('#report-modal'); const $modalTitle = $('#modal-title'); const $reportForm = $('#report-form'); const $reportId = $('#report-id'); const $reportName = $('#report-name'); const $reportType = $('#report-type'); const $reportDate = $('#report-date'); const $reportContent = $('#report-content'); const $addReportBtn = $('#add-report'); const $cancelBtn = $('#cancel-btn'); const $closeBtn = $('.close'); const $searchBtn = $('#search-btn'); const $searchInput = $('#search-report'); const $sortByDateBtn = $('#sort-by-date'); const $downloadAllBtn = $('#download-all'); const $logTimeRange = $('.log-time-range'); const $contentDesc = $('#content-desc'); // 报告类型模板映射 const typeTemplates = { '硬件故障处理报告': `1. 故障现象: 2. 故障排查过程: 3. 处理方案: 4. 处理结果: 5. 预防建议:`, '软件运维报告': `1. 运维内容: 2. 操作过程: 3. 运行状态: 4. 遗留问题: 5. 后续计划:`, '设备健康度报告': `1. 设备状态: 2. 检查项目: 3. 异常项: 4. 维护建议: 5. 预测分析:`, '产线运行分析报告': `1. 生产数据: 2. 设备表现: 3. 瓶颈分析: 4. 改进措施: 5. 提升建议:`, '硬件日志采集报告': `### 日志采集说明 - 采集时间段:{startDate} 至 {endDate} - 涉及设备:自动从日志中提取 - 异常日志数量:{errorCount} ### 关键日志摘要 {logSummary} ` }; // 从API加载报告数据 function loadReports() { $.ajax({ url: 'api/reports.php', method: 'GET', dataType: 'json', success: function (data) { reports = data || []; renderReports(reports); }, error: function (xhr, status, error) { console.error('加载报告失败:', error); $reportList.html('<p style="text-align:center;padding:20px;">加载报告数据失败,请稍后重试</p>'); } }); } // 加载硬件日志数据 function loadHardwareLogs() { $.getJSON('data/hardware_logs.json', (data) => { hardwareLogs = data.logs || []; console.log('硬件日志加载成功'); }).fail((xhr, status, error) => { console.error('加载硬件日志失败:', error); hardwareLogs = []; }); } // 渲染报告列表 function renderReports(reportData) { $reportList.empty(); // 解绑之前的事件处理器,避免重复绑定 $reportList.off('click', '.edit-btn'); $reportList.off('click', '.delete-btn'); $reportList.off('click', '.download-btn'); if (reportData.length === 0) { $reportList.html('<p style="text-align:center;padding:20px;">暂无报告数据,请点击"新增报告"创建</p>'); return; } reportData.forEach(report => { const $card = $(` <div class="report-card" data-id="${report.id}"> <div class="report-info"> <h3>${report.name}</h3> <div class="report-meta"> <span>${report.type} | </span> <span>生成日期:${report.date}</span> </div> </div> <div class="report-action"> <button class="action-btn download-btn">下载</button> <button class="action-btn edit-btn">编辑</button> <button class="action-btn delete-btn">删除</button> </div> </div> `); $reportList.append($card); }); // 绑定事件 $reportList.on('click', '.edit-btn', function () { const reportId = $(this).closest('.report-card').data('id'); editReport(reportId); }); $reportList.on('click', '.delete-btn', function () { const reportId = $(this).closest('.report-card').data('id'); deleteReport(reportId); }); $reportList.on('click', '.download-btn', function () { const reportId = $(this).closest('.report-card').data('id'); downloadReport(reportId); }); } // 打开模态框 function openModal(isEdit = false, report = null) { $reportForm[0].reset(); $logTimeRange.hide(); $reportContent.val(''); if (isEdit && report) { $modalTitle.text('编辑报告'); $reportId.val(report.id); $reportName.val(report.name); $reportType.val(report.type); $reportDate.val(report.date); $reportContent.val(report.content); if (report.type === '硬件日志采集报告') { $logTimeRange.show(); $('#log-start-date').val(report.logStartDate || ''); $('#log-end-date').val(report.logEndDate || ''); } } else { $modalTitle.text('新增报告'); $reportId.val(''); $reportDate.val(new Date().toISOString().split('T')[0]); } $reportModal.show(); } // 关闭模态框 function closeModal() { $reportModal.hide(); } // 编辑报告 function editReport(id) { console.log('编辑报告:', reports); console.log('报告ID:', id); const stringId = String(id); const report = reports.find(r => r.id === stringId); console.log('编辑报告:', report); // console.log(r.id); if (report) { openModal(true, report); } else { alert('未找到该报告'); loadReports(); } } // 删除报告 function deleteReport(id) { const stringId = String(id); const report = reports.find(r => r.id === stringId); if (!report) { alert('未找到该报告'); loadReports(); return; } if (confirm(`确定要删除"${report.name}"这份报告吗?删除后无法恢复!`)) { $.ajax({ url: 'api/reports.php', method: 'DELETE', contentType: 'application/json', data: JSON.stringify({ id: id }), dataType: 'json', success: function (response) { if (response.success) { loadReports(); // 重新加载数据 } else { alert('删除失败:' + (response.message || '未知错误')); } }, error: function (xhr, status, error) { console.error('删除报告失败:', error); alert('删除报告失败,请检查网络连接'); } }); } } // 下载单个报告 function downloadReport(id) { const report = reports.find(r => r.id === id); if (!report) return; let content = ` 报告名称:${report.name} 报告类型:${report.type} 生成日期:${report.date} 报告内容: ${report.content} `.trim(); if (report.type === '硬件日志采集报告' && report.attachments && report.attachments.length) { content += `\n\n=== 日志附件 ===\n`; report.attachments.forEach(attach => { content += `\n【附件:${attach.filename}】\n${attach.content}\n`; }); } const blob = new Blob([content], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const a = $('<a>').attr({ href: url, download: `${report.name.replace(/[\/:*?"<>|]/g, '-')}.txt` }); $('body').append(a); a[0].click(); a.remove(); URL.revokeObjectURL(url); } // 下载全部报告 function downloadAllReports() { if (reports.length === 0) { alert('没有报告可下载'); return; } let allContent = '=== 所有报告汇总 ===\n\n'; reports.forEach((report, idx) => { allContent += `【报告 ${idx + 1}】\n`; allContent += `名称:${report.name}\n类型:${report.type}\n日期:${report.date}\n\n`; allContent += `内容:\n${report.content}\n\n`; if (report.type === '硬件日志采集报告' && report.attachments && report.attachments.length) { allContent += `=== 日志附件 ===\n`; report.attachments.forEach(attach => { allContent += `\n【附件:${attach.filename}】\n${attach.content}\n`; }); } allContent += '========================================\n\n'; }); const blob = new Blob([allContent], { type: 'text/plain' }); const url = URL.createObjectURL(blob); const a = $('<a>').attr({ href: url, download: `所有报告汇总_${new Date().toISOString().split('T')[0]}.txt` }); $('body').append(a); a[0].click(); a.remove(); URL.revokeObjectURL(url); } // 保存报告 $reportForm.on('submit', function (e) { e.preventDefault(); const formData = { id: $reportId.val(), name: $reportName.val(), type: $reportType.val(), date: $reportDate.val(), content: $reportContent.val(), attachments: [] }; if (formData.type === '硬件日志采集报告') { const startDate = $('#log-start-date').val(); const endDate = $('#log-end-date').val(); formData.logStartDate = startDate; formData.logEndDate = endDate; const filteredLogs = hardwareLogs.filter(log => { const logTime = new Date(log.timestamp); const start = new Date(startDate); const end = new Date(endDate); return logTime >= start && logTime <= end; }); if (filteredLogs.length > 0) { const errorCount = filteredLogs.filter(log => log.level === 'ERROR').length; const logSummary = filteredLogs.map(log => `[${log.timestamp}] [${log.device}] [${log.level}]:${log.content}` ).join('\n'); formData.content = typeTemplates['硬件日志采集报告'] .replace('{startDate}', startDate) .replace('{endDate}', endDate) .replace('{errorCount}', errorCount) .replace('{logSummary}', logSummary); formData.attachments.push({ filename: `hardware_logs_${startDate}_${endDate}.txt`, content: filteredLogs.map(log => `${log.timestamp}\n${log.device}\n${log.level}\n${log.content}\n-----\n` ).join('') }); } else { formData.content = '未找到指定时间段的日志数据'; } } const method = formData.id ? 'PUT' : 'POST'; $.ajax({ url: 'api/reports.php', method: method, contentType: 'application/json', data: JSON.stringify(formData), dataType: 'json', success: function (response) { if (response.success) { loadReports(); closeModal(); } else { alert('保存失败:' + (response.message || '未知错误')); } }, error: function (xhr, status, error) { console.error('保存报告失败:', error); alert('保存报告失败,请检查网络连接'); } }); }); // 搜索报告 function handleSearch() { const keyword = $searchInput.val().toLowerCase(); const filtered = reports.filter(report => report.name.toLowerCase().includes(keyword) || report.type.toLowerCase().includes(keyword) ); renderReports(filtered); } // 按日期排序 function sortReportsByDate() { const sorted = [...reports].sort((a, b) => new Date(b.date) - new Date(a.date) ); renderReports(sorted); } // 事件绑定 function bindEvents() { // 报告类型切换 // / 修改报告类型切换事件 $reportType.on('change', function () { const type = $(this).val(); const $startDate = $('#log-start-date'); const $endDate = $('#log-end-date'); $logTimeRange.hide(); $contentDesc.text('请根据报告类型填写内容...'); if (type === '硬件日志采集报告') { $logTimeRange.show(); $contentDesc.text('选择时间段后将自动生成日志摘要'); $reportContent.val(''); // 仅在日志类型下添加必填属性 $startDate.attr('required', true); $endDate.attr('required', true); } else { $reportContent.val(typeTemplates[type] || ''); // 其他类型下移除必填属性 $startDate.removeAttr('required'); $endDate.removeAttr('required'); } }); // 新增报告 $addReportBtn.on('click', () => openModal()); // 关闭模态框 $closeBtn.on('click', closeModal); $cancelBtn.on('click', closeModal); // 点击模态框外部关闭 $(window).on('click', (e) => { if ($(e.target).is($reportModal)) closeModal(); }); // 搜索 $searchBtn.on('click', handleSearch); $searchInput.on('keypress', (e) => { if (e.key === 'Enter') handleSearch(); }); // 排序 $sortByDateBtn.on('click', sortReportsByDate); // 下载全部 $downloadAllBtn.on('click', downloadAllReports); } // 初始化 function init() { bindEvents(); loadHardwareLogs(); loadReports(); } // 页面加载完成后初始化 $(document).ready(init); </script> </body> </html> 优化代码.让拟态窗更加好看
最新发布
07-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值