html - 调整大小时,菜单栏折叠,一半的选项出现在其他选项下方的一行中
问题描述
我正在尝试创建我网站的主菜单栏。然而,虽然当浏览器全尺寸时它工作正常,但当我调整菜单栏的大小时,它会折叠,一半的选项出现在其他选项下方的一行中,而我希望它们保持一致,即使其中一些不可见.
为了使菜单栏的选择保持在单行中,即使该行不完全可见,我可以使用 HTML 和 CSS 做什么?我已经在主菜单和链接类中尝试了所有可能的位置,使用百分比和像素添加宽度,并添加过渡和固定位置组合。没有任何帮助。
.main-menu {
background-color:grey;
font-weight:bold;
font-size:xx-large;
color: black;
}
.linking {
text-decoration: none;
color: white;
margin-right: 100px;
border:solid 2px;
border-color: red;
}
<p class="main-menu">
<a href="studenthome.html" class="linking">ΦΟΙΤΗΤΕΣ</a>
<a href="secrethome.html" class="linking">ΓΡΑΜΜΑΤΕΙΑ</a>
<a href="publisherhome.html" class="linking">ΕΚΔΟΤΗΣ</a>
<a href="sellerhome.html" class="linking">....</a>
</p>
解决方案
可能这对你有帮助。看看下面的代码片段。
.main-menu {
background:grey;
font-weight:bold;
font-size:xx-large;
color: #000;
overflow:hidden; /*to hide on collapse*/
height:1em;
}
.linking {
text-decoration: none;
color: #FFF;
margin: 0 100px 0 0;
border:2px solid red;
}
<p class="main-menu">
<a href="studenthome.html" class="linking">ΦΟΙΤΗΤΕΣ</a>
<a href="secrethome.html" class="linking">ΓΡΑΜΜΑΤΕΙΑ</a>
<a href="publisherhome.html" class="linking">ΕΚΔΟΤΗΣ</a>
<a href="sellerhome.html" class="linking">....</a>
</p>
推荐阅读
- c# - ClickOnce 将未引用的 dll 复制到基目录
- python-3.x - 无法在 Pytorch 1.5.1 版中加载在 Pytotch 1.6.0 版上训练的模型
- javascript - 找不到模块 webpack
- laravel - Laravel 在公共文件夹中而不是在存储文件夹中上传图像
- nix - Nix:如何在 nixpkgs.mkShell 中更改 stdenv
- java - 使用 Quarkus 进行测试时的 Maven NoSuchMethodException
- c - 让 GNU `ld` 链接到另一个二进制文件中的静态函数,而不包括它们
- sql - HiveSQL - Erorr mismatched input 'as' expecting
- vba - 在 VBA 中测试位
- python - 如何在 QLCDNumber 屏幕上显示多个数字?