Q:

Why this difference occurred? 

I want to make div that appears like navbar in bootstrap's. 
I made two div and collocated in two ways. 
First, I located divOneGray first and then divTwoBlue like,
<div class="container-fluid">
    <div class="row" id="divGray">
        <div class="col-lg-8 col-lg-offset-2" style="background-color: #cccccc; height: 4000px;"></div>
    </div>

    <div class="row" id="divBlue">
        <div class="col-lg-8 col-lg-offset-2" style="background-color: #003366; height: 100px; position: fixed; bottom: 0px;"></div>
    </div>
</div> 

In this case, divBlue appears above divGray,
But Second case,
 <div class="container-fluid">

    <div class="row" id="divBlue">
        <div class="col-lg-8 col-lg-offset-2" style="background-color: #003366; height: 100px; position: fixed; bottom: 0px;"></div>
    </div>
    <div class="row" id="divGray">
        <div class="col-lg-8 col-lg-offset-2" style="background-color: #cccccc; height: 4000px;"></div>
    </div>
</div> 

divGray appears above divBlue. 
Why this happened? 
What is needed to do it like First case without collocating of html code? 
EDIT:
Here is my hoping result: 
https://jsfiddle.net/d6wunt0L/

A:

In your second case, after rendering divBlue you have render divGrey which overlaps the divBlue, so to show the divBlue you need to apply z-index:1 for divBlue whereas in your first case, you are rendering blueDiv after  greyDiv, so you don't find any problem here. 

   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  
 <div class="container-fluid">

    <div class="row" id="divBlue">
        <div class="col-lg-8 col-lg-offset-2" style="background-color: #003366; height: 100px; position: fixed; bottom: 0px;z-index:1;"></div>
    </div>
    <div class="row" id="divGray">
        <div class="col-lg-8 col-lg-offset-2" style="background-color: #cccccc; height: 4000px;"></div>
    </div>
</div> 

A:

Try This:
<div class="container-fluid">

    <div id="divGray">
        <div class="col-lg-6" style="background-color: #cccccc; height: 4000px;"></div>
    </div>

    <div id="divBlue">
        <div class="col-lg-6" style="background-color: #003366; height: 100px; bottom: 0px;"></div>
    </div>

</div> 

