html - 当浏览器窗口较小时,导航栏底部 View 被截断

标签 html css

所以我有这个我喜欢的导航栏,当窗口全尺寸显示时,它完美地位于我的两条水平线的顶部并且看起来很棒,但是当我将它调整为较小的 View 时,底部的文字被截断了。我认为它与高度 % 有关,但我很困惑。我也不明白为什么 5% 是全屏模式下完美位于水平线标签顶部的神奇数字?

HTML:

<center><div class="navbar"><a href= 'ask.php'>Ask a Question</a>
      &nbsp;
        <a href='index.html'>Log out</a>
        &nbsp;

       <a href= 'search.html'>Search</a>
       &nbsp;

       <a href= 'yourqs.php'>Your Questions</a>
       &nbsp;
       <a href= 'test.php'>All Questions</a>


<hr><hr></div></center>

CSS:

.navbar {
    overflow: hidden;
    background-color: #333;
    position: fixed; /* Set the navbar to fixed position */
    top: 0; /* Position the navbar at the top of the page */
    width: 100%; /* Full width */
height: 5%;

 padding-top: 17px;
}

最佳答案

因为 5% - 在 1000 像素中 - 和 5% 在 100 像素中,不一样

您可以删除此高度并为您的 div 设置 padding-top 和 padding-bottom,或者以 'px' 设置高度

关于html - 当浏览器窗口较小时,导航栏底部 View 被截断,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45759603/

相关文章:

html - 具有 `srcset` 属性的自动宽度图像

javascript - 将元素宽度调整为父级滚动条

html - VB CSS 问题 Div 自动调整大小

html - 在样式链接图像的左侧垂直居中分隔线

javascript - 非常简单的 jquery 自定义函数抛出错误

multithreading - HTML5 Web Worker 是针对一个页面还是跨页面

html - css/html 子菜单显示在其他页面内容后面而不是在其他页面内容之上

html - 定位带有下方文本的标题,加上背景颜色问题

html - 我如何在 CSS/HTML 中获得粘性页脚?

html - radio 输入样式不适用于 Firefox