Front-end website realizes sidebar function

renderings

       insert image description here

Ideas:

        The main thing is to put a ul on the left side of a sidebar box as the li in the sidebar as the content of each line, then position the sidebar-mask box to the right side of the sidebar, hide the box first with display:none, and then After that, when hovering the box, display: block, and then make a transition effect padding value for each line of the sidebar, and the padding value will be stretched.

The source 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">
    <title>侧边栏</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .sidebar {
            /* 子绝父相 */
            position: relative;
            width: 1200px;
            height: 700px;
            margin: 50px auto;
            color: #ffffff;
        }

        .sidebar ul {
            width: 200px;
            height: 100%;
            background-color: rgba(0, 0, 0, .3);
        }

        .sidebar ul li {
            list-style: none;
            height: 50px;
            padding: 10px 0;
            transition: all .5s;
        }

        .sidebar ul li p {
            float: left;
            margin-left: 50px;
        }

        .sidebar ul li span {
            float: right;
            margin-right: 20px;
        }

        .sidebar ul li:hover {
            background-color: orange;
            padding-left: 20px;
            cursor: pointer;
        }

        .sidebar ul li:hover .sidebar-mask {
            display: block;
        }

        .sidebar-mask {
            display: none;
            position: absolute;
            top: 50px;
            right: 50px;
            width: 900px;
            height: 600px;
            background-color: rgba(0, 0, 0, .3);
            text-align: center;
        }

    </style>
</head>

<body>
<div class="sidebar">
    <ul>
        <li>
            <h4 style="text-align: center;">侧边栏</h4>
        </li>
        <li>
            <p>第一</p>
            <span>></span>
            <div class="sidebar-mask">我是第一个</div>
        </li>
        <li>
            <p>第二</p>
            <span>></span>
            <div class="sidebar-mask">我是第二个</div>
        </li>
        <li>
            <p>第三</p>
            <span>></span>
            <div class="sidebar-mask">我是第三个</div>
        </li>
        <li>
            <p>第四</p>
            <span>></span>
            <div class="sidebar-mask">我是第四个</div>
        </li>
        <li>
            <p>第五</p>
            <span>></span>
            <div class="sidebar-mask">我是第五个</div>
        </li>
        <li>
            <p>第六</p>
            <span>></span>
            <div class="sidebar-mask">我是第六个</div>
        </li>
        <li>
            <p>第七</p>
            <span>></span>
            <div class="sidebar-mask">我是第七个</div>
        </li>
        <li>
            <p>第八</p>
            <span>></span>
            <div class="sidebar-mask">我是第八个</div>
        </li>
        <li>
            <p>第九</p>
            <span>></span>
            <div class="sidebar-mask">我是第九个</div>
        </li>
    </ul>
</div>
</body>

</html>

Guess you like

Origin blog.csdn.net/weixin_40845165/article/details/124532341