【问题标题】:Border not visible边框不可见
【发布时间】:2022-01-11 03:39:33
【问题描述】:

为什么输入框下面看不到边框?

此外,按钮越过边框,边框对于它旁边的按钮是连续的,但对于输入字段不是。

我的 CSS

input,
button {
  display: block;
  position: relative;
  width: 300px;
  margin: auto;
  cursor: pointer;
  border: 0;
  height: 60px;
  outline: 0;
}
input {
  border-radius: 10px 0 0 10px;
}
button {
  width: 100px;
}
input:after {
  border-radius: 10px 0 0 10px;
}
input:after,
button:after {
  transition: 200ms all ease;
  background-color: #fcfcfc;
  border: 1px solid #afafaf;
  line-height: 60px;
  color: #252525;
  font-size: 1.5em;
  text-align: center;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: inline-block;
  content: "Select package.json";
}
button:after {
  content: "Upload";
  border-radius: 0px 10px 10px 0;
}
input:hover:after,
button:hover:after {
  background-color: #f1f1f1;
}

【问题讨论】:

  • 您能否添加 html 并检查给定的 scss,因为我没有得到与您相同的输出。您已将标签指定为 sass,但它应该是 scss。
  • 注意输入元素不能附加伪元素。

标签: css sass styles


【解决方案1】:

我对@9​​87654321@做了一些小调整,并为input添加了一些边框属性。

input,
    button {
        display: inline-flex;
        position: relative;
        width: 300px;
        margin: auto;
        cursor: pointer;
        height: 60px;
        outline: 0;
        line-height: 60px;
        font-size: 1.5em;
        border: 0;
        padding: 0;
    }
    input {
        border-radius: 10px 0 0 10px;
        border-top: 1px solid #afafaf;
        border-right: 0;
        border-bottom: 1px solid #afafaf;
        border-left: 1px solid #afafaf;
        padding: 0 0 0 12px;
        
    }
    button {
        width: 100px;
    }
    input:after {
        border-radius: 10px 0 0 10px;
    }
    input:after,
    button:after {
        transition: 200ms all ease;
        background-color: #fcfcfc;
        border: 1px solid #afafaf;
        color: #252525;
        text-align: center;
        width: 100%;
        height: 100%;
        display: inline-block;
        content: 'Select package.json';
    }
    button:after {
        content: 'Upload';
        border-radius: 0px 10px 10px 0;
    }
    input:hover:after,
    button:hover:after {
        background-color: #f1f1f1;
    }
<input/><button></button>

【讨论】:

  • 请添加对您所做操作的解释,而不仅仅是代码。
  • 在这种情况下几乎没有任何改变
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多