Cannot change the current background-image of the navbar - css

I'm currently working on a project that uses angular framework. I want to achieve a similar design like this. Like this one
So here's my code for the navbar component:
<div *ngIf="!isMobile">
<nav *ngIf="nav.visible">
<div class="d-flex justify-content-around align-items-center flex-wrap my-2">
<div class="p-2">
<img src="https://i.imgur.com/2diJpU5.png" width="50px" />
</div>
</div>
<nav class="navbar navbar-expand-md">
<ul class="navbar-nav">
<li class="nav-item">
<a routerLink="/home" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">Home</a>
</li>
<li class="nav-item">
<a routerLink="/shop" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}">Shop All</a>
</li>
<li class="nav-item dropdown">
<a href="#" id="dropdown" data-toggle="dropdown">
Accessories
</a>
<div class="dropdown-menu shadow-sm">
<a class="dropdown-item" routerLink="/shop/category/Necklaces">Necklaces</a>
<a class="dropdown-item" routerLink="/shop/category/Bracelets-Anklets">Bracelets and Anklets</a>
<a class="dropdown-item" routerLink="/shop/category/Earrings">Earrings</a>
<a class="dropdown-item" routerLink="/shop/category/Rings">Rings</a>
</div>
</li>
<li class="nav-item">
<a routerLink="/about-us" routerLinkActive="active">About Us</a>
</li>
</ul>
<div>
<a>
<button class="btn-2 mr-2" routerLink="/cart">
<svg xmlns="http://www.w3.org/1200/svg" width="16" height="16" fill="currentColor" class="bi bi-bag"
viewBox="0 0 16 16">
<path
d="M8 1a2.5 2.5 0 0 1 2.5 2.5V4h-5v-.5A2.5 2.5 0 0 1 8 1zm3.5 3v-.5a3.5 3.5 0 1 0-7 0V4H1v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4h-3.5zM2 5h12v9a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V5z" />
</svg>
</button>
</a>
</div>
</nav>
</nav>
</div>
And the css component of the navbar:
.dropdown-menu::before {
display: block;
content: "";
width: 100%;
height: 10px;
position: absolute;
top: -10px;
left: 0;
}
.navbar {
padding: 1vh 0;
transition: 0.1s all ease-in;
border: none;
text-decoration: none;
text-align: center;
background-color: transparent;
}
.navbar a {
font-size: 13px;
text-decoration: none;
color: #fff;
text-transform: uppercase;
letter-spacing: 0.75px;
margin: 0 2vw;
}
.navbar a:hover {
color: rgb(221, 221, 221);
}
.active {
color: rgb(221, 221, 221) !important;
}
.navbar-toggler {
color: #ffffff;
}
.btn-2 {
background-color: transparent;
border-color: transparent;
}
.dropdown {
position: static;
transition: 1s all ease-in-out;
}
.dropdown-menu {
transition: 1s all ease-in-out;
display: none;
text-align: center;
border: 0;
border-radius: 0;
width: 100%;
margin-top: 0;
}
.dropdown:hover>.dropdown-menu {
display: block;
padding: 25px 300px;
height: auto;
width: 100%;
position: absolute;
}
.dropdown-menu a {
color: #000;
margin: 0;
padding: 5px 0;
width: auto;
}
.dropdown-menu a:hover {
display: block;
transition: .2s all ease-in-out;
background: none;
color: #c1ae8d;
}
ul {
margin: 0 auto;
align-items: center;
list-style-type: none;
}
.subtitle {
font-size: 12px;
text-transform: uppercase;
letter-spacing: 0.75px;
}
.navbar-toggler:hover,
.navbar-toggler:active,
.navbar-toggler:focus {
background-color: transparent;
border-color: transparent;
}
.btn-2:hover,
.btn-2:active,
.btn-2:focus {
background-color: transparent;
border-color: transparent;
}
.btn-2 {
color: #ffffff;
}
#media (max-width: 768px) {
.navbar {
background-color: #ffffff;
}
.dropdown:hover>.dropdown-menu {
display: block;
padding: 0 0 10px 0;
text-align: center;
height: auto;
width: 100%;
position: absolute;
visibility: visible;
}
.navbar-toggler,
.btn-2 {
color: black;
}
.navbar a {
color: #c1ae8d;
}
.mobile-active {
color: #a08e6e;
}
.dropdown-menu {
text-align: center;
border-color: transparent;
}
.dropdown-menu li {
text-align: center;
}
}
Here is my current situation with the project:
I tried setting the background-color of the navbar component to transparent but it just doesn't work. How can I achieve this? Thank you!
*UPDATE - Yeah, it looks like this now after changes. It gave the navbar a separate background image instead of going in to the big section.

Try to add
:host { background-color: transparent; } attribute in Navbar css file.

Related

How to style navbar for profile section

I currently have an angular app that has a nav bar made up of a tags, now when the player logs in i have an ngIf for a my profile icon to show with dropdowns but I cant get it styled correctly, I just want sort of that spanner icon on the top right of the nav bar and when clicked it shows options. This is what I have so far:
<div class="page-links responsive" [ngClass]="{'animate': shouldShow}">
<a [routerLink]="''"
[routerLinkActive]="'active'"
[routerLinkActiveOptions]="{exact: true}"
draggable="false"
(click)="toggleMenu()">
Home
</a>
<a [routerLink]="'/university'"
[routerLinkActive]="'active'"
draggable="false"
(click)="toggleMenu()">
University Cup
</a>
<a [routerLink]="'/rules'"
[routerLinkActive]="'active'"
draggable="false"
(click)="toggleMenu()">
The Game
</a>
<a [routerLink]="'/tournaments'"
[routerLinkActive]="'active'"
draggable="false"
(click)="toggleMenu()">
Tournaments
</a>
<a [routerLink]="'/history'"
[routerLinkActive]="'active'"
draggable="false"
(click)="toggleMenu()">
Our Legacy
</a>
<a [routerLink]="'/team'"
[routerLinkActive]="'active'"
draggable="false"
(click)="toggleMenu()">
Our Team
</a>
<a [routerLink]="'/portal'"
[routerLinkActive]="'active'"
draggable="false"
(click)="toggleMenu()">
Player Portal
</a>
<a *ngIf="isAuthed">
<mat-form-field appearance="fill">
<mat-label><mat-icon>accessibility</mat-icon></mat-label>
<mat-select>
<mat-option value="option1">My Profile</mat-option>
<mat-option value="option2">GitHub Instructions</mat-option>
<mat-option value="option3">Download CICD file</mat-option>
<mat-option value="option4">Logout</mat-option>
</mat-select>
</mat-form-field>
</a>
</div>
My css:
.page-links {
#media (max-width: $screen-md-max) {
position: absolute;
top: 80px;
right: 0;
left: 0;
}
a {
display: inline-block;
height: 80px;
line-height: 80px;
padding: 0 8px;
margin: 0 8px;
overflow: hidden;
transition-property: height, border-width, underline, background-color, color;
transition: ease-in-out 350ms;
font-weight: bold;
&, &:active, &:focus, &:visited {
text-decoration: none;
color: white;
}
&:hover {
color: $title;
background-color: rgba(255, 255, 255, 0.1);
}
&.active {
color: $title;
}
}
li {
display: inline-block;
height: 80px;
line-height: 80px;
padding: 0 8px;
margin: 0 8px;
overflow: hidden;
transition-property: height, border-width, underline, background-color, color;
transition: ease-in-out 350ms;
font-weight: bold;
&, &:active, &:focus, &:visited {
text-decoration: none;
color: grey;
}
}
&.responsive {
#media (max-width: $screen-md-max) {
display: inline-block;
width: 100%;
background: $primary-darker;
a {
position: relative;
float: none;
display: block;
text-align: left;
height: 0;
line-height: 50px;
padding: 0 16px;
margin: 0;
border-top: 0 solid white;
}
li {
position: relative;
float: none;
display: block;
text-align: left;
height: 0;
line-height: 50px;
padding: 0 16px;
margin: 0;
border-top: 0 solid white;
}
&.animate {
a {
height: 50px;
border-width: 1px;
}
}
}
}
}
But my code renders like this:
Rendered Code
What can i do to fix this?
Please add two more div's and add independent classes. and format by using the CSS it will work
<div class="left-menu">
<a>Home</a>
<a>University Cup</a>
<a>The Game</a>
<a>Tournaments</a>
<a>Our Legacy </a>
<a>Our Team</a>
<a>Player Portal</a>
</div>
<div class="right-menu">
<a *ngIf="isAuthed">
<mat-form-field></mat-form-field>
</a>
</div>
</div>
<style>
.left-menu{
float: left;
width:80%;
}
.right-menu {
float: left;
width: 20%;
}
</style>

Angular 8 components showing below sidebar instead of being on the side

I have a collapsible sidebar. On click of a link from the sidebar, I want to display the components next to the sidebar but they show below it.
My Component Code:
<app-topbar></app-topbar>
<div class="wrapper">
<app-sidebar></app-sidebar>
</div>
<div class="card" style="width: 18rem;">
<img class="card-img-top" src="assets/bn.jpg" alt="Card image cap">
<div class="card-body">
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
</div>
My Component's CSS:
.navbar{
background-color: #1F85DE;
}
.card{
flex: auto;
}
My Sidebar Component's HTML:
<nav id="sidebar" class="navbar-dark bg-#1F85DE" style="background-color: #1F85DE;" [ngClass]="{'hidden': sideNavService.hideSideNav }">
<hr>
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home Page</a>
<hr>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link2</a>
<hr>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link3</a>
<hr>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Profile</a>
<hr>
</li>
</ul>
</nav>
My Sidebars's CSS:
:host {
background: #343a40;
}
#sidebar {
min-width: 200px;
max-width: 200px;
min-height: 100vh;
color: #fff;
transition: all 0.3s;
font-weight: 300;
font-size: 1rem;
line-height: 1.5;
}
#sidebar.hidden {
margin-left: -200px;
}
a[data-toggle="collapse"] {
position: relative;
}
#media (max-width: 575px) {
#sidebar {
margin-left: -200px;
}
#sidebar.hidden {
margin-left: 0;
}
}
a, a:hover, a:focus {
color: inherit;
}
#sidebar .sidebar-header {
padding: 20px;
}
#sidebar ul li a {
padding: 15px;
display: block;
width: 100%;
&:hover {
background-color: rgba(255, 255, 255, 0.1);
}
}
hr {
border-top: 1px solid #fff;
margin-top: 0;
}
.dropdown-submenu {
position: relative;
}
.dropdown-submenu>.dropdown-menu {
top: 0;
left: 100%;
margin-top: -6px;
margin-left: -1px;
-webkit-border-radius: 0 6px 6px 6px;
-moz-border-radius: 0 6px 6px;
border-radius: 0 6px 6px 6px;
}
.dropdown-submenu:hover>.dropdown-menu {
display: block;
}
.dropdown-submenu>a:after {
display: block;
content: " ";
float: right;
width: 0;
height: 0;
border-color: transparent;
border-style: solid;
border-width: 5px 0 5px 5px;
border-left-color: #ccc;
margin-top: 5px;
margin-right: -10px;
}
.dropdown-submenu:hover>a:after {
border-left-color: #fff;
}
.dropdown-submenu.pull-left {
float: none;
}
.dropdown-submenu.pull-left>.dropdown-menu {
left: -100%;
margin-left: 10px;
-webkit-border-radius: 6px 0 6px 6px;
-moz-border-radius: 6px 0 6px 6px;
border-radius: 6px 0 6px 6px;
}
The code is making my Sidebar appear on the left side but the component that I want to display is not occupying the empty save on the right of the sidebar instead, after the sidebar ends, its occupying the save there.
<ng-sidebar-container>
<ng-sidebar [opened]="opened" position="right" mode="push" autoCollapseWidth=100>
<img src="assets/myimage_compressed.jpg" class="rounded-circle" width=80 height=80/>
<ul class="menu">
<li> <a routerLink="/">Dash Board</a></li>
<li> <a routerLink="/post">Post</a></li>
<li><a routerLink="/contact">Contact</a></li>
</ul>
</ng-sidebar>
<div ng-sidebar-content>
<!-- side page component ,Here i have used main component -->
<app-main></app-main>
</div>
</ng-sidebar-container>

Nav Tab active moment image not change

Im added tab for the image icon , im try to do that when i click the button (active button) after image icon change to be book_hover.png font color is change but image icon not change ,how to replace the image after NavTab active moment
.footer-tab .tooter-nav-tab {
padding: 2rem;
height: 10vh;
width: 100%;
margin-left: 0rem;
background: white;
border-top: 1px solid #c9cfd9;
display: inline;
text-align: center;
}
p.tab-txt {
font-size: 0.7rem;
}
.footer-tab ul {
list-style-type: none;
margin: 0;
padding: 0;
border-top: 1px solid #c9cfd9;
overflow: hidden;
background-color: #ffffff;
}
.footer-tab li {
float: left;
}
.footer-tab .nav-tabs .nav-link.active {
color: white;
background-color: #8bb6f3;
border-color: #ddd #ddd #fff;
}
.footer-tab li a {
display: block;
color: #3f5370;
text-align: center;
padding: 18px 16px;
text-decoration: none;
}
.footer-tab li a:hover {
background-color: #8bb6f3;
color: white;
}
.footer-tab-img :active {
background:url'https://image.ibb.co/ffSy9F/book_hover.png')no-repeat;
color: white;
}
/*footernavtab*/
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<div class="footer-tab">
<ul class="nav nav-tabs" role="tablist">
<li class="img-01 w-25"><a href="" class="nav-link"}}
<span class="footer-tab-img active">
<img src="https://image.ibb.co/mOHJbv/book.png" alt="book" border="0">
</span>
<p class="tab-txt">Book</p>
</a>
</li>
</ul>
</div>
Finally i fixed my issue, im used this class footer-tab-img-01 and added separate color image and code crete like this
`span.footer-tab-img-01 { background: url('/Image/users.png') no-repeat; width: 32px; height: 32px; display: block; margin-left:1.2rem; }
.nav-link.active span.footer-tab-img-01 { background: url('/Image/users-hover.png') no-repeat; width: 32px; height: 32px; display: block; margin-left:1.2rem; }`
<div class="footer-tab">
<ul class="nav nav-tabs" role="tablist">
<li class="img-01 w-25"><a href="" class="nav-link"}}
<span class="footer-tab-img-01">
</span>
<p class="tab-txt">Book</p>
</a>
</li>
</ul>
</div>

css progress bar's tab alignment

originally i have a progress bar/tab of 4 but i decided to add 1 more, but when i added up the code for the fifth 'tab.' it won't align with the other 4 instead it goes below first 'tab.' question is, how can i make the fifth tab aligned/inline with the other four tabs?
original preview
updated preview
here's the html:
<div class="wizard">
<div class="wizard-inner">
<div class="connecting-line"></div>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#step1" data-toggle="tab" aria-controls="step1" role="tab" style="pointer-events: none; cursor: default;">
<span class="round-tab">
<i class="glyphicon glyphicon-folder-open"></i>
</span>
</a>
</li>
<li role="presentation" class="disabled">
<a href="#step2" data-toggle="tab" aria-controls="step2" role="tab" style="pointer-events: none; cursor: default;">
<span class="round-tab">
<i class="glyphicon glyphicon-pencil"></i>
</span>
</a>
</li>
<li role="presentation" class="disabled">
<a href="#step3" data-toggle="tab" aria-controls="step3" role="tab" style="pointer-events: none; cursor: default;">
<span class="round-tab">
<i class="glyphicon glyphicon-picture"></i>
</span>
</a>
</li>
<li role="presentation" class="disabled">
<a href="#step3" data-toggle="tab" aria-controls="step4" role="tab" style="pointer-events: none; cursor: default;">
<span class="round-tab">
<i class="glyphicon glyphicon-picture"></i>
</span>
</a>
</li>
<li role="presentation" class="disabled">
<a href="#complete" data-toggle="tab" aria-controls="complete" role="tab" style="pointer-events: none; cursor: default;">
<span class="round-tab">
<i class="glyphicon glyphicon-ok"></i>
</span>
</a>
</li>
</ul>
</div>
</div>
CSS:
.wizard {
margin: 20px auto;
background: #fff;
width: 90%;
margin-top: -20px;
margin-left: 85px;
}
.wizard .nav-tabs {
position: relative;
margin: 4px auto;
margin-bottom: 0;
border-bottom-color: #e0e0e0;
}
.wizard > div.wizard-inner {
position: relative;
margin-right:90px;
}
.connecting-line {
height: 2px;
background: #e0e0e0;
position: absolute;
width: 100%;
margin: 0 auto;
left: 0;
right: 0;
top: 50%;
z-index: 1;
}
.wizard .nav-tabs > li.active > a, .wizard .nav-tabs > li.active > a:hover, .wizard .nav-tabs > li.active > a:focus {
color: #FFA53E;
cursor: default;
border: 0;
border-bottom-color: transparent;
}
span.round-tab {
width: 70px;
height: 70px;
line-height: 70px;
display: inline-block;
border-radius: 100px;
background: #fff;
border: 2px solid #e0e0e0;
z-index: 2;
position: absolute;
left: 0;
text-align: center;
font-size: 25px;
}
span.round-tab i{
color:#FFA53E;
}
.wizard li.active span.round-tab {
background: #fff;
border: 2px solid #F86D18;
}
.wizard li.active span.round-tab i{
color: #F86D18;
}
span.round-tab:hover {
color: #333;
border: 2px solid #333;
}
.wizard .nav-tabs > li {
width: 25%;
}
.wizard li:after {
content: " ";
position: absolute;
left: 46%;
opacity: 0;
margin: 0 auto;
bottom: 0px;
border: 5px solid transparent;
border-bottom-color: #F86D18;
transition: 0.1s ease-in-out;
}
.wizard li.active:after {
content: " ";
position: absolute;
left: 46%;
opacity: 1;
margin: 0 auto;
margin-right:-10px;
bottom: 0px;
border: 10px solid transparent;
border-bottom-color: #F86D18;
}
.wizard .nav-tabs > li a {
width: 70px;
height: 70px;
margin: 20px auto;
border-radius: 100%;
padding: 0;
}
.wizard .nav-tabs > li a:hover {
background: transparent;
}
.wizard .tab-pane {
position: relative;
padding-top: 50px;
}
.wizard h3 {
margin-top: 0;
}
Your li elements are set to 1/4 of width and you are trying to put 5 elements.
Try:
.wizard .nav-tabs > li {
width: 20%;
}

How to fix case when child items breaks parent boundary?

The problem is that sidebar menu list items breaks parent boundary. How can i fix this, kind of not let childs go beyond parent width?
Working on sliding out from left side navigation site menu.
It looks fine as is, the actual problem happens when i hover over list items.
As you can see list items reveals themself immideately, going beyond parent boundary. This looks awful. I pretty sure the issue can be fixed with css, but unfortunately my knoweledge is not solid at this moment. Could you please help me out with the solution to the issue? Thanks in advance!
This image shows what the correct behaviour should be.
body {
font-family: 'Open Sans', sans-serif;
}
img {
position: relative;
color: #999;
}
#one {
padding: 17px 15px 15px 17px;
}
#two {
padding: 20px 14px 15px 12px;
}
#three {
padding: 15px 17px 15px 15px;
}
#four {
padding: 20px 16px 15px 17px;
}
#five {
padding: 20px 14px 15px 17px;
}
#six {
padding: 17px 14px 15px 14px;
}
nav {
background: #1b1e22;
border-right: 1px solid #e5e5e5;
position: absolute;
top: 0;
bottom: 0;
height: 100%;
left: 0;
width: 60px;
overflow: hidden;
transition: width .5s linear;
}
nav > ul {
margin: 7px 0;
}
nav li {
position: relative;
display: block;
width: 250px;
transition: width .5s linear;
border-bottom: 1px solid #24272a;
}
nav li > a {
height: 60px;
color: #999;
font-size: 14px;
position: relative;
display: table;
border-collapse: collapse;
border-spacing: 0;
padding: 15px 0;
text-decoration: none;
-webkit-transition: all 5s linear;
transition: all 5s linear;
}
nav span {
position: relative;
display: table-cell;
vertical-align: middle;
width: 190px;
}
a:hover,
a:focus {
text-decoration: none;
}
nav {
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
}
nav ul,
nav li {
outline: 0;
margin: 0;
padding: 0;
}
li a:hover {
color: #104E8B;
background-color: #343536;
}
.main-menu:hover,
nav.main-menu.expanded {
width: 250px;
overflow: visible;
}
<body>
<nav class="main-menu">
<ul>
<li>
<a href="#">
<img id="one" src="https://i.imgur.com/RcWtM2a.png" alt="" />
<span class="nav-text">
Строительные проекты
</span>
</a>
</li>
<li class="has-subnav">
<a href="#">
<img id="two" src="https://i.imgur.com/wKDZKMl.png" alt="" />
<span class="nav-text">
Строительные товары
</span>
</a>
</li>
<li class="has-subnav">
<a href="#">
<img id="three" src="https://i.imgur.com/oztvKJ0.png" alt="" />
<span class="nav-text">
Строительные работы
</span>
</a>
</li>
<li class="has-subnav">
<a href="#">
<img id="four" src="https://i.imgur.com/MT1dCFF.png" alt="" />
<span class="nav-text">
Недвижемость
</span>
</a>
</li>
<li>
<a href="#">
<img id="five" src="https://i.imgur.com/uICbjKw.png" alt="" />
<span class="nav-text">
Мебель
</span>
</a>
</li>
<li>
<a href="#">
<img id="six" src="https://i.imgur.com/nHnYpBg.png" alt="" />
<span class="nav-text">
Строител. калькулятор
</span>
</a>
</li>
</ul>
</nav>
</body>
You will have to consider width for the transition and must keep overflow hidden as it is for following class:
.main-menu:hover,
nav.main-menu.expanded {
width: 250px;
transition: width .5s linear;
}
Here is the updated codepen
http://codepen.io/anon/pen/PqbEqj

Resources