在 CSS 中移动侧边栏

Move a sidebar in CSS

.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">

我想把这个侧边栏移到最左边和最上面。

我尝试删除填充,但没有填充,所以它什么也没做。

如何把侧边栏移到最左边和最上面?

因为您正在使用 position: fixed。只需在导航侧边栏容器中将 topleft css 属性 设置为 0。

.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">