css设置placeholder的样式,placeholder的样式

http://www.itjxue.com  2023-01-06 17:17  来源:未知  点击次数: 

css样式问题:placeholder

placeholder是无法设置颜色的,那两个颜色不同是浏览器不同而已,就跟你那两个图片的字体也不同一样

如何设置css3中placeholder的字体颜色

你好,目前没有统一的设置方法,不过各自私有的设置方法:

//?webkit

input::-webkit-input-placeholder?{

??color:?#f00;

}

//?moz

input::-moz-placeholder?{

??color:?#f00;

}

你甚至可以使用placeholder的:after伪元素实现placeholder换行:

textarea::-webkit-input-placeholder:after{

??display:block;

??content:"line@?\A?line#";?/*??\A?表示换行??*/

??color:red;

}

textarea::-moz-placeholder:after{

??content:"line@?\A?line#";?/*??\A?表示换行??*/

??color:red;

}

这应该是你想要的答案,望采纳~~

如何修改input中的placeholder中的默认样式

!doctype html

html

head

meta charset="utf-8"

titlemy_web_task1/title

script src="Web_task1.js" type="text/javascript"

/script

link type="text/css"? rel="stylesheet" href="Web_task1.css"

/head

body

??? !--设置文本框默认字体,点击文本框默认字体消失,这样的功能可以有几种方法实现,各种方法都存在优点缺点,至于如何完善就看你的了--

??? !--第一种:使用placeholder属性--写得比较完善的了

??? !--input type="text"? name="username" style="color:#999;" size="18" placeholder="QQ号码/手机/邮箱" onFocus="this.style='color:#FOO';"--

!--第二种:利用onfocus属性写脚本--不足:如果设置点击文本框之后将文本框类型设置为password,则‘密码’二字(默认字体)将会替换为两个黑点

???? input type="text"? name="username" style="color:#999;"? size="18" value="QQ号码/手机/邮箱"? onFocus="javascript:if(this.value='QQ号码/手机/邮箱')this.value='';this.style='color:#FOO' "

?????

????? !--第三种利用onblur和onfocus属性--

??? input type="text" name="username"? size="18" value="QQ/Phone" style="color:#999;"? onfocus="if(this.value=='QQ/Phone'){this.value='';this.style='color:#000;'}"? onblur="if(this.value.length1)this.value='QQ/Phone';this.style='color:#999;'" /

???? input placeholder="QQ/Phone"

/body

/html

//placeholder的默认样式好像不能改的吧??当然利用onFocus和onBlur同样可以实现默认字体而且还可以自己设置默认样式,当然啦,如果输密码框还是要用到placeholder属性才行

html 如何 设置 input 标签里的 placeholder 颜色 字体之类的

这个需要给input设置一些css样式就行了啊,比如color="red"设置颜色为红色

(责任编辑:IT教学网)

更多

推荐mac苹果系统文章