Question: Imagine I'm building a blog system where a user can upload images for a blog post. I have a problem mapping the uploaded images with user and their blog post.

Here's the flow :

1. User uploaded some pictures, it's saved to the server.
2. I store the image name in the related table, means later I can
retrieve images by blog's post\_id.

But what if the user upload images that has the same file name?

Answer: 
You can do the fading with just css transitions all you need to do is use jquery toggleClass function when the window reaches 150px.

Try the following: 

```
$(window).on( "scroll", function() {
   $('#secondNav').toggleClass('scrolled', $(this).scrollTop() > 150);
});

```

and the css 

```
#secondNav.navbar-default{
  background: #000;
  transition: background-color 0.5s ease;
}
#secondNav.scrolled {
  background: rgba(0,0,0,0.5);
}

```

The transition property is what will give you the fade in and out and then you can change the background of the navbar-default to whatever you want it to be. When it reaches 150px it will toggle the scrolled class and change the background.
I have a difficult solution. You can create two `navbar`. second `nav` should be hidden. when you `scroll` more than `150px`, then it should be `fade in` with fixed position. Below my jQuery code is 

```
$(window).scroll(function(){
    var scrolled = $(window).scrollTop();
    if(scrolled>149){
       $('#second_nav').fadeIn();
    }
    else{
        $('#second_nav').fadeOut();
    }
});

```

Below the code is first nav.

```
<nav class="navbar navbar-default">

```

And below the code is second nav.

```
<nav class="navbar navbar-default navbar-fixed-top" id="second_nav">

```

Check my live demo on [jsfiddle](https://jsfiddle.net/sarowerj/64s99gad/)