菜单列表:部分项目未显示

menu list: some items are not displayed

我的菜单中有 11 个项目要显示,但我只看到 9 个元素。

示例:

是否有根据屏幕调整菜单列表的技巧?

我认为减小字体大小也许可以解决我的问题?

不知道大家有没有更好的解决办法?

我把我的代码分享给你HTML/CSS。

非常感谢您的帮助。

/* Add application styles & imports to this file! */

@import '~bootstrap/dist/css/bootstrap.css';
@import url('https://fonts.googleapis.com/css?family=Varela+Round');
@import '~font-awesome/css/font-awesome.css';

html,
body {
  overflow-x: hidden;
  height: 100%;
}
body {
  background: #fff;
  padding: 0;
  margin: 0;
  font-family: 'Varela Round', sans-serif;
}
.header {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 100%;
  box-shadow: none;
  background-color: cornflowerblue;
  position: fixed;
  height: 60px !important;
  overflow: hidden;
  z-index: 10;
}
.main {
  margin: 0 auto;
  display: block;
  height: 100%;
  margin-top: 60px;
}
.mainInner {
  display: table;
  height: 100%;
  width: 100%;
  text-align: center;
}
.mainInner div {
  display: table-cell;
  vertical-align: middle;
  font-size: 3em;
  font-weight: bold;
  letter-spacing: 1.25px;
}
#sidebarMenu {
  height: 100%;
  position: fixed;
  left: 0;
  width: 250px;
  margin-top: 60px;
  transform: translateX(-250px);
  transition: transform 250ms ease-in-out;
  /* background: linear-gradient(180deg, #FC466B 0%, #3F5EFB 100%); */
  background-color: cornflowerblue;
}
.sidebarMenuInner {
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebarMenuInner li {
  list-style: none;
  color: #fff;
  text-transform: uppercase;
  font-weight: bold;
  padding: 20px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebarMenuInner li span {
  display: block;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
}
.sidebarMenuInner li a {
  color: #fff;
  text-transform: uppercase;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
}
input[type='checkbox']:checked ~ #sidebarMenu {
  transform: translateX(0);
}

input[type='checkbox'] {
  transition: all 0.3s;
  box-sizing: border-box;
  display: none;
}
.sidebarIconToggle {
  transition: all 0.3s;
  box-sizing: border-box;
  cursor: pointer;
  position: absolute;
  z-index: 99;
  height: 100%;
  width: 100%;
  top: 22px;
  left: 15px;
  height: 22px;
  width: 22px;
}
.spinner {
  transition: all 0.3s;
  box-sizing: border-box;
  position: absolute;
  height: 3px;
  width: 100%;
  background-color: #fff;
}
.horizontal {
  transition: all 0.3s;
  box-sizing: border-box;
  position: relative;
  float: left;
  margin-top: 3px;
}
.diagonal.part-1 {
  position: relative;
  transition: all 0.3s;
  box-sizing: border-box;
  float: left;
}
.diagonal.part-2 {
  transition: all 0.3s;
  box-sizing: border-box;
  position: relative;
  float: left;
  margin-top: 3px;
}
input[type='checkbox']:checked ~ .sidebarIconToggle > .horizontal {
  transition: all 0.3s;
  box-sizing: border-box;
  opacity: 0;
}
input[type='checkbox']:checked ~ .sidebarIconToggle > .diagonal.part-1 {
  transition: all 0.3s;
  box-sizing: border-box;
  transform: rotate(135deg);
  margin-top: 8px;
}
input[type='checkbox']:checked ~ .sidebarIconToggle > .diagonal.part-2 {
  transition: all 0.3s;
  box-sizing: border-box;
  transform: rotate(-135deg);
  margin-top: -9px;
}
<!DOCTYPE html>
<html>
   <head>
      <title>HTML CSS JS</title>
   </head>
   <body>
      <div class="header"></div>
      <input type="checkbox" class="openSidebarMenu" id="openSidebarMenu" />
      <label for="openSidebarMenu" class="sidebarIconToggle">
         <div class="spinner diagonal part-1"></div>
         <div class="spinner horizontal"></div>
         <div class="spinner diagonal part-2"></div>
      </label>
      <div id="sidebarMenu">
         <ul class="sidebarMenuInner">
            <li>
               <a routerLink="account-opening">
               <i class="fa fa-key"></i>Ouverture d'un compte</a
                  >
            </li>
            <li>
               <a routerLink="portfolio">
               <i class="fa fa-credit-card"></i>Selection d'un portefeuille</a
                  >
            </li>
            <li>
               <a routerLink="corporate-action">
               <i class="fa fa-key"></i>Corporate actions</a
                  >
            </li>
            <li>
               <a routerLink="visualization-deposit">
               <i class="fa fa-credit-card"></i>Visualisation des dépôts</a
                  >
            </li>
            <li>
               <a routerLink="value"> <i class="fa fa-key"></i>Valeurs</a>
            </li>
            <li>
               <a routerLink="indice-boursier">
               <i class="fa fa-credit-card"></i>Indices Boursiers</a
                  >
            </li>
            <li>
               <a routerLink="devise"> <i class="fa fa-key"></i>Devises</a>
            </li>
            <li>
               <a routerLink="valuable-table">
               <i class="fa fa-credit-card"></i>Tableau de valeurs</a
                  >
            </li>
            <li>
               <a routerLink="form-create">
               <i class="fa fa-credit-card"></i>Création formulaire</a
                  >
            </li>
            <li>
               <a routerLink="form-delete">
               <i class="fa fa-credit-card"></i>Suppresion formulaire</a
                  >
            </li>
            <li>
               <a routerLink="form-follow-up">
               <i class="fa fa-credit-card"></i>Suivi formulaire</a
                  >
            </li>
         </ul>
      </div>
   </body>
</html>

首先 运行 这个片段,看看你是否想要这样的东西,如果是,那么你只需要将 overflow-y: scroll 添加到你的 #sidebarMenu

/* Add application styles & imports to this file! */

@import '~bootstrap/dist/css/bootstrap.css';
@import url('https://fonts.googleapis.com/css?family=Varela+Round');
@import '~font-awesome/css/font-awesome.css';

html,
body {
  overflow-x: hidden;
  height: 100%;
}
body {
  background: #fff;
  padding: 0;
  margin: 0;
  font-family: 'Varela Round', sans-serif;
}
.header {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 100%;
  box-shadow: none;
  background-color: cornflowerblue;
  position: fixed;
  height: 60px !important;
  overflow: hidden;
  z-index: 10;
}
.main {
  margin: 0 auto;
  display: block;
  height: 100%;
  margin-top: 60px;
}
.mainInner {
  display: table;
  height: 100%;
  width: 100%;
  text-align: center;
}
.mainInner div {
  display: table-cell;
  vertical-align: middle;
  font-size: 3em;
  font-weight: bold;
  letter-spacing: 1.25px;
}
#sidebarMenu {
  height: 100%;
  overflow-y: scroll; /*Added only this */
  position: fixed;
  left: 0;
  width: 250px;
  margin-top: 60px;
  transform: translateX(-250px);
  transition: transform 250ms ease-in-out;
  /* background: linear-gradient(180deg, #FC466B 0%, #3F5EFB 100%); */
  background-color: cornflowerblue;
}
.sidebarMenuInner {
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebarMenuInner li {
  list-style: none;
  color: #fff;
  text-transform: uppercase;
  font-weight: bold;
  padding: 20px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebarMenuInner li span {
  display: block;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
}
.sidebarMenuInner li a {
  color: #fff;
  text-transform: uppercase;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
}
input[type='checkbox']:checked ~ #sidebarMenu {
  transform: translateX(0);
}

input[type='checkbox'] {
  transition: all 0.3s;
  box-sizing: border-box;
  display: none;
}
.sidebarIconToggle {
  transition: all 0.3s;
  box-sizing: border-box;
  cursor: pointer;
  position: absolute;
  z-index: 99;
  height: 100%;
  width: 100%;
  top: 22px;
  left: 15px;
  height: 22px;
  width: 22px;
}
.spinner {
  transition: all 0.3s;
  box-sizing: border-box;
  position: absolute;
  height: 3px;
  width: 100%;
  background-color: #fff;
}
.horizontal {
  transition: all 0.3s;
  box-sizing: border-box;
  position: relative;
  float: left;
  margin-top: 3px;
}
.diagonal.part-1 {
  position: relative;
  transition: all 0.3s;
  box-sizing: border-box;
  float: left;
}
.diagonal.part-2 {
  transition: all 0.3s;
  box-sizing: border-box;
  position: relative;
  float: left;
  margin-top: 3px;
}
input[type='checkbox']:checked ~ .sidebarIconToggle > .horizontal {
  transition: all 0.3s;
  box-sizing: border-box;
  opacity: 0;
}
input[type='checkbox']:checked ~ .sidebarIconToggle > .diagonal.part-1 {
  transition: all 0.3s;
  box-sizing: border-box;
  transform: rotate(135deg);
  margin-top: 8px;
}
input[type='checkbox']:checked ~ .sidebarIconToggle > .diagonal.part-2 {
  transition: all 0.3s;
  box-sizing: border-box;
  transform: rotate(-135deg);
  margin-top: -9px;
}
<!DOCTYPE html>
<html>
   <head>
      <title>HTML CSS JS</title>
   </head>
   <body>
      <div class="header"></div>
      <input type="checkbox" class="openSidebarMenu" id="openSidebarMenu" />
      <label for="openSidebarMenu" class="sidebarIconToggle">
         <div class="spinner diagonal part-1"></div>
         <div class="spinner horizontal"></div>
         <div class="spinner diagonal part-2"></div>
      </label>
      <div id="sidebarMenu">
         <ul class="sidebarMenuInner">
            <li>
               <a routerLink="account-opening">
               <i class="fa fa-key"></i>Ouverture d'un compte</a
                  >
            </li>
            <li>
               <a routerLink="portfolio">
               <i class="fa fa-credit-card"></i>Selection d'un portefeuille</a
                  >
            </li>
            <li>
               <a routerLink="corporate-action">
               <i class="fa fa-key"></i>Corporate actions</a
                  >
            </li>
            <li>
               <a routerLink="visualization-deposit">
               <i class="fa fa-credit-card"></i>Visualisation des dépôts</a
                  >
            </li>
            <li>
               <a routerLink="value"> <i class="fa fa-key"></i>Valeurs</a>
            </li>
            <li>
               <a routerLink="indice-boursier">
               <i class="fa fa-credit-card"></i>Indices Boursiers</a
                  >
            </li>
            <li>
               <a routerLink="devise"> <i class="fa fa-key"></i>Devises</a>
            </li>
            <li>
               <a routerLink="valuable-table">
               <i class="fa fa-credit-card"></i>Tableau de valeurs</a
                  >
            </li>
            <li>
               <a routerLink="form-create">
               <i class="fa fa-credit-card"></i>Création formulaire</a
                  >
            </li>
            <li>
               <a routerLink="form-delete">
               <i class="fa fa-credit-card"></i>Suppresion formulaire</a
                  >
            </li>
            <li>
               <a routerLink="form-follow-up">
               <i class="fa fa-credit-card"></i>Suivi formulaire</a
                  >
            </li>
         </ul>
      </div>
   </body>
</html>

一种可能性是增加 #sidebarMenuwidth 以将所有项目都排成一行,并减少列表项目的顶部和底部 padding (.sidebarMenuInner li).在这种情况下,#sidebarMenutransform 参数必须适应 translateX(-310px)(或您为 width 选择的任何值):

/* Add application styles & imports to this file! */

@import '~bootstrap/dist/css/bootstrap.css';
@import url('https://fonts.googleapis.com/css?family=Varela+Round');
@import '~font-awesome/css/font-awesome.css';

html,
body {
  overflow-x: hidden;
  height: 100%;
}
body {
  background: #fff;
  padding: 0;
  margin: 0;
  font-family: 'Varela Round', sans-serif;
}
.header {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 100%;
  box-shadow: none;
  background-color: cornflowerblue;
  position: fixed;
  height: 60px !important;
  overflow: hidden;
  z-index: 10;
}
.main {
  margin: 0 auto;
  display: block;
  height: 100%;
  margin-top: 60px;
}
.mainInner {
  display: table;
  height: 100%;
  width: 100%;
  text-align: center;
}
.mainInner div {
  display: table-cell;
  vertical-align: middle;
  font-size: 3em;
  font-weight: bold;
  letter-spacing: 1.25px;
}
#sidebarMenu {
  height: 100%;
  position: fixed;
  left: 0;
  width: 310px;
  margin-top: 60px;
  transform: translateX(-310px);
  transition: transform 250ms ease-in-out;
  /* background: linear-gradient(180deg, #FC466B 0%, #3F5EFB 100%); */
  background-color: cornflowerblue;
}
.sidebarMenuInner {
  margin: 0;
  padding: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebarMenuInner li {
  list-style: none;
  color: #fff;
  text-transform: uppercase;
  font-weight: bold;
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebarMenuInner li span {
  display: block;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
}
.sidebarMenuInner li a {
  color: #fff;
  text-transform: uppercase;
  font-weight: bold;
  cursor: pointer;
  text-decoration: none;
}
input[type='checkbox']:checked ~ #sidebarMenu {
  transform: translateX(0);
}

input[type='checkbox'] {
  transition: all 0.3s;
  box-sizing: border-box;
  display: none;
}
.sidebarIconToggle {
  transition: all 0.3s;
  box-sizing: border-box;
  cursor: pointer;
  position: absolute;
  z-index: 99;
  height: 100%;
  width: 100%;
  top: 22px;
  left: 15px;
  height: 22px;
  width: 22px;
}
.spinner {
  transition: all 0.3s;
  box-sizing: border-box;
  position: absolute;
  height: 3px;
  width: 100%;
  background-color: #fff;
}
.horizontal {
  transition: all 0.3s;
  box-sizing: border-box;
  position: relative;
  float: left;
  margin-top: 3px;
}
.diagonal.part-1 {
  position: relative;
  transition: all 0.3s;
  box-sizing: border-box;
  float: left;
}
.diagonal.part-2 {
  transition: all 0.3s;
  box-sizing: border-box;
  position: relative;
  float: left;
  margin-top: 3px;
}
input[type='checkbox']:checked ~ .sidebarIconToggle > .horizontal {
  transition: all 0.3s;
  box-sizing: border-box;
  opacity: 0;
}
input[type='checkbox']:checked ~ .sidebarIconToggle > .diagonal.part-1 {
  transition: all 0.3s;
  box-sizing: border-box;
  transform: rotate(135deg);
  margin-top: 8px;
}
input[type='checkbox']:checked ~ .sidebarIconToggle > .diagonal.part-2 {
  transition: all 0.3s;
  box-sizing: border-box;
  transform: rotate(-135deg);
  margin-top: -9px;
}
<!DOCTYPE html>
<html>
   <head>
      <title>HTML CSS JS</title>
   </head>
   <body>
      <div class="header"></div>
      <input type="checkbox" class="openSidebarMenu" id="openSidebarMenu" />
      <label for="openSidebarMenu" class="sidebarIconToggle">
         <div class="spinner diagonal part-1"></div>
         <div class="spinner horizontal"></div>
         <div class="spinner diagonal part-2"></div>
      </label>
      <div id="sidebarMenu">
         <ul class="sidebarMenuInner">
            <li>
               <a routerLink="account-opening">
               <i class="fa fa-key"></i>Ouverture d'un compte</a
                  >
            </li>
            <li>
               <a routerLink="portfolio">
               <i class="fa fa-credit-card"></i>Selection d'un portefeuille</a
                  >
            </li>
            <li>
               <a routerLink="corporate-action">
               <i class="fa fa-key"></i>Corporate actions</a
                  >
            </li>
            <li>
               <a routerLink="visualization-deposit">
               <i class="fa fa-credit-card"></i>Visualisation des dépôts</a
                  >
            </li>
            <li>
               <a routerLink="value"> <i class="fa fa-key"></i>Valeurs</a>
            </li>
            <li>
               <a routerLink="indice-boursier">
               <i class="fa fa-credit-card"></i>Indices Boursiers</a
                  >
            </li>
            <li>
               <a routerLink="devise"> <i class="fa fa-key"></i>Devises</a>
            </li>
            <li>
               <a routerLink="valuable-table">
               <i class="fa fa-credit-card"></i>Tableau de valeurs</a
                  >
            </li>
            <li>
               <a routerLink="form-create">
               <i class="fa fa-credit-card"></i>Création formulaire</a
                  >
            </li>
            <li>
               <a routerLink="form-delete">
               <i class="fa fa-credit-card"></i>Suppresion formulaire</a
                  >
            </li>
            <li>
               <a routerLink="form-follow-up">
               <i class="fa fa-credit-card"></i>Suivi formulaire</a
                  >
            </li>
         </ul>
      </div>
   </body>
</html>