html - 通过 CSS 增加垂直导航栏宽度的问题
问题描述
我想知道为什么以下CSS
属性的更新:width
,position
不会放大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
bywidth:20%
确实有效。random
因此,如果可能的话,我希望知道这种发现背后的基本原理。
推荐阅读
- svn - 我们如何将文件从一个 repo 复制到 SVN 的另一个 repo 并保持完整的历史记录
- javascript - 自动填充总价使用 javascript dom
- tags - LinkedIn 的元标签问题
- c# - 如何为winforms C#制作PDF查看器
- r - 在 R 中实现 De Casteljau,向量化的麻烦
- swift - URLSession 和 URLSessionTask 强制关闭连接
- kafka-producer-api - 本地防火墙后面的 Kafka node.js
- javascript - 如何在 Vuejs 中单击按钮时禁用文本字段?
- c# - 有没有办法可以更好地构造这个 LINQ 查询?
- security - 不安全网络中的 K8 集群通信