簡體   English   中英

如何在 HTML-CSS 的輸入框中更改文本的字體顏色(由用戶提供)?

[英]How to change font color of the text(Given by the user) in input-box in HTML-CSS?

HTML 代碼:-

<p><input type="text" placeholder="Username"></p>

CSS 代碼:-

.main-header input
{
    width: 90%;
    padding: 1rem;
    margin: 20px 0px;
    border: none;
    border-bottom: 4px solid #5f5fb0;
    font-size: 1.3rem;
    background: transparent;
    outline: none;
}
::-webkit-input-placeholder
{
    color: #fff;
}

我想將用戶在網頁input框中輸入的文本的顏色更改為#fff(white)。 在這個項目中,我使用的是 HTML 和 CSS。 我已經嘗試了很多,但我無法使顏色變白。

請幫我解決這個問題。

我想你是這個意思。
您可以將其更改為.main-header input

 input[type="text"] { width: 90%; padding: 1rem; margin: 20px 0px; border: none; border-bottom: 4px solid #5f5fb0; font-size: 1.3rem; background: black; outline: none; color: white; }::-webkit-input-placeholder { color: #fff; }
 <p><input type="text" placeholder="Username"></p>

只需將顏色賦予input標簽的選擇器本身的color屬性

 input { color: white; background-color: black; }
 <input type="text">

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM