duan6832168 2017-06-15 09:24
浏览 41
已采纳

如何使用Javascript打开模态

I have an HTML code which have fab floating button when i click on that button i want to open a modal popup window but I don't know how to do it.

index.html

<html>
<head>
    <link rel="stylesheet" href="dist/css/kc.fab.css"/>
    <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
</head>
<body>
    <h1 style="text-align: center;">Materialize Floating Action Button - jQuery plugin</h1>
    <h2 style="text-align: center;">Please feel free to use and contribute! :)</h2>
    <div class="kc_fab_wrapper" >

    </div>


    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src="dist/js/kc.fab.min.js"></script>
    <script>
        $(document).ready(function(){
            var links = [
                {
                    "bgcolor":"red",
                    "icon":"+"
                },
                {
                    "url":"http://www.example.com",
                    "bgcolor":"red",
                    "color":"#fffff",
                    "icon":"<i class='fa fa-phone'></i>",
                    "target":"_blank"
                },
                {
                    "url":"http://www.example.com",
                    "bgcolor":"black",
                    "color":"white",
                    "icon":"<i class='fa fa-music'></i>"
                }
            ]
            $('.kc_fab_wrapper').kc_fab(links);
        })
    </script>
</body>

for more below demo is helpful http://www.jqueryscript.net/menu/Material-Design-Floating-Action-Button-with-jQuery-KC-FAB.html

  • 写回答

1条回答 默认 最新

  • dsogx84602 2017-06-15 09:37
    关注

    May I suggest having a look at http://materializecss.com

    Fiddle example: https://jsfiddle.net/mikeferrari/a4xhxknk/

    Include the script and css file in your index.html page first

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/css/materialize.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/js/materialize.min.js"></script>
    

    I use this frequently and the documentation and example code is great. There is an easy to implement example for a modal button here:

    <!-- Modal Trigger -->
    <a class="waves-effect waves-light btn" href="#modal1">Modal</a>
    
    <!-- Modal Structure -->
    <div id="modal1" class="modal">
      <div class="modal-content">
        <h4>Modal Header</h4>
        <p>A bunch of text</p>
    </div>
    <div class="modal-footer">
      <a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat">Agree</a>
    </div>
    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题