how to change input text box style to line?

前端 未结 6 1520
醉酒成梦
醉酒成梦 2021-02-03 10:48

in my form I have three input fields name, email, mobile but I want to change input text box like -

name :  _____________  
email:  _____________  
mob  :  ___         


        
6条回答
  •  悲&欢浪女
    2021-02-03 11:32

    You can style an input box however you want. Check the Codepen where I have styled an input box only with css.

    Style an INPUT box with only CSS

    HTML -

    CSS -

    .input__box{
        width:800px;
        height: 200px;
        margin:0 auto;
        background-color: #f2f2f2;
        display: grid;
        place-items:center;
        position: relative;
    }
    
    .input__box  input{
        all:unset;
        width:600px;
        height:60px;
        border:1px solid grey;
        padding-left:55px;
        font-size:18px;
        color:#333;
        font-family:sans-serif;
        position:relative;
    }
    
    input:focus{
        outline:1px solid royalblue;
        border:none;
    }
    
    input[type="text"]::-webkit-input-placeholder { /* Chrome/Opera/Safari */
        font-size:18px;
        color:dimgrey;
        font-family:sans-serif;
    }
    
    input[type="text"]::-moz-placeholder{ /* Firefox 19+ */
        font-size:18px;
        color:dimgrey;
        font-family:sans-serif;
    }
    
    input[type="text"]:-moz-placeholder{ /* Firefox 18- */
        font-size:18px;
        color:dimgrey;
        font-family:sans-serif;
    }
    
    input[type="text"]:-ms-input-placeholder{ /* IE 10+ */
        font-size:18px;
        color:dimgrey;
        font-family:sans-serif;
    }
    
    input[type="text"]::placeholder { 
        font-size:18px;
        color:dimgrey;
        font-family:sans-serif;
    }
    
    .input__box::before{
        content: "☎";
        position: absolute;
        left: calc(50% - 327px);
        top:calc(50% - 30px);
        color: #333;
        font-weight: bold;
        font-size:40px;
        padding:0 10px;
    }
    

    .input__box {
      width: 800px;
      height: 200px;
      margin: 0 auto;
      background-color: #f2f2f2;
      display: grid;
      place-items: center;
      position: relative;
    }
    
    .input__box input {
      all: unset;
      width: 600px;
      height: 60px;
      border: 1px solid grey;
      padding-left: 55px;
      font-size: 18px;
      color: #333;
      font-family: sans-serif;
      position: relative;
    }
    
    input:focus {
      outline: 1px solid royalblue;
      border: none;
    }
    
    input[type="text"]::-webkit-input-placeholder {
      /* Chrome/Opera/Safari */
      font-size: 18px;
      color: dimgrey;
      font-family: sans-serif;
    }
    
    input[type="text"]::-moz-placeholder {
      /* Firefox 19+ */
      font-size: 18px;
      color: dimgrey;
      font-family: sans-serif;
    }
    
    input[type="text"]:-moz-placeholder {
      /* Firefox 18- */
      font-size: 18px;
      color: dimgrey;
      font-family: sans-serif;
    }
    
    input[type="text"]:-ms-input-placeholder {
      /* IE 10+ */
      font-size: 18px;
      color: dimgrey;
      font-family: sans-serif;
    }
    
    input[type="text"]::placeholder {
      font-size: 18px;
      color: dimgrey;
      font-family: sans-serif;
    }
    
    .input__box::before {
      content: "☎";
      position: absolute;
      left: calc(50% - 327px);
      top: calc(50% - 30px);
      color: #333;
      font-weight: bold;
      font-size: 40px;
      padding: 0 10px;
    }

提交回复
热议问题