栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > Web开发 > JavaScript

javascript实现显示和隐藏div方法汇总

JavaScript 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

javascript实现显示和隐藏div方法汇总

javascript实现显示和隐藏div方法汇总





15种方法实现div显示和隐藏


body{
 margin: 0;
}
h1,h2{
 margin: 0;
}
ul{
 margin: 0;
 padding: 0;
 list-style: none;
}
button{
 background-color: #333;
 color: white;
 padding: 5px;
 border: none;
 border-radius: 10px;
}
.box{
 width: 1000px;
 padding: 50px;
 border: 5px solid #333;
 margin: 100px auto 0;
 overflow: hidden;
}
.tit{
 text-align: center;
 margin-bottom: 20px;
}
.in-con{
 padding-top: 10px;
 overflow: hidden;
}
.in{
 width: 188px;
 height: 188px;
 padding: 5px;
 border: 1px solid #333;
 float: left;
 overflow: hidden;
}
.in-show{
 height: 100px;
 width: 120px;
 padding: 10px;
 background-color: orange;
 margin: 10px auto 0;
 line-height: 1.5;
 border-radius: 20px;
 text-align: center;
 word-break: break-all;
 overflow: hidden;
 transition: 0.5s;
}




 

15种方法实现显示和隐藏div

    我们再来看下其他小伙伴是如何实现的

    
    
    
    
    
    
    oec2003
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    居中的DIV

    示例三:

    先来看一个最简单的实例,这个可以实现显示和隐藏层

    
    function $_(id){ 
    return document.getElementById(id);
    };
    function display(x){ 
    $(x).style.display=($(x).style.display=="none")?"":"none";
    };
    
    

    下面是关闭层,其实原理 是一样的只是加了个效果。

    
    
    
    
    无标题文档
    
    body{ position:relative;}
    .wang{ width:100%; height:100%; background:#CCC; display:none; z-index:10; position:fixed; top:0px; left:150px; margin:0 auto; left:inherit; padding:0;filter:alpha(opacity=60); 
      opacity:0.6; }
    .wang ul{ width:100px; height:100px; margin:0 auto;}  
    
    
    
    弹出
    

      转载请注明:文章转载自 www.mshxw.com
      本文地址:https://www.mshxw.com/it/101136.html
      我们一直用心在做
      关于我们 文章归档 网站地图 联系我们

      版权所有 (c)2021-2022 MSHXW.COM

      ICP备案号:晋ICP备2021003244-6号