如何在HTML和CSS中修改搜索栏的字体家族和边框颜色?

huangapple go评论79阅读模式
英文:

How do I modify the font family and border color of my search bar in HTML and CSS?

问题

以下是您要翻译的内容:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->
.searchInput::-webkit-input-placeholder {
  font-family: FontAwesome;
  font-weight: normal;
  overflow: visible;
  vertical-align: top;
  display: inline-block !important;
  padding-left: 2%;
  padding-top: 1%;
  color: #9D9494;
}
.searchInput {
  border: 1px solid white;
  border-radius: 5px;
  width: 39%;
  height: 5%;
  padding: 0px;
  font-size: 20px;
  margin-left: 60%;
  margin-top: 2%;
  margin-bottom: 5%;
}

<!-- language: lang-html -->
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet"/>
<input class="searchInput" type="text" placeholder=" &#61442; search " /><br />

<!-- end snippet -->

请注意,这是您提供的HTML和CSS代码,已经按原样呈现出来。如果您需要任何翻译或进一步的帮助,请随时提问。

英文:

hello i need to make a serach bar it works for me but i have some modification to do what i aim to do is when i click on the bar search i want to change the color of border from black to blue .. besides how can i change the font family of the word search !

this my html and css code thanks in advice !

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

.searchInput::-webkit-input-placeholder {
  font-family: FontAwesome;
  font-weight: normal;
  overflow: visible;
  vertical-align: top;
  display: inline-block !important;
  padding-left: 2%;
  padding-top: 1%;
  color: #9D9494;
}
.searchInput {
  border: 1px solid white;
  border-radius: 5px;
  width: 39%;
  height: 5%;
  padding: 0px;
  font-size: 20px;
  margin-left: 60%;
  margin-top: 2%;
  margin-bottom: 5%;
}

<!-- language: lang-html -->

&lt;link href=&quot;https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css&quot; rel=&quot;stylesheet&quot;/&gt;
&lt;input class=&quot;searchInput&quot; type=&quot;text&quot; placeholder=&quot; &amp;#61442; search &quot; /&gt; &lt;br /&gt;

<!-- end snippet -->

答案1

得分: 1

可以使用:focus选择器来在点击搜索栏时更改边框颜色。如果你想要更改占位符字体系列,可以使用:placeholder选择器。

例如:

.searchInput:focus {
    border-color: blue;
}

.searchInput:placeholder {
    font-family: "Open-sans";
}
英文:

You can use the :focus selector to change the border color when you click on the search bar. If you want to change the placeholder font family, you can use the :placeholder selector.

for eg:

 .searchInput:focus {
     border-color: blue;
 }

.searchInput:placeholder{
     font-family: &quot;Open-sans&quot;;
 }

huangapple
  • 本文由 发表于 2023年5月26日 16:26:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/76339007.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定