Fontawesome changes font size and color

Why does it not work to directly set the font size and color of I? the code is as follows

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css" rel="stylesheet">
    <title>Document</title>
    <style>
        .container {
            text-align: center;
            padding-top: 10%;
        }
        i {
            font-size: "50px";
            color: "-sharp10AEFF";
            margin-bottom: "10%"
        }
        .txt {
            font-size: 120%;
            margin-top:10%;
        }
    </style>
</head>

<body>

    <div class="container">
        <i class="fa fa-exclamation-circle fa-5x"></i>
        <div class="txt"></div>
    </div>
    <script>
        var ua = window.navigator.userAgent.toLowerCase();
        if (!!(ua.indexOf("micromessenger") != -1)) {//

        } else {

        }
    </script>
</body>

</html>

element as shown in figure

Mar.02,2021

The

element selector I has a lower priority than the class selector .fa , so the css in your I will be overridden by the default .fa . Besides, don't use quotation marks in css.

i.fa {
    font-size: 50px;
    color: -sharp10AEFF;
    margin-bottom: 10%;
}

remove the single quotation marks from the value of the I tag attribute.

Menu