相关疑难解决方法(0)

使用CSS更改HTML5输入的占位符颜色

Chrome支持占位符属性input[type=text]元素(别人可能做太多).

但以下CSS内容对占位符的值没有任何作用:

input[placeholder], [placeholder], *[placeholder] {
    color: red !important;
}
Run Code Online (Sandbox Code Playgroud)
<input type="text" placeholder="Value">
Run Code Online (Sandbox Code Playgroud)

Value仍然会留下grey而不是red.

有没有办法改变占位符文本的颜色?

html css html5 placeholder html-input

3876
推荐指数
29
解决办法
171万
查看次数

如果需要,CSS 输入效果不起作用,已删除

如果输入标签中有需要,标签效果将起作用。但如果我删除所需的属性,效果将不起作用单击查看工作小提琴 是否有任何解决方案。

html

<div class="group ">
<input type="text" required="" class="module-input" />
<label >Name</label>
</div>
Run Code Online (Sandbox Code Playgroud)

片段:

<div class="group ">
<input type="text" required="" class="module-input" />
<label >Name</label>
</div>
Run Code Online (Sandbox Code Playgroud)
.module-input {
  font-size: 14px;
  padding-top: 12px;
  display: block;
  width: 97%;
  border: none;
  border-bottom: 1px solid #94a3a9;
  background-color: transparent;
  color: #5a686d;
  margin-bottom: 2%;
}

input:focus {
  outline: none;
}

.group {
  position: relative;
  margin-bottom: 25px;
}


/* LABEL */

label {
  color: #94a3a9;
  font-size: 14px;
  font-weight: normal;
  position: absolute;
  pointer-events: none;
  left: 0.5%;
  top: …
Run Code Online (Sandbox Code Playgroud)

html css

4
推荐指数
1
解决办法
2158
查看次数

输入长度大于0不能正常工作

我正在尝试编写一些代码,如果输入为空,则输入颜色变为红色。用户键入输入后,红色将被删除。

HTML

<html>
<head>
    <!-- add main style -->
    <link rel="stylesheet" href="../css/style.css">
    <!-- add JQuery -->
    <script
        src="https://code.jquery.com/jquery-3.3.1.js"
        integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
        crossorigin="anonymous"></script>
</head>
<body>
<div class="financeContainer">
    <div class="searchBox">
        <input id="financeSearch" type="text" class="financeInput" placeholder="Enter The Code">
        <button id="financeBtn" class="financeSearchBt"><i class="fas fa-search financeSearchIcon"></i></button>
    </div>
</div>
<script>

</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

的CSS

.redColor{
    color: red;
}
Run Code Online (Sandbox Code Playgroud)

jQuery的

$(document).ready(function () {
    $("#financeSearch").keydown(function () {
        if ($("#financeSearch").val().length>0){
            $("#financeSearch").removeClass("redColor")
        }
    });
    $(document).bind('keypress', function(e) {
        if(e.keyCode==13){
            $('#financeBtn').trigger('click');
        }
    });
    $("#financeBtn").click(function () {
        var financeKey = $("#financeSearch").val();
        if (financeKey == ""){ …
Run Code Online (Sandbox Code Playgroud)

html javascript css jquery

4
推荐指数
1
解决办法
76
查看次数

标签 统计

css ×3

html ×3

html-input ×1

html5 ×1

javascript ×1

jquery ×1

placeholder ×1