I have 11 items to display in my menu and I just see 9 elements.
Example:
Is there a trick to adapt the menu list according to the screen?
I think to reduce the font size is maybe solution to solve my problem?
I don't know if you have a better solution?
I share you my code HTML/CSS.
Thank you so much for your help.
/* 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>
<iframe name="sif1" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
One possibility would be to increase the width
of #sidebarMenu
to fit all items into one line each, and reduce the top and bottom padding
on the list items (.sidebarMenuInner li
). Also the transform
parameter of #sidebarMenu
has to be adapted to translateX(-310px)
(or whatever value you chose for width
) in this case:
/* 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>
<iframe name="sif2" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>
CodePudding user response:
First run this snippet and see whether you want something like this if yes then you just need to add overflow-y: scroll
to your #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>
<iframe name="sif3" sandbox="allow-forms allow-modals allow-scripts" frameborder="0"></iframe>