【问题标题】:HTML/CSS Input focus outside rangeHTML/CSS 输入焦点超出范围
【发布时间】:2017-10-03 23:19:59
【问题描述】:

我的网站上有一个表格,由于某种原因,有一些空间在单击它们后会自动聚焦到第二列中的字段。我试图找到任何可能导致它但没有任何运气的元素。我从来没有见过这样的行为。

您可以在此处查看表单:不再存在

任何帮助都会很好。

如果你需要看 css 我可以提供一个 sass 版本:

@keyframes input-underline {
  0% {
    left: 0;
    right: 0;
  }

  50% {
    left: 0;
    right: 100%;
    background: #ccc;
  }

  51% {
    background: $secondary-color;
  }

  100% {
    background: $secondary-color;
    left: 0;
    right: 0;
  }
}

.contact {
    form {
        display: block;
        max-width: 100%;

        label {
            position: relative;
            display: block;
            width: 100%;

            &::before {
                position: absolute;
                content: '';
                bottom: 0;
                height: 2px;
                left: 0;
                right: 0;
                transition: background .6s linear;
                background: #ccc;
            }

            &.active {
                &::before {
                    animation: input-underline .6s linear forwards;
                    background: #ccc;
                }

                .input-label {
                    top: -16px;
                    font-size: .925rem;
                }
            }

            .input-label {
                position: absolute;
                top: 7px;
                left: 0;
                transition: top .15s linear, font-size .15s linear;
                z-index: -1;
            }
        }

        .input {
            display: block;
            background: transparent;
            width: 100%;
            padding: 10px 0;
            border: none;
            font-family: inherit;
            font-weight: $global-weight-light;

            &.textarea {
                min-height: auto;
                height: 38px;
                max-width: 100%;
                max-height: 154px;
                resize: none;
                overflow-x: hidden;
            }
        }

        .select, .submit {
            appearance: none;
        }

        .submit {
            display: block;
            border: none;
            width: 100%;
            max-width: 260px;
            margin: 0 auto;
            padding: 10px 0;
            border-radius: 4px;
            box-shadow: 0 0 2px 0 #1d1d1b;
            background: $secondary-color;
            color: $white;
            cursor: pointer;
        }
    }
}

这里的完整代码:不存在了

这里的JS代码:不存在了

编辑:我使用 ZURB 基金会,以防万一。 编辑:提供的链接不再有效,所以我删除了它们。

【问题讨论】:

  • 你有 HTML 吗?
  • @LouysPatriceBessette 我在上图中标记了空格。我实际上要求更多人在多台 PC 上尝试它,他们都遇到了同样的问题。 i.stack.imgur.com/oE0oQ.jpg
  • 我明白了...这就是我删除评论的原因。这很奇怪,我同意。
  • @JamesDouglas 您可以在浏览器中通过 View Source 查看 HTML。
  • 奇怪的也没见过这样的东西

标签: jquery html css sass


【解决方案1】:

我建议您将所有 <div class="row"> 包装在 <div class="table"> 中。

然后使用这个 CSS:

.table{
  display:table;
}
.row{
  display:table-row;
}
.row div{
  display:table-cell;
}

并摆脱:

.row::before,
.row::after {
  display: table;
  content: ' ';
}

【讨论】:

  • 是的,问题是这是 Foundation 框架的一部分......但无论如何我只是添加了这个: .contact .row::after {content: normal;} 它解决了问题。谢谢!
  • 喂...我明白了。好吧,我将按原样保留我的答案......因为这是它应该的方式。但是您的评论对于解决此“基础”问题很有用。
猜你喜欢
  • 1970-01-01
  • 2013-05-30
  • 2017-08-02
  • 1970-01-01
  • 1970-01-01
  • 2011-05-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多