Css实现文字的高亮

javascript 复制代码
<!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>

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

相关推荐
漂流瓶jz1 小时前
快速定位源码问题:SourceMap的生成/使用/文件格式与历史
前端·javascript·前端工程化
samroom1 小时前
iframe实战:跨域通信与安全隔离
前端·安全
fury_1231 小时前
vue3:数组的.includes方法怎么使用
前端·javascript·vue.js
weixin_405023371 小时前
包资源管理器NPM 使用
前端·npm·node.js
宁&沉沦1 小时前
Cursor 科技感的登录页面提示词
前端·javascript·vue.js
Dragonir2 小时前
React+Three.js 实现 Apple 2025 热成像 logo
前端·javascript·html·three.js·页面特效
peachSoda72 小时前
封装一个不同跳转方式的通用方法(跳转外部链接,跳转其他小程序,跳转半屏小程序)
前端·javascript·微信小程序·小程序
@PHARAOH3 小时前
HOW - 浏览器兼容(含 Safari)
前端·safari
undefined在掘金390413 小时前
flutter 仿商场_首页
前端