html/css/js-layer弹出层的初次使用
学习前端有时很多时候要用到弹出层,原生的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;"> 我已阅读并接受鹦鹉网</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" >注 册</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弹出层的初次使用的更多相关文章
- layer弹出层
最近因为项目要求做了一个layer弹出层demo,先看效果图 好了,现在开始上代码 index.jsp <%@ page language="java" import=&qu ...
- js插件---弹出层sweetalert2(总结)
js插件---弹出层sweetalert2(总结) 一.总结 一句话总结: sweetalert2的效果非常好,效果比较Q萌,移动端适配也比较好,感觉比layer.js效果好点 1.SweetAler ...
- layer弹出层右上角的关闭按钮怎么没有显示
问题描述:layer弹出层右上角的关闭按钮怎么没有显示,但鼠标移上去又可以点击 解决方式: 这是因为样式中需要一个图标,你的项目中缺少.解决如下:1.下载图标:http://www-x-zi-han- ...
- js简单弹出层、遮罩层
<html> <head> <title>js简单弹出层</title> <style> /*阴影边框效果*/ .box-shadow-1 ...
- layer弹出层设置相对父级元素定位
layer弹出层默认是相对body固定定位的,可是项目中一般需要相对某个盒子相对定位,下面是个加载弹层例子: var loadIndex = layer.open({ type: 3, //3 表示加 ...
- layer弹出层不居中解决方案
layer弹出层不居中解决方案 代码头中加入以下代码即可 <!doctype html>
- layer弹出层不居中解决方案,layer提示不屏幕居中解决方法,layer弹窗不居中解决方案
layer弹出层不居中解决方案,layer提示不屏幕居中解决方法,layer弹窗不居中解决方案 >>>>>>>>>>>>> ...
- Layer弹出层销毁问题
Layer弹出层销毁问题 最近开发时有个问题记录一下 点击按钮显示相应的图表信息,当时自己点感觉没问题,谁知到测试手里多次点击就会有后续打开的窗口无法渲染问题,看了半天才发现是调用layer.clos ...
- layer 弹出层 回调函数调用 弹出层页面 函数
1.项目中用到layer 弹出层,定义一个公用的窗口,问题来了窗口弹出来了,如何保存页面上的数据呢?疯狂百度之后,有了结果,赶紧记下. 2.自己定义的公共页面方法: layuiWindow: func ...
- layer 弹出层 不居中
layer弹出层不居中解决方案 代码头中加入以下代码即可 <!doctype html>
随机推荐
- Jsp 国际化访问首页选择展示不同字体小例子
要求:创建一个首页,默然显示英文信息,但可以让用户选择使用英文,繁体中文或简体中文. 1.编写hello_en_US.txt,内容如下: cc.openhome.welcome=welcomecc.o ...
- C语言函数的存储类别
函数默认的隐含存储类型是extern auto:只能用于局部变量 extern:允许被其他文件调用 static:只能被本源程序文件调用
- 用canvas画一个房子
<!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <script t ...
- JDBC遇到向ORACLE数据库表执行插入操作时,报错“列在此处不允许”
此异常的原因在于,编写的SQL语句,其中的变量已经成了字符串,这种情况对数值类数据没有影响,但是对字符串类数据有影响,应该在SQL语句中的字符串类变量左右两边加上单引号.如下:
- while +for+字符串
# while 循环嵌套# user_from_db='egon'# pwd_from_db='123'# while True:# usr_inp=input('username>>&g ...
- [多线程] 线程中的synchronized关键字锁
为什么要用锁? 在多线程中,难免会出现在多个线程中对同一个对象的实例变量或者全局静态变量进行并发访问的情况,如果不做正确的同步处理,那么产生的后果就是"脏读",也就是取到的数据其实 ...
- webView 获取内容高度不准确的原因是因为你设置了某个属性
不管是UIWebView 还是 WKWebView 这里 获取js属性 获取高度的方法 我就不一一细说了 ,本文最主要不说这个 ,网上有太多的方法 我最不摘几个 CGFloat webViewHeig ...
- ios MQTT协议的实际应用
1,创建单视图项目,pod search mqtt找到一个库,然后在项目目录下pod init 出Podfile 2,pod install 安装mqtt库 3,主要代码: #import " ...
- Angular新手容易碰到的坑
在Angular群里回答新手问题一段时间了,有一些Angular方面的坑留在这里备查,希望能对各位有所帮助.这个文章将来会随时更新,不会单独开新章,欢迎各位订阅. Q1.<div ng-incl ...
- Idea 2017.3以后版本的破解
自从升级到idea2017.3之后,之前的license server破解方法貌似已失效.于是找到大神用的破解插件,很好很强大. 安装好idea之后不要打开软件,从http://idea.lanyus ...