【问题标题】:How to use the cursor proberty with position relative and why does it not work?如何使用相对位置的光标探针,为什么它不起作用?
【发布时间】:2015-12-05 17:40:06
【问题描述】:

大家好,我已经在网上搜索了很长时间,但仍然无法解决。

.login input[type="submit"] {
  background: #2196f3;
  border-radius: 5px;
  border: 1px solid #0d47a1;
  color: #FFF;
  cursor: pointer;
  font-weight: bold;
  line-height: 48px;
  margin-top: 20px;
  position: relative;
  text-align: center;
  text-transform: uppercase;
  width: 242px;
  z-index: -1;
}

【问题讨论】:

    标签: html css button position cursor


    【解决方案1】:

    默认情况下,否定的z-index 将按钮放在页面其余部分的后面,因此该按钮不可用。

    试试这个:

    .login input[type="submit"] {
      background: #2196f3;
      border-radius: 5px;
      border: 1px solid #0d47a1;
      color: #FFF;
      cursor: pointer;
      font-weight: bold;
      line-height: 48px;
      margin-top: 20px;
      position: relative;
      text-align: center;
      text-transform: uppercase;
      width: 242px;
    }
    <div class="login">
      <input type="submit" />
    </div>

    如果您需要 z-index 是因为您希望它位于页面上的其他内容后面,请尝试增加这些元素的 z-index。如果您需要将其设为禁用按钮,请尝试在按钮的 HTML 中添加disabled="disabled"

    【讨论】:

    • 哦,所以它不起作用的原因是 z-index 而不是位置?这就解释了为什么我将位置改回它再次起作用,我的意思是 z-index 在默认位置上不起作用。然后我会将 z-index 添加到其他元素中,谢谢。
    【解决方案2】:

    我认为这是因为你给input[type="submit"] 一个z-index: -1;

    也许z-index: 0; 对你有用。

    【讨论】:

      猜你喜欢
      • 2023-01-31
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-29
      • 2021-10-21
      • 1970-01-01
      • 2023-04-03
      相关资源
      最近更新 更多