内容部分位于侧边栏之下

2022-01-28 04:51:57 标签 htmlcsspositioncss-positionsidebar

我有一个侧边栏菜单,但我把它叫做position:fixed;内容部分没有将侧边栏视为障碍,而是进入了侧边栏。我该如何解决这个问题?

aside{
    position: fixed;
    top: 0;
    left: 0;
    width: 200px;
    display: flex;
    justify-content: center;
    flex-direction: column;
    padding: 1rem;
    z-index: 1000;
    background-color: #f9f9f9;}
aside .logo{
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    margin-bottom: 2rem;
}
aside .logo img{
    width: 150px;
    height: auto;
    object-fit: cover;
}
aside .logo h1{
    font-size: 1.5em;
    font-weight: 500;
}
aside .menu-one{
    display: flex;
    flex-direction: column;
}
aside .menu-one h4{
    font-size: 1.3em;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.8);
}
aside .menu-two{
    display: flex;
    flex-direction: column;
}
aside .menu-two h4{
    font-size: 1.3em;
    font-weight: 500;
    color: rgba(0, 0, 0, 0.8);
}
aside .menu-one ul{
    display: flex;
    flex-direction: column;
    margin-bottom: 2.5rem;
}
aside .menu-one ul li{
    margin-left: 1rem;
    list-style-type: none;
    margin-top: 20px;
}
aside .menu-one ul li a{
    font-size: 1.1em;
    transition: 200ms all;
    color: rgba(0, 0, 0, 0.7);
}
aside .menu-two ul li a{
    transition: 200ms all;
    font-size: 1.1em;
    color: rgba(0, 0, 0, 0.7);
}
aside .menu-one ul li a:hover{
    color: rgba(0, 0, 0, 1.0);
}
aside .menu-two ul li a:hover{
    color: rgba(0, 0, 0, 1.0);
}
aside .menu-two ul li a i{
    font-weight: 500;
    width: 30px;
    font-size: 1.2em;
    height: 30px;
}
aside .menu-one ul li a i{
    font-weight: 500;
    width: 30px;
    font-size: 1.2em;
    height: 30px;
}
aside .menu-two ul{
    display: flex;
    align-items: flex-start;
    flex-direction: column;
}
aside .menu-two ul li{
    margin-left: 1rem;
    list-style-type: none;
    margin-top: 20px;
}
.cizgi{
    width: 80px;
    height: 2px;
    background-color: rgba(0, 0, 0, 0.2);
}
<aside>
            <div class="logo">
                <img src="https://upload.wikimedia.org/wikipedia/commons/6/61/Wikipedia-logo-transparent.png">
                <h1>W?K?PED?A</h1>
            </div>
            <div class="menu-one">
                <h4>Sayfalar</h4>
                <div class="cizgi"></div>
                <ul>
                    <li><a href="#"><i class="far fa-home"></i> Anasayfa</a></li>
                    <li><a href="#"><i class="far fa-id-card"></i> Hakk?m?zda</a></li>
                    <li><a href="#"><i class="far fa-book-alt"></i> ??indekiler</a></li>
                    <li><a href="#"><i class="far fa-stream"></i> Maddeler</a></li>
                </ul>
            </div>
            <div class="menu-two">
                <h4>Kat?l?m</h4>
                <div class="cizgi"></div>
                <ul>
                    <li><a href="#"><i class="far fa-hands-helping"></i> Ba???</a></li>
                    <li><a href="#"><i class="far fa-house-flood"></i> K?y ?e?mesi</a></li>
                    <li><a href="#"><i class="far fa-store-alt"></i> Wikimedia</a></li>
                    <li><a href="#"><i class="far fa-question-circle"></i> Yard?m</a></li>
                </ul>
            </div>
        </aside>

###你的意思是你的侧边栏重叠你的内容部分,然后请尝试给你的内容部分左padding-left

.content-part { padding-left:200px //equal to aside width}
阅读全文

▼ 版权说明

相关文章也很精彩
推荐内容
更多标签
相关热门
全站排行
随便看看

错说 cuoshuo.com —— 程序员的报错记录

部分内容根据CC版权协议转载;网站内容仅供参考,生产环境使用务必查阅官方文档

辽ICP备19011660号-5

×

扫码关注公众号:职场神器
发送: 1
获取永久解锁本站全部文章的验证码