英文:
How do you apply a custom font family for placeholder, textbox & button?
问题
我想在占位符和按钮中使用我电脑上的自定义字体。
我的 @font-face。
@font-face {
font-family: customfont2;
src: url(Font/otf/segment14.regular.otf);
}
我正在做一个十进制/二进制/十六进制转换器。
<div id="decimal">
<input placeholder="在此输入十进制">
<button>转换为十进制</button>
</div>
英文:
I want to use a custom font from my computer for placeholder and button.
My @font-face.
@font-face {
font-family: customfont2;
src: url(Font/otf/segment14.regular.otf);
}
I was doing a Dec/Bin/Hex converter
<div id="decimal">
<input placeholder="Type Decimal Here">
<button>Convert Decimal</button>
</div>
答案1
得分: 0
For button, you just need something like:
button{
font-family: customfont2;
}
For placeholders, you can try the selectors below:
::-webkit-input-placeholder { /* Edge */
font-family: customfont2;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
font-family: customfont2;
}
::placeholder {
font-family: customfont2;
}
更多关于 ::placeholder 选择器的信息
英文:
For button, you just need something like:
button{
font-family: customfont2;
}
For placeholders, you can try the selectors below:
::-webkit-input-placeholder { /* Edge */
font-family: customfont2;
}
:-ms-input-placeholder { /* Internet Explorer 10-11 */
font-family: customfont2;
}
::placeholder {
font-family: customfont2;
}
More about the ::placeholder selector
答案2
得分: 0
使用 input::placeholder
伪元素来样式化输入元素的占位符
@font-face {
font-family: 'mycustomfont';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v20/pxiEyp8kv8JHgFVrJJbecmNE.woff2);
}
input, button {
font-family: 'mycustomfont';
}
input::placeholder {
font-family: 'mycustomfont';
color: green;
}
<div id="decimal">
<input placeholder="输入十进制数">
<button>转换为十进制</button>
</div>
英文:
use input::placeholder
pseudo element to style placeholder of input element
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
@font-face {
font-family: 'mycustomfont';
font-style: normal;
font-weight: 400;
font-display: swap;
src: url(https://fonts.gstatic.com/s/poppins/v20/pxiEyp8kv8JHgFVrJJbecmNE.woff2);
}
input,button{
font-family:'mycustomfont';
}
input::placeholder{
font-family:'mycustomfont';
color:green;
}
<!-- language: lang-html -->
<div id="decimal">
<input placeholder="Type Decimal Here">
<button>Convert Decimal</button>
</div>
<!-- end snippet -->
答案3
得分: 0
谢谢各位,但我自己已经搞定了
input[type="text"] {
font-family: customfont4;
background-color: rgb(0, 0, 0);
color: rgb(255, 0, 0);
}
input[type="button"] {
font-family: customfont3;
}
button {
font-family: customfont3;
height: 28px;
font-size: 12pt;
}
::placeholder {
font-family: customfont2;
color: rgb(255, 0, 0);
}
英文:
Thanks guys, but I figured on my own
input[type="text"]
{
font-family: customfont4;
background-color: rgb(0, 0, 0);
color: rgb(255, 0, 0);
}
input[type="button"]
{
font-family: customfont3;
}
button {
font-family: customfont3;
height:28px;
font-size:12pt;
}
::placeholder {
font-family: customfont2;
color: rgb(255, 0, 0);
{
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论