.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">
- 1 回答
- 0 關注
- 134 瀏覽
添加回答
舉報
0/150
提交
取消