为了账号安全,请及时绑定邮箱和手机立即绑定

在 CSS 中移动侧边栏

在 CSS 中移动侧边栏

斯蒂芬大帝 2024-01-22 15:44:19
.wrapper{    width: 1024px;    margin: auto;}.left-sidebar {    z-index: 9999;    width: 200px;    background: #303030;    height:100%;    overflow: auto;}#sidebar {    min-width: 200px;    min-height: 200px;    background: #303030;    color: #fff;    position:fixed;    transition: all 0.3s;    z-index:999;    height:100%;    width: 25%;    float: left;}<div class="wrapper">  <div class="left-sidebar">    <nav id="sidebar">我想将此侧边栏移至最左侧和顶部。我尝试删除填充,但没有填充,所以它什么也没做。如何将侧边栏移动到最左侧和最顶部?
查看完整描述

1 回答

?
忽然笑

TA贡献1806条经验 获得超5个赞

既然你正在使用position: fixed. 只需在导航侧边栏容器中将top和css 属性设置为 0 即可。left


.wrapper {

    width: 1024px;

    margin: auto;

}

.left-sidebar {

    z-index: 9999;

    width: 200px;

    background: #303030;

    height:100%;

    overflow: auto;

}

#sidebar {

    min-width: 200px;

    min-height: 200px;

    background: #303030;

    color: #fff;

    position: fixed;

    top: 0;

    left: 0;

    transition: all 0.3s;

    z-index: 999;

    min-height: 100%;

    width: 25%;

    float: left;

}

<div class="wrapper">

  <div class="left-sidebar">

    <nav id="sidebar">


查看完整回答
反对 回复 2024-01-22
  • 1 回答
  • 0 关注
  • 21 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信