Full Page Intro with fixed, transparent Navbar when scroll w


Topic: Full Page Intro with fixed, transparent Navbar when scroll wont change color

kevin cactus asked 7 years ago

Hi, i just download mdbootstrap basic template then i start trying to code a navbar, and trying to create fullpage intro with fixed, transparent navbar and then when scroll added a blue color just like example in mdbootstrap documentation, i simply copy and paste the code just like below :

app.component.css :

.view {
    background: url("https://mdbootstrap.com/img/Photos/Others/img (40).jpg")no-repeat center center;
    background-size: cover;
}    
.navbar {
    background-color: transparent;
}
.top-nav-collapse {
    background-color: #4285F4;
}
@media only screen and (max-width: 768px) {
    .navbar {
        background-color: #4285F4;
    }
}

and here is my app.component.html :

i can't post HTML code, i just post the link then https://mdbootstrap.com/angular/layout/navigation/#i-f-t-n
thats exactly HTML i use, i do not change a bit of it, just simply copy and paste there to the getting started project

When i scroll down the navbar is shrink and when i scroll up the navbar getting bigger just like example but it wont added a color, still transparent, in mdbootstrap example the color is changed to blue, how can i fix this?


This file should not be renamed. It should still be app.cpomponent.css and your styles should go to styles.scss. Please apply those and let me know how it works now.

kevin cactus commented 7 years ago

oohh thanks, its working, i should put the code in the global style which is in root application, styles.scss. thanks, you solved my question

Tolulope commented 7 years ago

How can I do this exact layout when my nav bar is a different component?

Damian Gemza staff answered 7 years ago

Dear Castillo, You have to put your's code:

.top-nav-collapse { background-color: #4285F4; } in global stylesheet called 'styles.scss' in root/app directory of your's project. Please let me know if this solution works for you. If not, we'll try to handle it in other way. Best Regards, Damian


CareerGraph pro premium priority commented 5 years ago

M having a same issue. On Angular MDB. Tired all these above steps using CSS which are not working..


Hi, please try and put those styles in styles.scss file. There should not be app.cpomponent.css file in the package as mdb-angular is using scss not css.

kevin cactus commented 7 years ago

already rename the file but the bar still wont change the color when scroll down, after all i get the project from mdbootstrap official getting started package, i am running on windows 8.1 OS, here is my version list : @angular/cli: 1.2.6 node: 6.9.1 os: win32 x64 @angular/animations: 4.3.6 @angular/common: 4.3.6 @angular/compiler: 4.3.6 @angular/core: 4.3.6 @angular/forms: 4.3.6 @angular/http: 4.3.6 @angular/platform-browser: 4.3.6 @angular/platform-browser-dynamic: 4.3.6 @angular/router: 4.3.6 @angular/cli: 1.2.6 @angular/compiler-cli: 4.4.2 can be the version of cli or node that not compatile? that strange lol, or can you send me the working one?

Castillo pro answered 7 years ago

I have the same problem, below I leave my code. app.component.css
.view {
background: url("../assets/img/gallery/arches.jpg")no-repeatcentercenter;
background-size: cover;
}
.navbar {
background-color: transparent;
}
.top-nav-collapse {
background-color: #4285F4;
}
@media only screen and (max-width: 768px) {
.navbar {
background-color: #4285F4;
}
}
app.component.html
<header>
<mdb-navbarSideClass="navbar fixed-top navbar-expand-lg navbar-dark scrolling-navbar" [containerInside]="false">
<logo>
<aclass="logo navbar-brand"href="#">
<imgsrc="../assets/img/logo.png"height="50"alt="National Parks Guide">
<span><strong>Nacional Parks Guide</strong></span>
</a>
</logo>
<!-- Links -->
<links>
<ulclass="navbar-nav nav-flex-icons ml-auto">
<liclass="nav-item active">
<aclass="nav-link waves-light"mdbRippleRadius>Home<spanclass="sr-only">(current)</span></a>
</li>
<liclass="nav-item">
<aclass="nav-link waves-light"mdbRippleRadius>Gallery</a>
</li>
<liclass="nav-item">
<aclass="nav-link waves-light" (click)="test.toggle()"mdbRippleRadius>About us</a>
</li>
<liclass="nav-item">
<aclass="nav-link waves-light"mdbRippleRadius>Contact</a>
</li>
</ul>
</links>
<!-- Links -->
</mdb-navbar>
<!-- Main -->
<divclass="view intro hm-purple-light"style="">
<divclass="full-bg-img flex-center">
<divclass="container text-center white-text wow fadeInUp">
<h2>Choose the perfect park for you and your family</h2>
<br>
<h5>In this guide you can find tens of national parks and natural reserve whatever your holiday destination</h5>
<p>Navbar's background will switch from transparent to solid color while scrolling down</p>
<br>
<p>Full page intro with background image will be always displayed in full screen mode, regardless of device </p>
</div>
</div>
</div>
<!-- /.Main -->
</header>
<!--Main Navigation-->

Bartosz Termena staff answered 5 years ago

Dear @CareerGraph

Could you show me your code? Below is my example, and everything works as it should:

styles.scss

.view {
  background: url('https://mdbootstrap.com/img/Photos/Others/img (40).jpg') no-repeat center center;
  background-size: cover;
  height: 100vh;
}

.navbar {
  background-color: transparent;
}

.top-nav-collapse {
  background-color: #4285f4;
}

@media only screen and (max-width: 768px) {
  .navbar {
    background-color: #4285f4;
  }
}

HTML

<header class="h-100">
  <mdb-navbar
    SideClass="navbar top-nav-collapse fixed-top navbar-expand-lg navbar-dark scrolling-navbar intro-fixed-nav"
    [containerInside]="false"
  >
    <mdb-navbar-brand>
      <a class="logo navbar-brand" href="#">
        <strong>Navbar</strong>
      </a>
    </mdb-navbar-brand>
    <links>
      <ul class="navbar-nav mr-auto">
        <li class="nav-item active waves-light" mdbWavesEffect>
          <a class="nav-link"
            >Home
            <span class="sr-only">(current)</span>
          </a>
        </li>
        <li class="nav-item waves-light" mdbWavesEffect>
          <a class="nav-link">Link</a>
        </li>
        <li class="nav-item waves-light" mdbWavesEffect>
          <a class="nav-link">Profile</a>
        </li>
      </ul>
    </links>
  </mdb-navbar>
  <!-- Main -->
  <div class="view intro-2" style="">
    <div class="full-bg-img">
      <div class="mask rgba-purple-light flex-center">
        <div class="container text-center white-text wow fadeInUp">
          <h2>This Navbar is fixed and transparent</h2>
          <br />
          <h5>It will always stay visible on the top, even when you scroll down</h5>
          <p>
            Navbar's background will switch from transparent to solid color while scrolling down
          </p>
          <br />
          <p>
            Full page intro with background image will be always displayed in full screen mode,
            regardless of device
          </p>
        </div>
      </div>
    </div>
  </div>
  <!-- /.Main -->
</header>
<!--Main Navigation-->

<!--Main Layout-->
<main class="text-center py-5">
  <div class="container">
    <div class="row">
      <div class="col-md-12">
        <p align="justify">
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
          ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation
          ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
          reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
          sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id
          est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
          tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
          exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
          dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
          Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
          anim id est laborum.
        </p>
      </div>
    </div>
  </div>
</main>
<!--Main Layout-->

Best Regards, Bartosz.


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue
  • User: Free
  • Premium support: No
  • Technology: MDB Angular
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: Yes