gpt4 book ai didi

javascript - 使 html 文本字段中的占位符文本闪烁

转载 作者:太空宇宙 更新时间:2023-11-04 14:15:40 25 4
gpt4 key购买 nike

在问这个问题之前,我搜索了很多这个功能,但没有找到任何线索,所以这就是为什么要发布一个新问题。

所以实际上我在这样的 html 文本字段中有一个占位符文本

A input field with placeholder text

<input type="text" class="timepicker" placeholder="Placeholder Text..." >

所以我想要的是让这个占位符闪烁。那么是否可以在 html 中或使用 jquery 或 javascript。

最佳答案

您可以使用简单的 CSS 动画来做到这一点。不确定,但这是多少跨浏览器兼容。适用于 Chrome 和 Firefox。

HTML:

<input type="text" placeholder="Enter Text Here" class="textbox">

CSS:

input[class="textbox"]::-webkit-input-placeholder {
color:blue;
-webkit-animation-name: blinker;
-webkit-animation-duration: 1s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
}

input[class="textbox"]::-moz-placeholder {
color:blue;
-moz-animation-name: blinker;
-moz-animation-duration: 1s;
-moz-animation-timing-function: linear;
-moz-animation-iteration-count: infinite;
}

@-moz-keyframes blinker {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}

@-webkit-keyframes blinker {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}

@keyframes blinker {
0% { opacity: 1.0; }
50% { opacity: 0.0; }
100% { opacity: 1.0; }
}

fiddle :http://jsfiddle.net/rkwa19se/6/

关于javascript - 使 html 文本字段中的占位符文本闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27638468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com