Sameer Moin
Sameer Moin

Reputation: 72

How to make div start from top

I create a menu bar and then i create one div for image slider but it was start from below the menu bar. I want this div to start from top of the page i use margin to set it on top but i think margin is not good way, please suggest me another way.

this is my menu bar code

<header>
    <div class="top_nav">
    <div class="logo">
        <a id="site-logo" href="#"><img src="#" alt="ETSSQUARE LOGO"></a>
        </div>
        <div class="contact_details">
            <p>Need Help, Call: +92 445676654 |<a href="#"> Mail</a></p>
        </div>
        <div class="nav_bar">
            <ul>
                <li><a href="#">Services</a></li>
                <li><a href="#">Solution</a></li>
                <li><a href="#">Support</a></li>
                <li><a href="#">Partners</a></li>
                <li><a href="#">Contacts</a></li>
            </ul>
        </div>
    </div>
</header>

menu bar css

.nav_bar{
    margin-left: 700px;
    margin-top: 45px;
    position: absolute;
}

.nav_bar ul{
    list-style-type: none;
}

.nav_bar ul li{
    display: inline-block;
    text-align: center;
    float: left;
}

.nav_bar ul li a{
    text-decoration: none;
    padding: 12px;
    margin: 8px;
    font-size: 20px;
    color: #fff;
    position: relative;
}

.nav_bar ul li a::after{
    content: '';
    display: inline-block;
    position:absolute;
    width: 0px;
    height: 4px;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    background: #ff6600;
    transition: width .4s;
}

.nav_bar ul li a:hover::after{
    content: '';
    display: inline-block;
    position:absolute;
    width: 0px;
    height: 4px;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    background: #ff6600;
    width: 100%;
}

i want this div to start from top of page

<div id="container">

</div>

css

#container{
    width: 100%;
    height: 704px;
    overflow: hidden;
    background: #ff00ff;
}

Upvotes: 2

Views: 6159

Answers (1)

Sasith
Sasith

Reputation: 790

You can fixed your navigation and then your #container will start from top.

.nav_bar {
    position: fixed;
    right: 0;
    left: 0;
    top: 0;
    z-index:999;
}

Hope this will help you.

Upvotes: 1

Related Questions