美文网首页
十三、案例:简单的小米侧边栏

十三、案例:简单的小米侧边栏

作者: honest涛 | 来源:发表于2021-02-14 08:07 被阅读0次

案例:简洁版小米侧边栏

案例的核心思路分为两步:

  • 把链接a转换为块级元素,这样链接就可以独占一行,并且有宽度和高度。
  • 鼠标经过a给链接设置背景颜色。
    效果图
    简洁版小米侧边栏.png
<!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>简单版小米侧边栏</title>
    <style>
        /* 1. 把a转换为块级元素 */
        a {
            display: block;
            width: 230px;
            height: 40px;
            background-color: #55585a;
            font-size: 14px;
            color: #fff;
            text-decoration: none;
            text-indent: 2em;
            line-height: 40px;
        }

        /* 2 鼠标经过链接变换背景颜色 */
        a:hover {
            background-color: #ff6700;
        }
    </style>
</head>
<body>
    <div>
        <a href="#">手机 电话卡</a>
        <a href="#">电视 盒子</a>
        <a href="#">笔记本 平板</a>
        <a href="#">出行 穿戴</a>
        <a href="#">智能 路由器</a>
        <a href="#">健康 儿童</a>
        <a href="#">耳机 音响</a>
    </div>
</body>
</html>

相关文章

网友评论

      本文标题:十三、案例:简单的小米侧边栏

      本文链接:https://www.haomeiwen.com/subject/yqfyxltx.html