The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Centering links in menu
Legless
post Feb 2 2018, 05:19 AM
Post #1


Newbie
*

Group: Members
Posts: 16
Joined: 6-January 17
Member No.: 26,256



Hi guys,
I'm trying to implement some code I found on w3schools for a responsive menu.

This is the code: https://www.w3schools.com/howto/howto_js_to..._responsive.asp

It appears to work well, but the problem I'm having, is that I can't get the links to be centered across the page.
I've tried removing the float: left / adding divs inside divs with percentages / margin: 0 auto, etc. etc., but I'm getting nowhere.

I wonder if someone could help me sort out this problem?

They have a sort of jsfidddle type page here: https://www.w3schools.com/howto/tryit.asp?f...ryhow_js_topnav

Many thanks. smile.gif


User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
Legless
post Feb 7 2018, 05:42 AM
Post #2


Newbie
*

Group: Members
Posts: 16
Joined: 6-January 17
Member No.: 26,256



This was the fix...

CODE
@media screen and (max-width: 600px) {
    .topnav a:not(:first-child) {
        display: none;
    }
    .topnav a {
        float:left;
    }    
    .topnav a.icon {
        float: right;
        display: block;
    }
}
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 21st March 2019 - 12:20 AM