Html Put a fixed text on an input text

后端 未结 7 1346
梦毁少年i
梦毁少年i 2020-12-11 04:21

How can i put a default text in an input html element which user can\'t delete (fixed text on start of the input).

The second thing what i want that the cursor will b

7条回答
  •  隐瞒了意图╮
    2020-12-11 04:37

    I know this question is already answered, but here is another way to do it.

    I tested this code with..

    Firefox 22
    Google Chrome 28
    Internet Explorer 10
    Safari 5
    Opera 15
    

    #text_container {
      padding: 1px;
      /*To make sure that the input and the label will not overlap the border, If you remove this line it will not display correctly on Opera 15.0*/
      border: 1px solid activeborder;
      /*Create our fake border :D*/
    }
    
    #text_container>label {
      color: activeborder;
      background-color: white;
      -webkit-touch-callout: none;
      /*Make the label text unselectable*/
      -webkit-user-select: none;
      -khtml-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
    }
    
    #text_container>input {
      border: none;
      /*We have our fake border already :D*/
    }
    
    		
    		
    	    

提交回复
热议问题