js控制div层的叠加简单方法

所属分类: 网络编程 / JavaScript 阅读数: 1037
收藏 0 赞 0 分享

如下所示:

<style type="text/css">
.favorite_icon{float:left; padding: 0 0 0 30px;}
.favorite_label{float:left; width:950px;}
.favorite_label h2{  border-bottom: medium none;height: 60px;padding: 0.8em 0 0 0px;}
.favorite_title{height:60px;margin:0px auto 12px auto;}
.favorite_title a:link, .favorite_title a:visited {color: #333; background-color:#8bb65a;}
.favorite_title a:hover {color: #333;text-decoration: none; background-color:#6c9541;}
.add_favorite {border-radius: 0;color: #fff !important;font-family: "宋体","Helvetica Neue",Helvetica,Arial,sans-serif;
 font-size: 12px;line-height: 17px;padding: 5px 16px;float: right !important;border: medium none;
 height: 18px;background-image: none;cursor: pointer;display: inline-block;font-weight: 400;margin-bottom: 0;
 text-align: center;vertical-align: middle;white-space: nowrap;text-decoration: none;}
#favorite_count{color:#303030;font-size:12px;padding: 0 0 0 7px;}
.favorite_list{clear:both; padding: 0 10px 200px 10px;}
.list_type li{float:left;line-height: 17px;} 
.list_type a{text-decoration: none;font-size: 15px;}
.list_type a:link {color: #6c9541;}
.list_type a:visited{color: #333;}
.list_type a:hover {color: #6c9541;text-decoration: none;}
.list_line{clear:both;height:10px; margin-bottom:10px;border-bottom:1px groove #ccc;}
.nums{font-weight:bold;}
.t1{border-bottom:1px dotted #ccc;height: 40px;padding: 0.8em 0 0 30px;}
.list_content{clear:both;}
.list_content h3{float:left; width:763px;}
.list_content a{text-decoration:none; display:block;font-family: "宋体","Helvetica Neue",Helvetica,Arial,sans-serif;
        font-size: 15px;color: #333; float:left; }
.list_content a:link, .favorite_title a:visited {color:#333;text-decoration: none;}
.list_content a:hover {color: #bb1c20;text-decoration: none; }
.date{color:#ccc;font-size:13px;padding: 0 0 0 7px;float:left !important;text-align: center; 
     vertical-align: middle;white-space: nowrap;text-decoration: none; }
.edit{ margin: 0 0 0 20px;}
.delete{ margin: 0 0 0 10px;}

.black_overlay{display:none;position:absolute;top:0%;left:0%;width:100%;height:100%;
  background-color:black;z-index:1001;-moz-opacity:0.8;opacity:.10;filter:alpha(opacity=80);}
.white_content{display:none;position:absolute;top:15%;left:25%;width:500px;height:250px;padding:16px;
  border:1px solid #ccc;background-color:white;z-index:1002;overflow:auto;}
.white_content a{float:right; color:#aca7a7;text-decoration: none;}
.form-group{clear:both; margin:10px 0 10px 0;}
.control-label{float:left; margin:10px 0 10px 30px;color:#aca7a7;}
#url,#title{width:330px;height:23px;border:solid 1px #ccc; background:#f8f8f8;color:#8d8585;}
.col-xs-9{float:left; margin:10px 0 10px 10px;}
.btn-default,.btn-primary{float:right; width:80px;border-radius: 0;color: #fff !important;
    font-family: "宋体","Helvetica Neue",Helvetica,Arial,sans-serif;font-size: 12px;line-height: 14px;
    padding: 5px 18px;text-align: center;vertical-align: middle;white-space: nowrap;text-decoration: none;}
.btn-default{border:solid 1px #ccc; background:#9a9a9a;color:#fff;margin:15px 20px 0 0;}
.btn-default:hover {background:#8d8585;}
.btn-primary{border:solid 1px #ccc; background:#8bb65a;color:#fff;margin:15px 78px 0 0;}
.btn-primary:hover {background:#6c9541;}
</style>

<div class="favorite_title">
    <div class="favorite_label">
      <img class="favorite_icon" width="48" height="48" src="http://127.0.0.1/phpcms/statics/images/favorite/favorite_icon_48_48.jpg"/>
      <h2>&nbsp;&nbsp;收藏<span id="favorite_count">(n个)</span>
      <a class="add_favorite" href="javascript:void(0)" onclick="add_shoucang();">添加收藏</a>
      </h2>
    </div>
  </div>

  <div class="favorite_list">
    <div class="list_type">
      <ul class="all">
       <li>&nbsp;<a href="#>全部(<span class="nums"></span>)</a></li>
       <li>&nbsp;<a href="#">钢琴谱(<span class="nums"></span>)</a></li>
       <li>&nbsp;<a href="#">钢琴曲(<span class="nums"></span>)</a></li>
      </ul>
    </div>

    <div class="list_line">
    </div>

    <div class="list_content">
      <ul class="navigation" id="navigation">
        {loop $info $r}
        <li class="t1"> 
         <a href="#" ><label class="shoucangId" id="shoucangId" style="display:none;">{$r[id]}</label>
                <h3>{$r[title]}</h3></a>
         <span class="date">{date("Y-m-d",$r[inputtime])}</span>
         <a class="edit" href="javascript:void(0)" onclick="edit_shoucang();">
         <img alt="编辑" src="http://127.0.0.1/phpcms/statics/images/favorite/edit.jpg"/></a>
         <a class="delete" href="JavaScript:void(0)" onclick="ConfirmDel();">
         <img alt="删除" src="http://127.0.0.1/phpcms/statics/images/favorite/delete.jpg"/></a>
         </li>
        {/loop}
        <li class="t1">&nbsp;
        </li>
      </ul>
    </div>
  </div>
  </div>  
  
  <div id="light" class="white_content">
  <a href="javascript:void(0)" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">
  <span>关闭</span></a>
  <br>
  <h2 style="color:#999292;">添加收藏</h2>
  <div class="form-group">
    <label for="url" class="control-label col-xs-2"><span>*</span>网址:</label>
    <div class="col-xs-9">
       <input id="url" type="text" name="url" class="form-control" value=" http://"/>
    </div>
  </div>
  
  <div class="form-group">
    <label for="title" class="control-label col-xs-2"><span>*</span>标题:</label>
    <div class="col-xs-9">
      <input id="title" type="text" name="title" class="form-control" />
    </div>
  </div>

  <div class="form-group">
    <label for="title" class="control-label col-xs-2"><span>*</span>类别:</label>
    <div class="col-xs-9">
     <label id="m1" >
      <input type="radio" name="radio" id="radio_pu" value="钢琴谱" checked="checked"/><span>钢琴谱</span></label>
     <label id="m2"><input type="radio" name="radio" id="radio_qu" value="钢琴曲" /><span>钢琴曲</span></label>
    </div>
  </div>
  
  <div class="form-group">
    <div class="col-xs-5 text-right">
       <input type="submit" value="收藏" name="dosumbit" class="btn btn-primary"/> 
       <button type="button" class="btn btn-default" onclick="document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">取消</button>
    </div>
  </div>

<script type="text/javascript">
//添加收藏
function add_shoucang()
{
  document.getElementById('light').style.display='block';
  document.getElementById('fade').style.display='block';
  $("#title").val('');
  $("#url").val('http://');
  $("#shoucnag_id").val('');
  $("input[name='radio'][value='钢琴谱']").attr("checked",true);
}

//删除
function ConfirmDel() 
{
  var _id;
  if(confirm('确定删除?')) 
   {
     $('.navigation>li').click(function(){
      var iVal = $(this).index();
      $('.navigation>li').eq(iVal).hide();  
    });
   } 

   else 
   {
   document.getElementById('light').style.display='none';
   document.getElementById('fade').style.display='none'
   }
}
</script>

【效果预览】

以上就是小编为大家带来的js控制div层的叠加简单方法全部内容了,希望大家多多支持脚本之家~

更多精彩内容其他人还在看

Angular使用Md5加密的解决方法

这篇文章主要介绍了Angular使用Md5加密的解决方法,需要的朋友可以参考下
收藏 0 赞 0 分享

详解JS构造函数中this和return

本文通过实例代码给大家介绍了JS构造函数中this和return,需要的朋友参考下吧
收藏 0 赞 0 分享

ES6中Array.find()和findIndex()函数的用法详解

ES6为Array增加了find(),findIndex函数。find()函数用来查找目标元素,找到就返回该元素,找不到返回undefined,而findIndex()函数也是查找目标元素,找到就返回元素的位置,找不到就返回-1。下面通过实例详解,需要的朋友参考下吧
收藏 0 赞 0 分享

JS闭包的几种常见形式实例详解

本文通过实例代码给大家详细介绍了js闭包的几种常见形式,代码简单易懂,非常不错,具有参考借鉴价值,需要的朋友参考下
收藏 0 赞 0 分享

ES6中Array.copyWithin()函数的用法实例详解

ES6为Array增加了copyWithin函数,用于操作当前数组自身,用来把某些个位置的元素复制并覆盖到其他位置上去。下面重点给大家介绍ES6中Array.copyWithin()函数的用法,需要的朋友参考下
收藏 0 赞 0 分享

Javascript 严格模式use strict详解

严格模式:由ECMA-262规范定义的JavaScript标准,对javascrip的限制更强。这篇文章主要介绍了Javascript 严格模式use strict详解 ,需要的朋友可以参考下
收藏 0 赞 0 分享

引入JavaScript时alert弹出框显示中文乱码问题

今天在HTML中引入JavaScript文件运行时,alert弹出的提示框中文显示为乱码,怎么解决此问题呢?下面小编给大家带来了引入JavaScript时alert弹出框显示中文乱码问题的解决方法,一起看看吧
收藏 0 赞 0 分享

AngularJs 延时器、计时器实例代码

这篇文章主要介绍了AngularJs 延时器、计时器实例代码,需要的朋友可以参考下
收藏 0 赞 0 分享

JS分页的实现(同步与异步)

这篇文章主要介绍了JS分页的实现(同步与异步),需要的朋友可以参考下
收藏 0 赞 0 分享

Angularjs自定义指令实现分页插件(DEMO)

由于最近的一个项目使用的是angularjs1.0的版本,涉及到分页查询数据的功能,后来自己就用自定义指令实现了该功能,下面小编把实例demo分享到脚本之家平台,需要的朋友参考下
收藏 0 赞 0 分享
查看更多