学习前端有时很多时候要用到弹出层,原生的js写有些麻烦,而且不美观,基于jQuery的弹出层组件layer应运而生,近些年来备受青睐。官网上有使用教程,但当初用的时候还是糊里糊涂,今天来记录一下layer组件的步骤

1step:

新建一个html文件,并引入下载好的jQuery和layer.js。

   2step:

   码字

  

 <!doctype html>
<html>
<meta charset="utf-8">
<head>
<title></title>
<style> </style>
<!--导入外部js脚本-->
<script src="../jquery-3.3.1.js"></script> <script src="../layer例子/layer-v3.1.1/layer/layer.js"></script>
</head>
<body>
<div style="width:1000px;height:1000px;margin:auto;border:1px solid #999;">
<button style="width:70px;height:40px;float:left;font-size:13px;line-height:20px;text-align:center;" onClick="openRegister()">点击我</button>
</div> <!--弹出层界面-->
<div style="display:none;padding:30px;" id="registerlayer">
<span style="color:#999;font-size:25px;float:left">注册</span>
<span style="color:#999;font-size:13px;float:right;margin:10px 0 0 0;" class="hover3" onClick="goLogin()">快速登录</span>
<div style="width:298px;height:138px;float:left;border:1px solid #ccc;margin:30px 0 0 0;">
<input style="width:294px;height:42px;border:1px solid #fff;border-bottom:1px solid #ccc;" type="text" placeholder="注册新用户">
<input style="width:294px;height:42px;border:1px solid #fff;border-bottom:1px solid #ccc;" type="password" placeholder="请设置密码">
<input style="width:294px;height:42px;border:1px solid #fff;" type="password" placeholder="请确认密码">
</div>
<input style="margin:20px 0 0 0;float:left;" type="checkbox" id="registerAgree" checked="checked" >
<span style="margin:18px 0 0 0 ;float:left;font-size:12px;color:#999;">&nbsp;我已阅读并接受鹦鹉网</span>
<span style="margin:18px 0 0 0 ;float:left;font-size:12px;color:#069;" class="hover4">《服务协议》</span>
<span style="margin:18px 0 0 0 ;float:left;font-size:12px;color:#999;">和</span>
<span style="margin:18px 0 0 0 ;float:left;font-size:12px;color:#069;" class="hover4">《账户协议》</span>
<div style="width:298px;height:40px;float:left;background:#6FAC22;margin:30px 0 0 0;text-align:center;line-height:40px;font-size:16px;" id="register" >注&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;册</div>
</div> <script>
//注册弹出层
function openRegister(){
layer.open({
type: 1,
title: false,
area : ['360px' , '400px'],
closeBtn: 0,
shadeClose: true,
skin: 'yourclass',
content: $('#registerlayer'),
});
} $(document).ready(function(){
$("#registerAgree").click(function(){ var check=document.getElementById("registerAgree"); if(check.checked!=true){
$("#register").css("background","#ccc");
}
else {
$("#register").css("background","#6FAC22");
}
});
});
</script> </body>

html/css/js-layer弹出层的初次使用的更多相关文章

  1. layer弹出层

    最近因为项目要求做了一个layer弹出层demo,先看效果图 好了,现在开始上代码 index.jsp <%@ page language="java" import=&qu ...

  2. js插件---弹出层sweetalert2(总结)

    js插件---弹出层sweetalert2(总结) 一.总结 一句话总结: sweetalert2的效果非常好,效果比较Q萌,移动端适配也比较好,感觉比layer.js效果好点 1.SweetAler ...

  3. layer弹出层右上角的关闭按钮怎么没有显示

    问题描述:layer弹出层右上角的关闭按钮怎么没有显示,但鼠标移上去又可以点击 解决方式: 这是因为样式中需要一个图标,你的项目中缺少.解决如下:1.下载图标:http://www-x-zi-han- ...

  4. js简单弹出层、遮罩层

    <html> <head> <title>js简单弹出层</title> <style> /*阴影边框效果*/ .box-shadow-1 ...

  5. layer弹出层设置相对父级元素定位

    layer弹出层默认是相对body固定定位的,可是项目中一般需要相对某个盒子相对定位,下面是个加载弹层例子: var loadIndex = layer.open({ type: 3, //3 表示加 ...

  6. layer弹出层不居中解决方案

    layer弹出层不居中解决方案 代码头中加入以下代码即可 <!doctype html>

  7. layer弹出层不居中解决方案,layer提示不屏幕居中解决方法,layer弹窗不居中解决方案

    layer弹出层不居中解决方案,layer提示不屏幕居中解决方法,layer弹窗不居中解决方案 >>>>>>>>>>>>> ...

  8. Layer弹出层销毁问题

    Layer弹出层销毁问题 最近开发时有个问题记录一下 点击按钮显示相应的图表信息,当时自己点感觉没问题,谁知到测试手里多次点击就会有后续打开的窗口无法渲染问题,看了半天才发现是调用layer.clos ...

  9. layer 弹出层 回调函数调用 弹出层页面 函数

    1.项目中用到layer 弹出层,定义一个公用的窗口,问题来了窗口弹出来了,如何保存页面上的数据呢?疯狂百度之后,有了结果,赶紧记下. 2.自己定义的公共页面方法: layuiWindow: func ...

  10. layer 弹出层 不居中

    layer弹出层不居中解决方案 代码头中加入以下代码即可 <!doctype html>

随机推荐

  1. [lightoj P1306] Solutions to an Equation

    [lightoj P1306] Solutions to an Equation You have to find the number of solutions of the following e ...

  2. Swiper.js使用及API介绍

    Swiper.js详细使用教程http://www.swiper.com.cn/api/start/2014/1218/140.html

  3. Python—字符编码转换、函数基本操作

    字符编码转换 函数 #声明文件编码,格式如下: #-*- coding:utf-8 -*- 注意此处只是声明了文件编码格式,python的默认编码还是unicode 字符编码转换: import sy ...

  4. 同时使用n和nvm踩到的坑

    平时在公司的时候,一直只使用一个node版本.这两天想多了解下node的新版本,使用tj大神的 n 包管理工具来安装node包. 安装过程中一直难以容忍过慢的包下载速度,于是根据日志的描述直接把包下载 ...

  5. ubuntu14.04, Cloudera Manager 5.11.1, cdh5.11.1 postgresql离线部署

    最近一段时间团队接到的项目需要处理的数据量非常大,之前的处理方式难以满足现有需求.最近两周前前后后折腾了不少,在搭建了hadoop+hbase+hive+spark的一个集群后,由于感觉管理和监控太麻 ...

  6. 【Cocos2d-html5】运动中速度效果

    在我们使用Action系统动作的时候,比如MoveTo,在进行运动的时候总是在规定的时间内进行匀速运动,有时候可能会想添加一些加速度的效果,cocos2d-html5就依然和cocos2dx一样为我们 ...

  7. 添加网络打印机的步骤(xp和win2008+win7)

    1.如题,设置好打印机的 ip地址和子网掩码等信息. 2 .xp不像其他新的系统那么好用那么智能...只能慢慢来 如果是xp,注意,请添加网络打印机的时候选  :添加本地打印机,,记得哦 然后如图 然 ...

  8. springcloud Zuul学习笔记

    SpringCloud Zull是一个基于NetflixZuul实现的API网关组件,它实现了请求路由,负载均衡,校验过滤等功能;本文主要记录springcloud zuul的入门级demo开发过程; ...

  9. noj电子老鼠走迷宫(深搜dfs)超时错误

    1042.电子老鼠闯迷宫 时限:1000ms 内存限制:10000K  总时限:3000ms 描述 有一只电子老鼠被困在如下图所示的迷宫中.这是一个12*12单元的正方形迷宫,黑色部分表示建筑物,白色 ...

  10. go example

    一个简单的博客系统 https://github.com/pingguoxueyuan/gostudy/tree/master/blogger