0

I have the below code and I want the div1 to be above div2. I have tried to do it with css as seen below but I can't get it right and the divs appear next to each other. Since i have both of them to be full width:100%; and float:right; shouldn't they be below each other?

Also, I read about clear:both; that it should do the trick but it did not!

Any thoughts on this?

Thank you

EDIT: I am using Bootstrap 4.0.0.

<body>
    <header>
        <div class="container">
            <nav class="navbar navbar-expand-lg navbar-light top">
                <img src="images.png" alt="image" class="imageClass">
                <div class="div1 ">
                    <a href="#" id="id1">somthinghere</a>
                    <a href="#" class="active">link</a>
                    <a href="#" class="">link2</a>
                </div>
                <div class="collapse navbar-collapse div2" id="navbarsExampleDefault">
                    <ul class="navbar-nav ml-lg">
                        <li class="nav-item">
                            <a class="nav-link" href="#">link1</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">link11</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">link111</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">link1111</a>
                        </li>
                    </ul>                       
                </div>
            </nav>
        </div>
    </header>
</body>

CSS:

header{
    position:absolute;
    z-index: 10;
    width: 100%;
}

.div2{
    clear:both;
    width: 100%;
    float:right;        
}

.div1{
    width: 100%; 
    float:right;
}

Image

noel293
  • 514
  • 5
  • 21

1 Answers1

1

Use a .row div combined with .col

Demo: http://jsfiddle.net/dx5nL1hy/2/

Soufiane Hassou
  • 17,257
  • 2
  • 39
  • 75