提问者:小点点

未正确应用输入样式


我设计了一个输入,我希望输入看起来是这样的:https://codepen.io/yaniva5/pen/mwjqgod

但是当我移到输入所需时,它看起来是这样的:https://codepen.io/yaniva5/pen/balyxdx

页面启动时应用

HTML

<div class="inputContainer">
        <input type="text" id="firstName" required>
        <span class="highlight"></span>
        <span class="bar"></span>
        <label for="">שם פרטי</label>
        <small>הבעיה תופיעה כאן</small>
    </div>

造型

.inputContainer{
    position: relative;
    width: 200px;
    margin: 45px 0;
}


.inputContainer input{
    background: none;
    color: rgb(0, 0, 0);
    font-size: 18px;
    padding: 10px 10px 10px 5px;
    display: block;
    width: 100%;
    text-align: right;
    border: none;
    border-radius: 0;
    border-bottom: 1px solid  rgb(218, 218, 218);
}
.inputContainer input:focus {
    outline: none;
  }

  .inputContainer input:focus ~ label,
  .inputContainer input:valid ~ label {
    top: -14px;
    font-size: 12px;
    color:  rgb(37, 129, 235);
  }

  .inputContainer input:focus ~ .bar:before, input:valid ~ .bar:before{
    width: 200px; transition: 0.4s; left: 0;
  }

  .inputContainer label{
    color: rgb(0, 0, 0);
    font-size: 16px;
    font-weight: normal;
    position: absolute;
    pointer-events: none;
    right: 5px;
    top: 10px;
    transition: 0.2s ease all;
  }

  .inputContainer .bar {
    position: relative;
    display: block;
    width: fit-content;
}

.inputContainer .bar::before{
    content: '';
    height: 2px;
    width: 0;
    bottom: 0px;
    position: absolute;
    background: rgb(37, 129, 235);
    transition: 0.3s ease all;
    position: absolute; bottom: 0; 
    left: 100px; 
    width: 0; 
    height: 2px; 
    transition: 0.4s;
    
}

small{
    color: rgb(243, 11, 11);
    width: 200px;
    margin-right: 5px;
    float: right;
    text-align: right;
}

共1个答案

匿名用户

在代码的html中,你有所需的资源,但是在代码的html中,你没有。它可以在没有所需的配料的情况下工作。

差异检查器的图像