我想在下面的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作为字体,方法是将CSSfont-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 - Font Awesome 和文本都在占位符中,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30834021/

10-12 07:00