-1

I have 2 problems.

here my homepage

1) I want to move the logo image and box to the center. I don't know why it doesn't work... I think I've used everything including align, but it doesn't move. I solved the menus with a flex.

2) I want the borderline of menus and box to be the same size. The overlapping parts have different sizes of lines.

Thank you reading.

<style type="text/css">

.logo {
    display: flex;
    margin: auto;
    padding: 50px;
}

.nav {
    display: flex;   
}

.menu-center {
    display: flex;  
    margin: auto;
}

.menu-item {
    width: 100px;
    height: 30px;
    border: 1px solid gray;
    text-align: center;
    padding: 10px;
    padding-left: 100px;
    padding-right: 100px;
}

a {
    text-decoration: none;
    color: black;
}

.main {
    margin: 0;
    margin-top: 60px; 
}

.box  {
    display: flex; 
    width: 800px;
    height: 500px;
    border: 1px solid gray;
    margin-top: auto;
    text-align: center;

}

    .main_box {
        display: flex;
        width: 750px;
        height: 450px;
        border: 1px solid black;
        padding: 10px;
        margin: auto;

        text-align: center;

    }




   </style>
    <script type="text/javascript" src="js/jquery-1.12.4.js"></script>
    <script type="text/javascript">


    </script>
        </head>
        <body>
            <div class="logo">
                <a href="index.html"><img src="imgs/logo2.png" alt="" /></a>
            </div>
            <div class="nav">
                <div class="menus">
                    <a href="intro.html"><div class="menu-item">About Me</div></a>
                    <div class="menu-item">My Language</div>
                    <div class="menu-item">Photos</div>
                    <div class="menu-item">Login</div>
                </div>
            </div>
            <div class="box">
                <div class="main_box">
                </div>
            </div>
            <div id="footer">
            </div>
        </body>
    </html>

3 Answers3

0

Add the margin auto property to the anchor tag inside div

a {
        text-decoration: none;
        color: black;
        margin: auto;
    }

And also in the box div

.box {
        display: flex;
        width: 800px;
        height: 500px;
        border: 1px solid gray;
        margin-top: auto;
        text-align: center;
        margin: auto;   
    }
Bilal Hussain
  • 572
  • 6
  • 14
0

For the logo, you can use the following option CSS:

.logo{ display: block; width: 100%; text-align: center; }
.logo img{ display: block; margin: auto }

And to avoid borderline menu you can use the following CSS:

.menus { border-bottom: 1px solid gray; }
.menus .menu-item{ border-right: 1px solid gray; }
.menus .menu-item:last-child{ border-right: 0px; }
pratik agashe
  • 111
  • 1
  • 8
0

Another issue you may face is the menu not centering with the buttons side by side as you've drawn. I think you also want to add <display: inline-block> to your menu.item class like so:

.menu-item {
    width: 100px;
    height: 30px;
    border: 1px solid gray;
    text-align: center;
    padding: 10px;
    padding-left: 100px;
    padding-right: 100px;
    display: inline-block;
}

That along with the margin: auto; changes suggested by BILAL should achieve something like this:

Website Image

If you want space between your menu and the box div you can also add margin-top: 10px; to the box div looking something like:

.box  {
    display: flex; 
    width: 800px;
    height: 500px;
    border: 1px solid gray;
    margin-top: auto;
    text-align: center;
    margin: auto;
    margin-top: 10px;

}

Note: Increasing or decreasing 10px to achieve the desired margin.

I realize this was a bit beyond the scope of your question, but this will help you to achieve the style you've drawn.

kevin walker
  • 149
  • 7