html - 固定导航列表上的负边距

标签 html css css-float margins

基本上我拥有的是一个包含所有内容的主容器 div。我想要一个固定的垂直导航列表出现在容器的一侧。

当我调整窗口大小以查看不同的分辨率时出现问题。我现在在我的容器中使用大约 1024px 的固定宽度,最小宽度为 1200px,但它仍然切断了固定导航列表的一部分,因为我在导航容器上使用了 -125px 的边距以使其超出内容容器。

这是正常的样子

enter image description here

然后当缩小尺寸时,我设置的最小宽度开始生效

enter image description here

这是导航的代码 .导航{ 向左飘浮; 位置:固定; 左边距:-125px; 文本对齐:右;

最佳答案

.nava
{
    float:left; 
    position: fixed;
    min-width: ??px         //Set your minimum needs here.
    max-width: ???%;        //preferably % because you don't know the maximum
    padding-left: -125px;   //!!!
    text-align:right; 
}

当你的意图是填充时,永远不要使用边距,永远不要!

关于html - 固定导航列表上的负边距,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12810016/

相关文章:

html - 将 Div 中的背景图片变成链接

javascript - Safari 和 IE8 中的 jQuery 径向菜单故障

html - 溢出 :hidden includes float in container - why?

html - 如何避免在内联 <ul> 中破坏 <li>?

javascript - 如何将 CSS 样式添加到 javascript

android - Bootstrap 中纵向和横向的不同网格布局

javascript - 如何使用货币掩码自动格式化输入数字( ionic )

html - Firefox 中的 Flexbox : Items are not lined up properly

jquery - 底部 float div(如 Facebook 消息中)

html - 在另一个 div 中左右定位 div