html - 占位符中的字体和文本都很棒

标签 html css font-awesome placeholder

我想在下面的HTML代码中同时添加awesome字体和占位符中的文本,我想了解详细过程:

  <!DOCTYPE html>
<html>
<head>
    <title>Student-login</title>
    <link href='http://fonts.googleapis.com/css?family=Shadows+Into+Light' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="main.css">
    <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
</head>
<body>
    <div class="body"></div>
        <div class="main-form">
            <h1>Student Login</h1>
            <form class="login">
                <input type="text" placeholder="*User name" name="username"></input><br>
                <input type="password" placeholder="*Password" name="password"></input><br>
                <input type="text" placeholder="*First name" name="first_name"></input><br>
                <input type="text" placeholder="*Last name" name="last_name"></input><br>
                <select name="gender">
                    <option value="">Select</option>
                    <option value="male">Male</option>
                    <option value="female">Female</option>
                </select><br>
                <input type="text" placeholder="*E-mail" name="email"></input><br>
                <input type="text" placeholder="*Phone number" name="phone"></input><br>
                <div class="button"><a href="index.html">Login</a></div>
                <div class="button"><a href="#">Submit</a></div>

            </form>
        </div>
</body>
</html>

最佳答案

要实现此目的,请使用 FontAwesome 作为字体,方法是将 CSS font-family 设置为 FontAwesome 并使用 FontAwesome Unicode reference 引用您想要的图标。 .

例如,要让 fa-envelope 出现在占位符中,您可以使用以下命令:

<style type="text/css">
    input {font-family:FontAwesome;}
</style>

<!-- use &#xf0e0; which is the code for fa-envelope -->
<input type="text" placeholder="&#xf0e0; E-mail" name="email" />

关于html - 占位符中的字体和文本都很棒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30834021/

相关文章:

html - 使用 CSS3 检查方 block 的匹配游戏

css - Font-Awesome ExtJS ActionColumn

javascript - HTML/CSS/JS 中未捕获的类型错误

jquery - 使用 MDL 主题更新 jquery 数据表布局

html - 带边框的 Angular div

jquery - 如何更改除侧边栏div之外的整个主体的背景颜色

html - 在输入组内选择的顶部显示跨度

html - 悬停在我的导航菜单中不起作用

php - 如何在出现 PHP Echo 错误时更改 fa 图标的颜色?

internet-explorer - font-awesome 在 IE 11 中不起作用,如果从 IE 安全选项中禁用字体下载