• Resolved tcdesigner

    (@tcdesigner)


    Ok, this may sound like a dumb question but ive been up for many hours and apparently im not seeing something lol. Im trying my dardest to center this floating menu im working on coding but i cant get it to center. I currently have it set for right, but ive decided i want it centered. Please help!

    #floating_menu {
    position:fixed;
    background:#fff4c8;
    border:1px solid #ffcc00;
    width:200px;
    top:10%;
    right:0px;
    z-index:100;
    }
    #floating_menu a, #floating_menu h3, #floating_menu img, #floating_menu p {
    
    margin:auto;
    }
Viewing 10 replies - 1 through 10 (of 10 total)
  • Since you have a width value, you should be able to add margins:

    margin-left: auto;
    margin-right: auto;

    What’s the website URL and the part you are trying to center, and I’ll play around with the code if that doesn’t work.

    Thread Starter tcdesigner

    (@tcdesigner)

    Hmm didn’t work. The website URL is https://torquegraphix.com/ It is simply the bar on the left that says ABCD. Very basic starts but im more worried about functionality right now lol. Thanks

    No worries, even Einstein had to learn how to read and write first! (although I think he was absent the day they taught the whole “i before e” thing… he’s got it wrong twice in his name).

    Anyways, so you want to center this horizontally in the middle of the page?

    How about just adding:

    left: 50%; or whatever value aligns it close to where you want it.

    Thread Starter tcdesigner

    (@tcdesigner)

    Hmm i assume that will work the same, centering it is a little simpler but that will do just fine. Thanks!

    Thread Starter tcdesigner

    (@tcdesigner)

    Wait, now i remember why i wanted to center it, thats because im wanting to do a full page floating menu……….one that stretches across the whole browser, and repeats an image as the browser window gets bigger. Like this website https://www.foxhead.com

    Yeah, that’s pretty cool. Okay, I’ll go test it some more.

    Why don’t you make the menu, and then use the left property to set the indentation. Are you making a theme… or just getting this to work on your site?

    Thread Starter tcdesigner

    (@tcdesigner)

    Well actually im working on making a floating menu similar to the one in the link, except on mine its just going to cover up the logo and other content. I took this same theme and started on making the actual menu float but it got way to complicated, i got close though https://www.torquegraphix.com/store

    Also i noticed using the left indention method doesnt always center the menu to the whole website.

    To make it like the menu at foxhead.com (full width and fixed at the top of the browser):

    #floating_menu {
        position: fixed;
        background: #fff4c8;
        border:1px solid #ffcc00;
        width: 100%;
        top: 0;
        z-index: 100;
        height: 20px;
    }

    Make sure to change the height to whatever you want.

    Might be good to then push the rest of the site down so nothing is permanently hidden behind the menu:

    #header {
        margin-top: 20px; /* Should match or be greater than the height rule above */
    }

    If you don’t want it to be the full page width, declare your desired width then add what Josh suggested but with an extra margin-left to get it perfectly centered:

    #floating_menu {
        width: 200px;
        left: 50%;
        margin-left: -100px; /* Half the width */
        /* ... The rest of the rules ... */
    }
    Thread Starter tcdesigner

    (@tcdesigner)

    You sir are a life saver! I appreciate everyone’s help! Thanks

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How to center this code?’ is closed to new replies.