css模仿微信弹出菜单 

效果图:

 

html:

  1. <div class="action-sheet-backdrop">
  2. <div class="action-sheet-wrapper">
  3. <div class="action-sheet">
  4. <div class="action-sheet-group action-sheet-options">
  5. <div class="action-sheet-title">选择</div>
  6. <button class="button action-sheet-option ">未婚</button>
  7. <button class="button action-sheet-option ">已婚</button>
  8. </div>
  9. <div class="action-sheet-group action-sheet-cancel">
  10. <button class="button">取消</button>
  11. </div>
  12. </div>
  13. </div>
  14. </div>

  

css:

  1. .action-sheet-backdrop {
  2. -webkit-transition: background-color 150ms ease-in-out;
  3. transition: background-color 150ms ease-in-out;
  4. position: fixed;
  5. top: 0;
  6. left: 0;
  7. z-index: 11;
  8. width: 100%;
  9. height: 100%;
  10. background-color: rgba(0, 0, 0, 0);
  11.  
  12. }
  13.  
  14. .action-sheet-backdrop.active {
  15. background-color: rgba(0, 0, 0, 0.4);
  16.  
  17. }
  18.  
  19. .action-sheet-wrapper {
  20. -webkit-transform: translate3d(0, 100%, 0);
  21. transform: translate3d(0, 100%, 0);
  22. -webkit-transition: all cubic-bezier(0.36, 0.66, 0.04, 1) 500ms;
  23. transition: all cubic-bezier(0.36, 0.66, 0.04, 1) 500ms;
  24. position: absolute;
  25. bottom: 0;
  26. left: 0;
  27. right: 0;
  28. width: 100%;
  29. max-width: 500px;
  30. margin: auto;
  31. }
  32.  
  33. .action-sheet-up {
  34. -webkit-transform: translate3d(0, 0, 0);
  35. transform: translate3d(0, 0, 0);
  36. }
  37.  
  38. .action-sheet {
  39. margin-left: 8px;
  40. margin-right: 8px;
  41. width: auto;
  42. z-index: 11;
  43. overflow: hidden;
  44. }
  45.  
  46. .action-sheet .button {
  47. display: block;
  48. padding: 1px;
  49. width: 100%;
  50. border-radius: 0;
  51. border-color: #d1d3d6;
  52. background-color: transparent;
  53. color: #007aff;
  54. font-size: 21px;
  55. }
  56.  
  57. .action-sheet .button:hover {
  58. color: #007aff;
  59. }
  60.  
  61. .action-sheet .button.destructive {
  62. color: #ff3b30;
  63. }
  64.  
  65. .action-sheet .button.destructive:hover {
  66. color: #ff3b30;
  67. }
  68.  
  69. .action-sheet .button.active, .action-sheet .button.activated {
  70. box-shadow: none;
  71. border-color: #d1d3d6;
  72. color: #007aff;
  73. background: #e4e5e7;
  74. }
  75.  
  76. .action-sheet-has-icons .icon {
  77. position: absolute;
  78. left: 16px;
  79. }
  80.  
  81. .action-sheet-title {
  82. padding: 16px;
  83. color: #8f8f8f;
  84. text-align: center;
  85. font-size: 13px;
  86. }
  87.  
  88. .action-sheet-group {
  89. margin-bottom: 8px;
  90. border-radius: 4px;
  91. background-color: #fff;
  92. overflow: hidden;
  93. }
  94.  
  95. .action-sheet-group .button {
  96. border-width: 1px 0px 0px 0px;
  97. }
  98.  
  99. .action-sheet-group .button:first-child:last-child {
  100. border-width: 0;
  101. }
  102.  
  103. .action-sheet-options {
  104. background: #f1f2f3;
  105. max-height: 520px;
  106. overflow-y: auto;
  107. }
  108.  
  109. .action-sheet-cancel .button {
  110. font-weight: 500;
  111. }
  112.  
  113. .action-sheet-open {
  114. pointer-events: none;
  115. }
  116.  
  117. .action-sheet-open.modal-open .modal {
  118. pointer-events: none;
  119. }
  120.  
  121. .action-sheet-open .action-sheet-backdrop {
  122. pointer-events: auto;
  123. z-index: 1111;
  124. }
  125.  
  126. .action-sheet .action-sheet-title, .platform-android .action-sheet .button {
  127. text-align: center;
  128. }
  129.  
  130. .action-sheet-cancel {
  131. display: block;
  132. }

  

只需要js控制切换class名。

  1. $("body").click(function(){
  2. $("body").addClass("action-sheet-open");
  3. $(".action-sheet-backdrop").addClass("active");
  4. $(".action-sheet-wrapper").addClass("action-sheet-up")
  5. })
  6. $(".button").click(function(event){
  7. $("body").removeClass("action-sheet-open");
  8. $(".action-sheet-backdrop").removeClass("active");
  9. $(".action-sheet-wrapper").removeClass("action-sheet-up")
  10. event.stopPropagation( );
  11. })

  

  

最终的效果图为:

css模仿微信弹出菜单的更多相关文章

  1. 纯div+css制作的弹出菜单

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. DIV+CSS制作二级横向弹出菜单,略简单

    没有使用JavaScript控制二级菜单的显示,结果如上图所示. 代码如下: <!DOCTYPE html> <html> <head> <meta char ...

  3. 布局分析002:入门级的CSS导航弹出菜单

    这种弹出菜单非常有意思,也有记录的意义,甚至可以说,掌握了这种弹出菜单,基本上CSS掌握的差不多. 主要涉及下面三个重要知识: CSS的继承性质. relative absolute定位. 子选择符& ...

  4. css+html+js实现多级下拉和弹出菜单

    本文将使用css+html+js实现横向菜单.具有多级弹出菜单下拉. 首先我们来看看效果图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvajkwMzgy ...

  5. HTML5微信长按图片不会弹出菜单的解决方法

    HTML5微信长按图片不会弹出菜单的解决方法 <pre><div ontouchstart = "return false;"></div>&l ...

  6. 向上弹出菜单jQuery插件

    插件名:柯乐义英文名:Keleyijs文件名称:jquery.keleyi.js插件功能:该插件可以让你轻易地在页面上构建一个向上弹出的二级菜单. 示例查看:http://keleyi.com/kel ...

  7. html5手机端遮罩弹出菜单代码

    效果体验:http://hovertree.com/texiao/html5/17/ 效果图: 代码如下: <!doctype html> <html lang="zh&q ...

  8. html + js 右 点击 弹出 菜单

    页面 引用jar 包 <link rel="stylesheet" href="../../style/zui.min.css" type="t ...

  9. 仿酷狗音乐播放器开发日志二十六 duilib在标题栏弹出菜单的方法

    转载请说明原出处,谢谢~~ 上篇日志说明了怎么让自定义控件响应右键消息.之后我给主窗体的标题栏增加右键响应,观察原酷狗后可以发现,在整个标题栏都是可以响应右键并弹出菜单的.应该的效果如下: 本以为像上 ...

随机推荐

  1. MySQL 开启事件 使用定时器调用存储过程

      mysql定时器是系统给提供了event,而oracle里面的定时器是系统给提供的job.废话少说,下面创建表:create table mytable (id int auto_incremen ...

  2. Spring Boot 多环境部署

    再简单的应用系统,通常都有两个环境——开发环境和线上环境.大型的企业应用还会有更多的环境,比如测试环境.准线上环境.演示环境等.应用的版本也可能对应了多个环境,比如1.0版本的演示环境.2.0版本的演 ...

  3. sea.js模块化工具

    sea.js 一. sea.js向全局中引入了两个变量seajs.define: 1.seajs用加载文件 seajs.use(deps,callback)异步引入入口模块 路径要以sea.js文件所 ...

  4. Window10 Electron 开发环境搭建及打包exe程序

    1.安装 Electron 首先要安装Node.js     (安装方法:https://www.cnblogs.com/inkwhite/p/9685520.html) 我这里已经安装好了. 2:安 ...

  5. 帆软SQL报异常:多表连接的时候出现错误:未明确定义列

    我刚开始的代码: select dm_veh_jdcgz_mx.DAY_ID ,--日期 dm_veh_jdcgz_mx.GLBM ,--管理部门ID dm_veh_jdcgz_mx.SFZMHM , ...

  6. python 自定义函数表达式 拟合求系数

    https://docs.scipy.org/doc/scipy/reference/tutorial/integrate.html https://docs.scipy.org/doc/scipy/ ...

  7. mac安装ruby-oci8

    1.安装xcode 2.从oracle官网下载以下安装包 instantclient-basic-macos.x64-12.1.0.2.0.zip instantclient-sdk-macos.x6 ...

  8. c语言实现通讯录管理系统(c课程设计)

    工具:Visual C++6.0 说明: 本系统基于C语言实现班级通讯录管理系统,为大一时学习C语言刚入门所做的课程设计.功能包括增.删.查.改等,非常适合初学者练手.通讯录包括的个人信息有姓名.学号 ...

  9. BZOJ3209(luogu 4317)花神的数论题题解

    题目 设 sum(i) 表示 i 的二进制表示中 1 的个数.给出一个正整数 N ,花神要问你 派(Sum(i)),也就是 sum(1)—sum(N) 的乘积(n<=1e15). 分析 好吧,一 ...

  10. python是一门解释性语言吗?

    其实这只能算说对了一半,准确来说是编译跟解释性语言.python跟java.C# 一样都是会预编译一部分代码(简称做了优化) 都知道java编译要先在cmd里敲 javac hello.world 是 ...