单击切换图标后如何隐藏纯抽屉标签和图标?

时间:2015-07-27 14:10:17

标签: javascript css

我正在使用http://mac81.github.io/pure-drawer/找到的左切换菜单的纯抽屉css。一旦点击它,我需要隐藏抽屉标签和图标。我有代码在点击屏幕上的其他位置时切换回来,除了切换的分区。纯切换标签的CSS如下。



.pure-toggle-label {
  display: none;
  cursor: pointer;
  display: block;
  position: fixed;
  
  top: 20px;
  z-index: 20;
  color: #5d809d;
  width: 40px;
  height: 40px;
  transition: all 400ms ease-in-out;
  border: 2px solid #5d809d;
  border-radius: 50%;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -o-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
  .pure-toggle-label:hover {
    border-color: #1fc08e;
    color: #1fc08e; }
    .pure-toggle-label:hover .pure-toggle-icon, .pure-toggle-label:hover .pure-toggle-icon:before, .pure-toggle-label:hover .pure-toggle-icon:after {
      background-color: #1fc08e; }
  .pure-toggle-label:active {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
  .pure-toggle-label .pure-toggle-icon, .pure-toggle-label .pure-toggle-icon:before, .pure-toggle-label .pure-toggle-icon:after {
    position: absolute;
    top: 50%;
    left: 50%;
    height: 4px;
    width: 10px;
    cursor: pointer;
    background: #5d809d;
    display: block;
    content: '';
    transition: all 400ms ease-in-out; }
  .pure-toggle-label .pure-toggle-icon {
    transform: translate3d(-50%, -4px, 0);
    -webkit-transform: translate3d(-50%, -4px, 0); }
  .pure-toggle-label .pure-toggle-icon:before {
    transform: translate3d(-50%, -14px, 0);
    -webkit-transform: translate3d(-50%, -14px, 0); }
  .pure-toggle-label .pure-toggle-icon:after {
    transform: translate3d(-50%, 10px, 0);
    -webkit-transform: translate3d(-50%, 10px, 0); }

.pure-toggle-label[data-toggle-label='left'] {
  left: 15px;
  right: auto; }

.pure-toggle-label[data-toggle-label='right'] {
  right: 28px;
  left: auto; }

.pure-toggle-label[data-toggle-label='top'] {
  left: 50%;
  -webkit-transform: translate3d(-50%, 0, 0);
  transform: translate3d(-50%, 0, 0); }

.pure-toggle[data-toggle='left']:checked ~ .pure-toggle-label:not([data-toggle-label='left']), .pure-toggle[data-toggle='right']:checked ~ .pure-toggle-label:not([data-toggle-label='right']), .pure-toggle[data-toggle='top']:checked ~ .pure-toggle-label:not([data-toggle-label='top']) {
  opacity: 0;
  z-index: -1; }

.pure-toggle[data-toggle='left']:checked ~ .pure-toggle-label[data-toggle-label='left'], .pure-toggle[data-toggle='right']:checked ~ .pure-toggle-label[data-toggle-label='right'], .pure-toggle[data-toggle='top']:checked ~ .pure-toggle-label[data-toggle-label='top'] {
  border-color: #1fc08e;
  color: #1fc08e; }
  .pure-toggle[data-toggle='left']:checked ~ .pure-toggle-label[data-toggle-label='left'] .pure-toggle-icon, .pure-toggle[data-toggle='right']:checked ~ .pure-toggle-label[data-toggle-label='right'] .pure-toggle-icon, .pure-toggle[data-toggle='top']:checked ~ .pure-toggle-label[data-toggle-label='top'] .pure-toggle-icon {
    background-color: transparent; }
  .pure-toggle[data-toggle='left']:checked ~ .pure-toggle-label[data-toggle-label='left'] .pure-toggle-icon:before, .pure-toggle[data-toggle='left']:checked ~ .pure-toggle-label[data-toggle-label='left'] .pure-toggle-icon:after, .pure-toggle[data-toggle='right']:checked ~ .pure-toggle-label[data-toggle-label='right'] .pure-toggle-icon:before, .pure-toggle[data-toggle='right']:checked ~ .pure-toggle-label[data-toggle-label='right'] .pure-toggle-icon:after, .pure-toggle[data-toggle='top']:checked ~ .pure-toggle-label[data-toggle-label='top'] .pure-toggle-icon:before, .pure-toggle[data-toggle='top']:checked ~ .pure-toggle-label[data-toggle-label='top'] .pure-toggle-icon:after {
    top: 0; }
  .pure-toggle[data-toggle='left']:checked ~ .pure-toggle-label[data-toggle-label='left'] .pure-toggle-icon:before, .pure-toggle[data-toggle='right']:checked ~ .pure-toggle-label[data-toggle-label='right'] .pure-toggle-icon:before, .pure-toggle[data-toggle='top']:checked ~ .pure-toggle-label[data-toggle-label='top'] .pure-toggle-icon:before {
    transform: translateX(-50%) rotate(45deg);
    -webkit-transform: translateX(-50%) rotate(45deg); }
  .pure-toggle[data-toggle='left']:checked ~ .pure-toggle-label[data-toggle-label='left'] .pure-toggle-icon:after, .pure-toggle[data-toggle='right']:checked ~ .pure-toggle-label[data-toggle-label='right'] .pure-toggle-icon:after, .pure-toggle[data-toggle='top']:checked ~ .pure-toggle-label[data-toggle-label='top'] .pure-toggle-icon:after {
    transform: translateX(-50%) translateY(-10px) rotate(-45deg);
    -webkit-transform: translateX(-50%) translateY(-10px) rotate(-45deg);
    top: 10px; }




1 个答案:

答案 0 :(得分:0)

这应该在点击

后隐藏标签(标签内的图标)
.pure-toggle:checked ~ .pure-toggle-label{
  display: none;
}