Css实现文字的高亮

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .text {
            display: inline-block;
            cursor: pointer;
            font-size: 28px;
            padding: 40px 60px;
            border: 1px solid red;
        }
        .text:focus {
            color: aqua;
        }
    </style>
</head>
<body>
    <div id="box">
        <div class="text" tabIndex="1">1</div>
        <div class="text" tabIndex="1">2</div>
        <div class="text" tabIndex="1">3</div>
        <div class="text" tabIndex="1">4</div>
        <div class="text" tabIndex="1">5</div>
        <div class="text" tabIndex="1">6</div>
        <div class="text" tabIndex="1">7</div>
    </div>
</body>
</html>

Css实现文字的高亮_第1张图片

tips:通过给元素添加 accesskey、tabindex 属性为元素添加快捷键及键盘焦点顺序

你可能感兴趣的:(Html+Css,css,前端)