hide placeholder with css

后端 未结 6 1068
感动是毒
感动是毒 2020-12-13 18:14

I\'m working with a responsive theme. And I\'m facing the input form problem here. In the desktop view, the input will not have placeholder but have label.

However,

6条回答
  •  一向
    一向 (楼主)
    2020-12-13 18:39

    You can use media queries and hide and show based on required resolution:

    /* Smartphones (portrait and landscape) ----------- */
    @media only screen
    and (min-device-width : 320px)
    and (max-device-width : 480px) {
          ::-webkit-input-placeholder {
             color: lightgray !important; 
          }
          :-moz-placeholder { /* Firefox 18- */
             color: lightgray !important;  
          }
    
          ::-moz-placeholder {  /* Firefox 19+ */
             color: lightgray !important;  
          }
    
          :-ms-input-placeholder {  
             color: lightgray !important;  
          }
          #labelID
          {
             display:none !important;
          }
    }
    

    Normal Styles

    ::-webkit-input-placeholder {
             color: transparent;
    }
    :-moz-placeholder { /* Firefox 18- */
             color: transparent;
    }
    
    ::-moz-placeholder {  /* Firefox 19+ */
             color: transparent;
    }
    
    :-ms-input-placeholder {  
             color: transparent;
    }
    
    #labelID{
            display:block;
    }
    

提交回复
热议问题