html - 创建一个图层开/关的页面

标签 html asp.net css layer

我正在尝试创建一个带有图层打开和关闭选项的页面。

有谁知道这种页面怎么做?

请告诉我, 谢谢

最佳答案

这是一个 FIDDLE

<button class="on">Show All</button>
<button class="off">Hide All</button>
<button data-rel="one">One</button>
<button data-rel="two">Two</button>
<button data-rel="three">Three</button>

<div class="one layer"></div>
<div class="two layer"></div>
<div class="three layer"></div>

div {
  position: absolute;
  width: 500px;
  height: 500px;
  top: 100px;
  left: 50%;
  margin-left: -250px;;
  opacity: 0.3;
}
button {
  width: 75px;
  margin-right: 15px;
}
.one {
  background: url(image1.png) 110px 0 no-repeat;
  background-size: 40px 40px;
}
.two {
  background: url(image2.png) 250px 150px no-repeat;
  background-size: 60px 60px;
}
.three {
  background: url(image3.png) 410px 310px no-repeat;
  background-size: 80px 80px;
}

$(function() {

  $('button').click(function() {

    var el = $('.'+$(this).data('rel'));

    if(el.css('opacity') === '1') {
       el.stop().animate({ opacity: '0.3' }, 300, 'linear');
    }
    else {
       el.stop().animate({ opacity: '1' }, 300, 'linear');
    }

  });

  $('.on').click(function() {
    $('.layer').stop().animate({ opacity: '1' }, 300, 'linear');    
  });

  $('.off').click(function() {
    $('.layer').stop().animate({ opacity: '0.3' }, 300, 'linear');    
  });

});

关于html - 创建一个图层开/关的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20551395/

相关文章:

javascript - Laravel 5 中无法包含内部 JS 文件

javascript - 如何仅在加载所有元素后才在头部加载Javascript

javascript - 暂停后如何停止加载嵌入的youtube视频

jquery - 根据具有背景大小封面的内容固定图像大小比例

html - 我如何在自己的HTML播放器中播放音频格式的youtube视频

asp.net - 在 ASP.NET 中上传文件时运行病毒扫描

c# - Web 服务拒绝接收参数并以 JSON 格式回复

c# - 如何将自定义属性添加到 RadioButtonList 项目?

css - 用 h3 样式覆盖链接 CSS

JavaScript 在 html/css 内容中旋转