我想要个弹窗登录

想在我下载的模板里面,添加一个登陆功能。然后不想像以前一样,点击个登陆跳转到个界面,想就在当前界面拉风的出个弹窗,本来想看下bootstrap里面有没有合适的直接借鉴,结果发现,下的模板里面,有个featherlight.min.js的引用,再查看了一下这个插件库是干啥的,wc,不就是我想要的效果吗?!棒棒哒!
github地址:https://github.com/noelboss/featherlight/#installation
中文的一个演示地址:http://demo.lanrenzhijia.com/2013/js891115/

这里这个演示可以看到,既可以弹窗出照片,也可以弹窗出自定义的内容或者面板。那就直接用吧。

引用featherlight,我是用django来搭建网页的,所以这里我的引用地址是酱紫,具体看我的上一篇。

{% load static %}
<link rel="stylesheet" href="{% static 'myloveweb/css/featherlight.min.css' %}">
<script src="{% static 'myloveweb/js/featherlight.min.js' %}" type="text/javascript" charset="utf-8"></script>

先设置个css样式,css3,有用@media all,针对所有设备的,都是这个css设置的意思。
加了这个:

<style type="text/css">
        @media all{
            .lightbox {display:none;}
        }
    </style>

我的登录那个加这个data-featherlight,连接到我自定义的id为log那块。

<li><a href="javascript:" data-featherlight="#log">登录</a>/<a href="#">注册</a></li>
<div class="lightbox" id="log">
  <h2>Featherlight with custom styles</h2>
  <p>It's easy to override the styling of Featherligh. All you need to do is specify an additional class in the data-featherlight-variant of the triggering element. This class will be added and you can then override everything. You can also reset all CSS: <em>$('.special').featherlight({ resetCss: true });</em> </p>
</div>

好了,样式对外不可见,点击了登录的时候,这个id为log的内容就会弹出来。good,准备将我的自定义内容,变成登录的弹窗。
实验
登录那块,想用bootstrap的东西,所以引用其css,js后,登录这块改成了酱紫

<div class="lightbox" id="log">
    <form class="form-horizontal" role="form">
        <div class="form-group">
            <label for="account" class="col-sm-4 control-label">账号</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" id="account" placeholder="请输入账号名称">
            </div>
        </div>
        <div class="form-group">
            <label for="password" class="col-sm-4 control-label">密码:</label>
            <div class="col-sm-8">
                <input type="password" class="form-control" id="password" placeholder="请输入密码">
            </div>
        </div>
        <button type="button" class="col-sm-4 btn btn-primary btn-xs">登录:</button>
    </form>
    </div>

用了bootstrap里面的栅栏,我记得栅栏之和应该是12的,然后就变成下图这样了。
修改后
好了,界面就先酱,考虑后台的内容。想要个管理员和普通成员分开的,所以之后要设定权限的。django那里要开始设定登录的成员数据库什么的了。记得django那里好像可以用自带的数据库,查了下,叫SQLite,以前都用了mysql,要不这里试下django自带的吧,好像很方便的样纸。看下怎么用。弹窗登录先到这里,下篇记录下sqlite

发布了4 篇原创文章 · 获赞 0 · 访问量 47

猜你喜欢

转载自blog.csdn.net/anancycy/article/details/104061957