I would like to get this result:
For now, I don't have much...
I don't understand why I don't have a gray line that separates each menu title? And the arrows are not aligned correctly?
I tried several things but I give up, the elements are still not aligned and the border-bottom does not appear on each title.
#import url(https://fonts.googleapis.com/css?family=Open+Sans);
#import url(https://use.fontawesome.com/releases/v5.3.1/css/all.css);
*,
*:before,
*:after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
h1 {
font-size: 58px;
}
h2 {
font-size: 30px;
}
ul {
list-style-type: none;
}
.sidebar {
position: fixed;
height: 100%;
width: 250px;
background: #239cd3;
transition: all 0.5s ease;
}
/* LOGO */
.sidebar .logo-details {
height: 100px;
display: flex;
align-items: center;
}
.sidebar .accordion {
font-size: 18px;
color: white;
border-bottom: 1px solid #ccc;
padding: 15px 15px 15px 25px;
}
.sidebar .accordion li i.fa-chevron-down {
right: 1rem;
left: auto;
}
.sidebar .accordion li.active i.fa-chevron-down {
transform: rotate(180deg);
}
<div class="sidebar" style="border-right: 1px solid black" [ngClass]="{ active: showSideBar }">
<div class="logo-details" style="border-bottom: 1px solid black;">
<span class="logo_name">
</span>
</div>
<ul id="accordion" class="accordion">
<li *ngFor="let menu of menus; let i = index" [class.active]="menu.active">
<ng-container>
<div class="menu" (click)="selectMenu(menu)">
<i [class]="menu.iconClass"></i> {{ menu.name }}
<i class="fa fa-chevron-down"></i>
</div>
</ng-container>
</li>
</ul>
</div>
The project is here.
Thanks for your help and your time.
Concerning the grey divider line and the padding I think this rule...
.sidebar .accordion {
font-size: 18px;
color: white;
border-bottom: 1px solid #ccc;
padding: 15px 15px 15px 25px;
}
...should be changed to have a different selector which doesn't apply to the ul , but to its li children:
.sidebar .accordion > li {
font-size: 18px;
color: white;
border-bottom: 1px solid #ccc;
padding: 15px 15px 15px 25px;
}
Concerning the alignment of the downward arrows you could apply display: flex and justify-content: space-between to the .menu elements which are children of the li elements addressed with the CSS rule above, plus apply margin-left: auto;to its last child (= the down-arrow) to have everything before that left-aligned and the arrow right-aligned. In other words, add this:
.sidebar .accordion > li .menu {
display: flex;
justify-content: space-between;
}
.sidebar .accordion > li .menu > i.fa.fa-chevron-down {
margin-left: auto;
}
Related
I'm creating an HTML/CSS menu for an Angular project.
I have two rubrics in the menu...
When I click on a rubric, there is a space that is created, how could I solve this problem, please?
The problem happens when hovering...
/* You can add global styles to this file, and also import other style files */
#import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
* {
list-style: none;
text-decoration: none;
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Open Sans', sans-serif;
}
body {
background: #f5f6fa;
}
.wrapper .sidebar {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 225px;
background: rgb(5, 68, 104);
padding: 20px 0;
transition: all 0.5s ease;
}
.wrapper .sidebar ul li a {
display: block;
padding: 13px 60px;
border-bottom: 1px solid green;
color: rgb(241, 237, 237);
font-size: 16px;
position: relative;
background-color: red;
}
.wrapper .sidebar ul li a .icon {
color: #dee4ec;
width: 30px;
display: inline-block;
}
.wrapper .sidebar ul li a:hover {
color: #0c7db1;
border-right: 2px solid rgb(5, 68, 104);
}
.wrapper .sidebar li i {
position: absolute;
top: 1.2rem;
left: 1rem;
right: 1rem;
color: white;
transition: all 0.4s ease;
font-size: 18px;
}
.wrapper .sidebar li i.fa-chevron-down {
right: 1rem;
left: auto;
}
.wrapper .sidebar li.active i.fa-chevron-down {
transform: rotate(180deg);
}
.wrapper .sidebar li.active .menu {
color: white;
}
.wrapper .sidebar li.active i {
color: white;
}
<div class="wrapper">
<!-- Top Menu -->
<div class="sidebar">
<!-- Menu Item -->
<ul>
<li
*ngFor="let menu of menus; let i = index"
[class.active]="menu.active"
>
<ng-container>
<a class="item" (click)="selectMenu(menu)">
<i [class]="menu.iconClass"></i> {{ menu.name }}
<i class="fa fa-chevron-down"></i>
</a>
</ng-container>
</li>
</ul>
</div>
</div>
I share you a reproduction on stackblitz here.
Thank you in advance for your help and sharing.
.wrapper .sidebar ul li a:hover { color: #0c7db1; }
Just Remove the border tag From Hover and it will fix your Problem
As the comment suggests,
Seems like border-right on hover is the issue => .wrapper .sidebar ul li a:hover
#emre-ozgun
I have commented that line, see the answer snippet below
/* You can add global styles to this file, and also import other style files */
#import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
* {
list-style: none;
text-decoration: none;
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Open Sans', sans-serif;
}
body {
background: #f5f6fa;
}
.wrapper .sidebar {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 225px;
background: rgb(5, 68, 104);
padding: 20px 0;
transition: all 0.5s ease;
}
.wrapper .sidebar ul li a {
display: block;
padding: 13px 60px;
border-bottom: 1px solid green;
color: rgb(241, 237, 237);
font-size: 16px;
position: relative;
background-color: red;
}
.wrapper .sidebar ul li a .icon {
color: #dee4ec;
width: 30px;
display: inline-block;
}
.wrapper .sidebar ul li a:hover {
color: #0c7db1;
/* border-right: 2px solid rgb(5, 68, 104);*/
}
.wrapper .sidebar li i {
position: absolute;
top: 1.2rem;
left: 1rem;
right: 1rem;
color: white;
transition: all 0.4s ease;
font-size: 18px;
}
.wrapper .sidebar li i.fa-chevron-down {
right: 1rem;
left: auto;
}
.wrapper .sidebar li.active i.fa-chevron-down {
transform: rotate(180deg);
}
.wrapper .sidebar li.active .menu {
color: white;
}
.wrapper .sidebar li.active i {
color: white;
}
<div class="wrapper">
<!-- Top Menu -->
<div class="sidebar">
<!-- Menu Item -->
<ul>
<li
*ngFor="let menu of menus; let i = index"
[class.active]="menu.active"
>
<ng-container>
<a class="item" (click)="selectMenu(menu)">
<i [class]="menu.iconClass"></i> {{ menu.name }}
<i class="fa fa-chevron-down"></i>
</a>
</ng-container>
</li>
</ul>
</div>
</div>
I don't understand why the border-bottom is not displayed entirely in the menu?
Here is my result below:
image
In this image, there is a space on the left that I would like to remove because it is not aesthetically pretty.
dashboard.component.html
<div class="sidebar" style="border-right: 1px solid black" [ngClass]="{ active: showSideBar }">
<div class="logo-details" style="border-bottom: 1px solid black;">
<span class="logo_name">
</span>
</div>
<ul id="accordion" class="accordion">
<li *ngFor="let menu of menus; let i = index" [class.active]="menu.active">
<ng-container>
<div class="menu" (click)="selectMenu(menu)">
<i [class]="menu.iconClass"></i> {{ menu.name }}
<i class="fa fa-chevron-down"></i>
</div>
</ng-container>
</li>
</ul>
style.css
#import url(https://fonts.googleapis.com/css?family=Open+Sans);
#import url(https://use.fontawesome.com/releases/v5.3.1/css/all.css);
*,
*:before,
*:after {
margin: 0;
padding: 0;
box-sizing: border-box;
}
h1 {
font-size: 58px;
}
h2 {
font-size: 30px;
}
ul {
list-style-type: none;
}
.sidebar {
position: fixed;
height: 100%;
width: 250px;
background: #239cd3;
/* overflow-y:scroll;*/
transition: all 0.5s ease;
}
/* LOGO */
.sidebar .logo-details {
height: 100px;
display: flex;
align-items: center;
}
/* ACCORDION */
.sidebar .accordion {
width: 100%;
margin: 0px;
border-radius: 4px;
}
/* MENU TITLE */
.sidebar .accordion .menu {
position: relative;
padding: 15px 15px 15px 20px;
color: white;
border-bottom: 1px solid #ccc;
cursor: pointer;
transition: all 0.4s ease;
font-size: 18px;
text-transform: uppercase;
text-decoration: none;
}
/* ICON MENU TITLE */
.sidebar .accordion li i {
position: absolute;
top: 1.2rem;
left: -15px;
/* left: 1rem; */
color: white;
transition: all 0.4s ease;
font-size: 18px;
}
.sidebar .accordion li i.fa-chevron-down {
right: 1rem;
left: auto;
}
.sidebar .accordion li.active i.fa-chevron-down {
transform: rotate(180deg);
}
The code is here for information -> Stackblitz.
Thank you in advance for your reply.
There is a padding-left: 2rem; for ul element. Remove that.
Give that padding-left: 2rem; to the li element in *ngFor.
remove border-bottom from div and add to li.
I want to create a menu, where if you hover over an <a> it slides down by 10px, and if you unhover it slides back up 10px.
The problem is whenever you hover over an <a> the parent container (<li>) gets squashed to 0px width.
.nav-list {
display: flex;
gap: 1rem;
list-style: none;
justify-content: flex-end;
background-color: #495371;
padding: 20px 20px 30px 20px;
}
.nav-list>li {
border: 1px yellow solid;
}
.nav-list a:link,
a:visited,
a:active {
color: #FFF;
text-decoration: none;
border: 1px red solid;
font-size: 30px;
font-weight: bold;
}
.nav-list a:hover {
color: #000;
position: absolute;
padding-top: 10px;
}
<header>
<nav>
<ul class="nav-list">
<li>Stuff1</li>
<li>Stuff22</li>
<li>Stuff333</li>
</ul>
</nav>
</header>
<p>yellow: ul<br>red: a</p>
JSFiddle Link
Instead of position: absolute; for hover effect, you'd need to use transform: translateY();. Also, because a is inherently inline element, you'd need to add the transform to its block-level parent of li.
Please see the snippet below. Very minimal change has been made to your .nav-list li and its a styles.
.nav-list {
display: flex;
gap: 1rem;
list-style: none;
justify-content: flex-end;
background-color: #495371;
padding: 20px 20px 30px 20px;
}
.nav-list>li {
border: 1px yellow solid;
transition: transform .2s;
}
.nav-list a:link,
a:visited,
a:active {
color: #FFF;
text-decoration: none;
border: 1px red solid;
font-size: 30px;
font-weight: bold;
}
.nav-list li:hover {
transform: translateY(10px);
}
.nav-list a:hover {
color: #000;
}
<header>
<nav>
<ul class="nav-list">
<li>Stuff1</li>
<li>Stuff22</li>
<li>Stuff333</li>
</ul>
</nav>
</header>
<p>yellow: ul<br>red: a</p>
What you want is position: relative; and top: 10px; on your hover instead of position absolute and padding-top. This will push your element down. Note that the yellow box will not go down with it if you have it set to the anchor tag's hover. Instead, have it attach the li tag's hover event if you want both to move in that direction.
.nav-list {
display: flex;
gap: 1rem;
list-style: none;
justify-content: flex-end;
background-color: #495371;
padding: 20px 20px 30px 20px;
}
.nav-list>li {
border: 1px yellow solid;
}
.nav-list a:link,
a:visited,
a:active {
color: #FFF;
text-decoration: none;
border: 1px red solid;
font-size: 30px;
font-weight: bold;
}
.nav-list a:hover {
color: #000;
position: relative;
top: 10px;
}
<header>
<nav>
<ul class="nav-list">
<li>Stuff1</li>
<li>Stuff22</li>
<li>Stuff333</li>
</ul>
</nav>
</header>
<p>yellow: ul<br>red: a</p>
I am facing an issue on IE11 on a fixed element. That's a context menu that needs to grow horizontally depending on the text inside. This works perfectly on Firefox, Chrome and Safari, but not on IE.
The problem is that on IE11 the right arrow goes down to the next line, instead of growing the line to allow all text be shown.
The following is my code:
* {
box-sizing: border-box;
}
#context-menu {
display: none;
text-align: left;
position: fixed;
z-index: 1000000000;
}
#context-menu ul {
background-color: white;
border: 1px solid #ccc;
border-radius: 5px;
box-shadow: 1px 1px 3px #444;
text-align: left;
min-width: 150px;
width: auto;
}
#context-menu ul,
#context-menu ul li {
padding: 0;
margin: 0;
position: relative;
display: block;
width: auto;
color: black;
text-align: left;
background-color: #fff;
}
#context-menu ul li {
padding: 5px 10px;
cursor: pointer;
}
#context-menu ul li:hover ul {
z-index: 1;
}
#context-menu ul li:first-child {
border-radius: 3px 3px 0 0;
}
#context-menu ul li:last-child {
border-radius: 0 0 3px 3px;
}
#context-menu ul li .fa {
margin-right: 10px;
width: 15px;
vertical-align: middle;
}
#context-menu ul li.group {
cursor: default;
background-color: #dfdfdf;
font-weight: bold;
}
#context-menu ul > li:not(.group):hover {
background-color: hsla(208, 56%, 53%, 1);
color: black;
}
#context-menu ul > li.submenu::after {
font-family: FontAwesome;
content: "\f105";
margin-left: 15px;
float: right;
}
#context-menu ul> li > ul{
display: none;
}
#context-menu ul > li:hover > ul {
display: block;
position: absolute;
left: 100%;
top: 0;
}
<link href="https://opensource.keycdn.com/fontawesome/4.7.0/font-awesome.min.css" rel="stylesheet"/>
<div id="context-menu" style="display: block;">
<ul>
<li><span class="optionText">Long text to show the problem here on the right arrow</span></li>
<li class="submenu"><span class="optionText">Another text</span></li>
<li class="submenu"><span class="optionText">Long text to show the problem here on the right arrow</span>
<ul class="dropdownright">
<li><span class="optionText">Other</span></li>
</ul>
</li>
</ul>
</div>
If you see, if the text is longer than the min-width, it grows on all browsers except IE11, where the arrow goes down to the next line.
How can I make it grow the width automatically ?
Thank you.
Removing the "float: right" in the rule "#context-menu ul > li.submenu::after" seems to be working for me in Internet explorer 11.
I want to add a border to my tab content. There should be no border at the bottom of the selected tab. I found this questions: how to give a border to bootstrap tab contents, but the answers didn't work for me?
HTML:
<ul class="nav nav-tabs pull-right">
<li><a data-toggle="tab" href="#sub_cats_8">תתי קטגוריות</a></li>
<li class="active"><a data-toggle="tab" href="#category_8">קטגוריה</a></li>
</ul>
<div class="clearfix"></div>
<div class="tab-content" style="height: 100%;">
<div id="category_8" class="tab-pane fade in active category" style="background-image: url('example.jpg');">
<h1> קוסמטיקה </h1>
</div>
<div id="sub_cats_8" class="tab-pane fade">
<ul class="sub_categories">
<li>איפור</li>
</ul>
</div>
</div>
CSS:
body, html {
direction: rtl;
height: 100%;
font-family: Tahoma;
}
.nav-tabs {
direction: ltr;
}
#logo {
background-color: #005CB8;
width: 100%;
color: white;
padding: 4% 10%;
-webkit-box-shadow: 20px 10px 20px #003972;
-moz-box-shadow: 20px 10px 20px #003972;
box-shadow: 20px 10px 20px #003972;
border-bottom-left-radius: 50px;
}
#logo h1, #logo h4 {
display: inline;
font-family: head;
}
#logo h1 {
font-size: 550%;
}
#logo h4 {
font-size: 220%;
}
.navbar-inverse {
background-color: #477199;
font-weight: bold;
}
.nav.navbar-nav.navbar-right li a {
color: white;
}
.nav.navbar-nav li a {
color: white;
}
.navbar-inverse .navbar-nav > .active {
background-color: #003972;
}
.navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
color: white;
background: #003972;
}
.navbar-inverse .navbar-nav > li > a:hover, .navbar-inverse .navbar-nav > li > a:focus {
background-color: #324F6B;
color: white;
}
.category {
text-align: center;
margin-top: 1px;
background-size: 100% 100%;
padding: 15% 0;
}
.category h1 {
color: white;
font-family: head;
font-size: 500%;
text-shadow: 2px -2px black;
}
.category_start {
margin: 0 auto;
width: 85%;
}
.sub_categories {
-webkit-columns: auto 3;
/* Chrome, Safari, Opera */
-moz-columns: auto 3;
/* Firefox */
columns: auto 3;
list-style-type: disc;
margin-top: 5px;
}
.category_start .container {
margin-top: 10px;
}
.product_image {
height: 80px;
width: 80px;
}
.products_sub_list {
margin: 10px auto 0;
text-align: center;
max-width: 80%;
border-radius: 7px;
}
.products_sub_list td {
width: 15%;
max-width: 15%;
padding: 0 5px;
border: 3px solid #46617A;
}
.product {
width: 80%;
border: 3px solid #46617A;
margin: 0 auto;
text-align: center;
border-radius: 10px;
}
.product_table td {
border: 2px solid #46617A;
padding: 13px;
}
.product_table {
display: inline-table;
margin-left: 15px;
margin-bottom: 8px;
}
.product_table td:first-child {
font-weight: bold;
}
.page {
width: 85%;
margin: 0 auto;
padding: 15px 25px;
border: 2px solid #46617A;
border-radius: 10px;
background-color: #C8D0D7;
}
.register {
margin: 0 auto;
width: 80%;
text-align: center;
}
.register td {
padding: 5px;
text-align: right;
}
.register table {
margin-right: 240px;
}
#register {
width: 80%;
position: absolute;
z-index: 2;
display: none;
left: 0;
right: 0;
top: 100px;
margin: 0 auto;
border: 3px solid #0066FF;
background-color: #CCE0FF;
text-align:center;
border-radius: 10px;
}
#bbg {
display: none;
position: absolute;
z-index: 1;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: black;
opacity: 0.8;
filter: alpha(opacity=80);
}
.tab-content {
border: 1px solid #ddd;
padding: 1px;
}
JSFiddle: http://jsfiddle.net/ep2drocb/7/
Notice there is border in the open tab, also the closed tabs have a double border.
The main problem is the pull-right on the ul element.
Remove pull-right class from the ul
Remove the clear-fix element as it's not needed anymore
Remove top border from your tab-content class
Float the lis right
Correct the margins on the tab anchors
Relevant HTML:
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#category_8">תתי קטגוריות</a></li>
<li><a data-toggle="tab" href="#sub_cats_8">קטגוריה</a></li>
</ul>
<div class="tab-content">
<div id="category_8" class="tab-pane fade in active category">
<h1> קוסמטיקה </h1>
</div>
<div id="sub_cats_8" class="tab-pane fade">
<ul class="sub_categories">
<li>איפור</li>
</ul>
</div>
</div>
Relevant CSS:
.tab-content {
border: 1px solid #ddd;
border-width: 0 1px 1px; /* Removes the top border */
padding: 1px;
}
.nav-tabs > li {
float: right;
}
.nav-tabs > li > a {
margin-right: 0;
margin-left: 2px;
}
JSFiddle: http://jsfiddle.net/ep2drocb/9/
That should get you on the right track.