html - 通过 CSS 增加垂直导航栏宽度的问题

标签 html css

我想知道为什么更新以下 CSS 属性:widthposition 不会放大垂直的 nav bar 在我的 page.aspx 上。

作为示例,请在 CSS 下方找到:

/* The sidebar menu */
.sidenav {
    /*height: 100%;*/ /* Full-height: remove this if you want "auto" height */
    width: 300px; /* Set the width of the sidebar */
    /*position: fixed;*/ /* Fixed Sidebar (stay in place on scroll) */
    position: absolute;
    z-index: 1; /* Stay on top */
    top: 0; /* Stay at the top */
    left: 0;
    /*background-color: #111*/; /* Black */
    background-color: #eee;
    overflow-x: hidden; /* Disable horizontal scroll */
    padding-top: 50px;
    font-family: 'Segoe UI Historic';
    font-size: 19px;

}

    /* The navigation menu links */
    .sidenav a {
        padding: 6px 8px 6px 16px;
        text-decoration: none;
        /*font-size: 25px;*/
        font-size: 19px;
        color: #818181;
        display: block;
        font-family: 'Segoe UI Historic';
    }

        /* When you mouse over the navigation links, change their color */
        .sidenav a:hover {
            /*color: #f1f1f1;*/
            /*color: #2196F3;*/
            color: #1912e3;
            font-family: 'Segoe UI Historic';
        }

/* Style page content */
.main {
    margin-left: 160px; /* Same as the width of the sidebar */
    padding: 0px 10px;
    font-family: 'Segoe UI Historic';
}

/* On smaller screens, where height is less than 450px, change the style of the sidebar (less padding and a smaller font size) */
@media screen and (max-height: 450px) {
    .sidenav {
        padding-top: 15px;
    }

        .sidenav a {
            font-size: 18px;
        }
}

body {
    font-family: "Segoe UI Historic";
}

非常感谢您的反馈。

最佳答案

随机地,基于“试错”方法,我凭经验发现 在 CSS 中将 property width:300px 替换为 width:20% 确实有效。因此,如果可能的话,我很想知道这种随机发现背后的基本原理。

关于html - 通过 CSS 增加垂直导航栏宽度的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59288813/

相关文章:

javascript - 串行滚动条问题

javascript - 从特定样式表中识别特定 HTML 页面中使用的所有 css ID 和类?

html - 如何在 react 中将此下拉菜单组件对齐在我的导航栏上特定位置的下方?

java - CSS解析器解析字符串内容

javascript - 向上/向下移动时颜色变化

html - Firefox 中旋转元素上的框阴影

html - 在模态中使用纯 HTML 和 CSS

css - 将 3.1 模式 Bootstrap 到表单中

javascript - 如何在不占用空间的情况下隐藏 html 元素 x 时间?

html - CSS Inline-table 添加底部边距