欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
默认情况下,<input>字段和的占位符文本<textarea>以浅灰色显示,并且没有标准的CSS属性可为其设置样式。但是,浏览器提供了一些非标准的供应商特定的伪元素和伪类,可用于自定义占位符文本的外观,如以下示例所示:
 
例试试这个代码»
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Styling Placeholder Text with CSS</title>
<style>
    ::-webkit-input-placeholder {
       color: orange;
    }
    :-moz-placeholder { /* Upto Firefox 18, Deprecated in Firefox 19  */
       color: orange;  
    }
    ::-moz-placeholder {  /* Firefox 19+ */
       color: orange;  
    }
    :-ms-input-placeholder {  
       color: orange;  
    }
</style>
</head>
<body>
    <form>
        <p><input type="text" placeholder="Please Enter your Name"><p>
        <p><textarea placeholder="Please Enter your Comment" cols="30"></textarea><p>
    </form>
</body>
</html>

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h61102.shtml