Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在html/css上使固定侧导航栏移到右侧?_Html_Css - Fatal编程技术网

如何在html/css上使固定侧导航栏移到右侧?

如何在html/css上使固定侧导航栏移到右侧?,html,css,Html,Css,以下是我的css代码: .sidenav { height: 100%; width: 160px; position: fixed; z-index: 1; top: 0; left: 0; background-color: #111; overflow-x: hidden; padding-top: 20px; } .sidenav a { padding: 6px 8px 6px 16px; tex

以下是我的css代码:

.sidenav {
    height: 100%;
    width: 160px;
    position: fixed;
    z-index: 1;
    top: 0;
    left: 0;
    background-color: #111;
    overflow-x: hidden;
    padding-top: 20px;
}

.sidenav a {
    padding: 6px 8px 6px 16px;
    text-decoration: none;
    font-size: 25px;
    color: #818181;
    display: block;
}

@media screen and (max-height: 450px) {
    .sidenav {padding-top: 15px;}
    .sidenav a {font-size: 18px;}
}

我试过在左右两侧摆弄右键和升降键以及填充物,但我所做的一切都让侧边栏粘在了左侧。我怎样才能让它移到右边?提前谢谢

将您的
.sidenav
类属性
left
更改为
right

.sidenav {
    height: 100%;
    width: 160px;
    position: fixed;
    z-index: 1;
    top: 0;
    right: 0;
    background-color: #111;
    overflow-x: hidden;
    padding-top: 20px;
}

left:0
的意思是将div锚定到相对容器的左侧0像素处,将其更改为
right:0
告诉css它锚定右侧0像素处。

出于某种原因,我不得不等待9分钟,但肯定会很好,很高兴为我的朋友编码!