18910140161

HTML-使用CSS-Stack溢出使内容消失

顺晟科技

2022-10-19 13:16:36

164

我只尝试在测试中使用HTML和CSS。点击圆圈后,我可以将列表显示在框中。我遇到的问题是,当圆圈不活动时,列表仍然可以点击。如果你悬停在右下角,你就可以点击列表并激活它。有没有办法使它只在框出现时才可点击?包括未激活圆圈时列表所在区域的图片。谢谢您的帮助。

在此处输入图像说明


顺晟科技:

设置元素不会导致它以您可能期望的方式隐藏。它仍然可以与之交互,就好像它仍然完全不透明一样。对于某些类型的元素,这包括能够通过键盘导航到它们,并且对于辅助技术如屏幕阅读器也是可见的。

当我需要用动画隐藏或显示元素时,我通常使用的方法是对元素进行动画,因为与属性不同,可以对值进行动画。

以下是我喜欢为此使用的标准动画,它将使元素在动画周期结束时立即出现或消失:

  html {
    background: #1a1a1a;
    color: #e5e5e5;
    text-align: left;
    font-family: Univers, Futura, "Trebuchet MS", Arial, sans-serif;
  }

  body {
    max-width: 1200px;

    overflow-x: hidden;
  }

  .description {
    max-width: 600px;
    margin: 0 auto;
    color: rgba(229, 229, 229, 0.7);
  }

  div {
    position: relative;
    box-sizing: border-box;
  }

  p {
    font-size: 9pt;
    margin-bottom: 1pt;
    margin-top: 2.5pt;
    margin-left: 2px;
    z-index: 5;
  }

  a {
    color: inherit;
    text-decoration: none;
  }

  label {
    font-size: 10pt;
    margin-bottom: 0pt;
    margin-top: 0pt;
    margin-left: 8px;
    color: orange;
    font-weight: bold;
  }

  /*
        .centered {
            position: absolute;
            top: 50%;
            left: 50%;
            -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
        }
*/

  .test {
    position: sticky;
    top: 0px;
    right: 2px;
  }

  .centered-y {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 50%;
    -webkit-transform: translateY(-50%);
    transform: translateY(-50%);
  }

  .distribution-map {
    position: relative;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    margin: 0 auto;
  }

  .distribution-map .map-point {
    cursor: pointer;
    outline: none;
    z-index: 0;
    position: absolute;
    width: 13px;
    height: 13px;
    border-radius: 20px;
    opacity: 0.8;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    -moz-transition: opacity 0.25s ease-in-out 0.25s, width 0.25s ease-in-out 0.25s, height 0.25s ease-in-out 0.25s, z-index 0.25s ease-in-out 0.25s;
    -o-transition: opacity 0.25s ease-in-out 0.25s, width 0.25s ease-in-out 0.25s, height 0.25s ease-in-out 0.25s, z-index 0.25s ease-in-out 0.25s;
    -webkit-transition: opacity 0.25s ease-in-out, width 0.25s ease-in-out, height 0.25s ease-in-out, z-index 0.25s ease-in-out;
    -webkit-transition-delay: 0.25s, 0.25s, 0.25s, 0.25s;
    transition: opacity 0.25s ease-in-out 0.25s, width 0.25s ease-in-out 0.25s, height 0.25s ease-in-out 0.25s, z-index 0.25s ease-in-out 0.25s;
    background: rgba(26, 26, 26, 0.85);
    border: 2.5px solid #cf2045;
  }

  .distribution-map .map-point .content {

    opacity: 0;
    transition: opacity 0.25s ease-in-out;
    width: 100%;
    height: 100%;
    left: 50%;
    -webkit-transform: translateX(-50%);
    transform: translateX(-50%);
    overflow: overlay;
  }

  .distribution-map .map-point:active,
  .distribution-map .map-point:focus {
    margin: 0;
    padding: 0;
    opacity: 1;
    width: 100px;
    height: 100px;
    color: #e5e5e5;
    z-index: 1;
    transition: opacity 0.25s ease-in-out, width 0.25s ease-in-out, height 0.25s ease-in-out;
  }

  .distribution-map .centered-y .map-point:active .content ,
  .distribution-map .map-point:focus .content {

    opacity: 1;
    transition: opacity 0.25s ease-in-out 0.25s, height 0.25s ease-in-out, overflow 0.25s ease-in-out;
    overflow: hidden;
  }

  .distribution-map .map-point:active .content a:hover,
  .distribution-map .map-point:active .content a:active,
  .distribution-map .map-point:focus .content a:hover,
  .distribution-map .map-point:focus .content a:active {
    color: #afe1fa;
  }

不幸的是,由于visibility属性的内插方式,它很难与转换一起使用,因为它会在转换的中间点切换值。这就是为什么我更喜欢通过动画来完成它。

如果您以前没有使用过CSS动画,这里有一个有用的参考和指南:使用CSS动画

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航