Icons instead of toggle menu in mobile version
-
Hi,
is there a way to show a few icons (font awesome) in a row on smaller resolutions?
Take a look at my blog – https://jackgraal.com/en
When you resize the browser window to a mobile device size, the top menu changes to show only a toggle menu button and search button.
I’d like to show menu items in the same way I have them on the fullscreen version on the blog, but without the captions so it looks like on this website https://zombiesamurai.pl (resize it to mobile size).
Thanks in advance ??
-
Hi Jack. There’s always a way…;-) Question is how much time and effort do you want to put into it. A couple of thoughts just off the top of my head:
1. Create a new container with an unordered list of just the icons and drop it into header.php; use css media queries to determine when it is and isn’t displayed.
2. Change/override the existing media queries to keep the top menu visible until a smaller size; use a new media query to hide the menu text at a specific point.Most of the changes I do by myself, but sometimes I just don’t know where to look for the piece of the code that needs to be edited. I end up doing one thing for hours and refreshing after every minor change.
But when I know what needs to be worked on – it’s much easier.
If you could just point me into the right direction – which themes files and what part of the code concerns the things I’d like to play with ??
Thanks ??
Well, turns out #2 was fairly easy. I created a couple of media queries with a break point of 1200px so you could see the result before the menu bar collapses at 960px. Give it a try and let me know what you think.
@media only screen and (min-width: 1200px) { #nav-topbar .nav li a span.fontawesome-text { display: inline; } } @media only screen and (max-width: 1199px) { #nav-topbar .nav li a span.fontawesome-text { display: none; } }
Yeah, it works fine.
Now I need to disable the toggle menu on smaller resolutions
It has to be something within the code below (inside styles.css). I tried a few things but I couldn’t make it work
/* common : nav /* ------------------------------------ */ .nav-container { background: #888; z-index: 99; position: relative; } .nav-toggle { display: none; background: #777; cursor: pointer; float: right; height: 50px; width: 60px; color: #fff; text-align: center; } .nav-toggle i { font-size: 29px; padding: 10px 0; } .nav-text { display: none; float: right; font-size: 16px; line-height: 24px; padding: 13px 20px; } .nav li > a:after, .nav > li > a:after { font-family: FontAwesome; display: inline-block; } @media only screen and (min-width: 480px) { .nav-wrap { height: auto!important; } /* common */ .nav { font-size: 0; position: relative; } .nav li a { color: #ccc; display: block; line-height: 20px; } /* dropdown arrows */ .nav li > a:after { content: "\f0da"; float: right; opacity: 0.5; } .nav > li > a:after {content: "\f0d7"; float: none; margin-left: 6px; font-size: 14px; line-height: 1.2em; } .nav li > a:only-child:after {content: ""; margin: 0; } #footer .nav li > a:after { content: "\f0da"; } #footer .nav > li > a:after { content: "\f0d8"; } #footer .nav li > a:only-child:after { content: ""; } /* level 1 */ .nav > li { font-size: 16px; border-right: 1px solid #999; display: inline-block; position: relative; } .nav > li > a { padding: 15px 14px; } .nav > li > a:hover, .nav > li:hover > a { background: #777; } .nav li > a:hover, .nav li:hover > a, .nav li.current_page_item > a, .nav li.current-menu-item > a, .nav li.current-menu-ancestor > a, .nav li.current-post-parent > a { color: #fff; } /* level 2 & 3 */ .nav li:hover > ul { display: block; } .nav ul { display: none; background: #777; position: absolute; left: 0; top: 50px; width: 180px; padding: 10px 0; z-index: 2; -webkit-transform: translateZ(0); -webkit-box-shadow: 0 2px 2px rgba(0,0,0,0.15); box-shadow: 0 2px 2px rgba(0,0,0,0.15); } .nav ul li { font-size: 14px; position: relative; display: block; padding: 0; } .nav ul li a { padding: 10px 20px; } .nav ul li:last-child { border-bottom: 0!important; } /* level 3 */ .nav ul ul { position: absolute; top: -10px; left: 180px; } } @media only screen and (max-width: 479px) { .nav { font-weight: 400; } .nav-container { text-transform: none; } .nav-toggle, .nav-text { display: block; } .nav-wrap { position: relative; float: left; width: 100%; height: 0; overflow: hidden; } .nav-wrap.transition { -webkit-transition: height 0.35s ease; -moz-transition: height 0.35s ease; -o-transition: height 0.35s ease; transition: height 0.35s ease; } .expand .nav-wrap { height: auto; } /* common */ .nav { float: left; width: 100%; } .nav li a { line-height: 20px; display: block; padding: 8px 20px; } .nav li li a { padding-left: 15px; padding-right: 15px; } /* dropdown arrows */ .nav li > a:after { content: '\f0d7'; opacity: 0.5; margin-left: 6px; } .nav > li > a:after { content: '\f0d7'; font-size: 14px; } .nav li > a:only-child:after { content: ''; } /* level 1 */ .nav > li { font-size: 15px; } .nav li > a:hover, .nav li.current_page_item > a, .nav li.current-menu-item > a, .nav li.current-post-parent > a { color: #fff; } /* level 2 & 3 */ .nav ul { display: block!important; margin-left: 40px; } .nav ul li { font-size: 13px; font-weight: 300; } .nav ul li a { padding-top: 6px; padding-bottom: 6px; } } /* ------------------------------------------------------------------------- * * Section: Header /* ------------------------------------------------------------------------- */ #header { background: #33363b; position: relative; padding-bottom: 60px; } #header .pad { padding-top: 30px; padding-bottom: 30px; } #header .container-inner { position: relative; } .site-title { font-size: 42px; font-weight: 600; letter-spacing: -0.5px; float: left; line-height: 60px; padding: 10px 0; } .site-title a { display: block; color: #fff; max-width: 100%; } .site-title a img { display: block; max-width: 100%; max-height: 60px; height: auto; padding: 0; margin: 0 auto; -webkit-border-radius: 0; border-radius: 0; } .site-description { font-size: 16px; font-style: italic; color: #fff; color: rgba(255,255,255,0.5); float: left; margin-left: 20px; line-height: 60px; padding: 10px 0; } .site-image { display: block; margin: 0 auto; max-height: 400px; } /* header : search /* ------------------------------------ */ .toggle-search { color: #fff; font-size: 18px; line-height: 24px; cursor: pointer; padding: 13px 20px; display: block; position: absolute; right: 0; top: -50px; -webkit-box-shadow: -1px 0 0 rgba(255,255,255,0.1); box-shadow: -1px 0 0 rgba(255,255,255,0.1); } .toggle-search:hover, .toggle-search.active { background: rgba(0,0,0,0.15); color: #fff; } .search-expand { display: none; background: #26272b; position: absolute; top: 0; right: 0; width: 340px; -webkit-box-shadow: 0 1px 0 rgba(255,255,255,0.1); box-shadow: 0 1px 0 rgba(255,255,255,0.1); } .search-expand-inner { background: rgba(0,0,0,0.15); padding: 15px; } .search-expand .themeform input { width: 100%; border: 2px solid #e2e2e2; border-radius: 0; } .search-expand .themeform input:focus { } /* header : nav topbar /* ------------------------------------ */ #nav-topbar.nav-container { background: #26272b; -webkit-box-shadow: 0 0 5px rgba(0,0,0,0.2),0 1px 0 rgba(255,255,255,0.15); box-shadow: 0 0 5px rgba(0,0,0,0.2),0 1px 0 rgba(255,255,255,0.15); } #nav-topbar .nav-toggle { background: transparent; color: #fff; -webkit-box-shadow: inset 1px 0 0 rgba(255,255,255,0.06); box-shadow: inset 1px 0 0 rgba(255,255,255,0.06); } #nav-topbar .nav-text { color: #fff; color: rgba(255,255,255,0.7); } @media only screen and (min-width: 960px) { /* fixed nav */ .full-width.topbar-enabled #header { padding-top: 50px; } .full-width #nav-topbar.nav-container { position: fixed; top: 0; left: 0; right: 0; width: 100%; z-index: 999; } .full-width.admin-bar #nav-topbar.nav-container { top: 32px; } } @media only screen and (min-width: 480px) { /* common */ #nav-topbar .container { padding-left: 15px; } #nav-topbar .nav { } #nav-topbar .nav li a { color: #fff; color: rgba(255,255,255,0.7); } /* level 1 */ #nav-topbar .nav > li { border-right: none; } #nav-topbar .nav > li > a:hover, #nav-topbar .nav > li:hover > a { background-color: rgba(0,0,0,0.1); } #nav-topbar .nav li > a:hover, #nav-topbar .nav li:hover > a, #nav-topbar .nav li.current_page_item > a, #nav-topbar .nav li.current-menu-item > a, #nav-topbar .nav li.current-menu-ancestor > a, #nav-topbar .nav li.current-post-parent > a { color: #fff; } /* level 2 & 3 */ #nav-topbar .nav ul { background: #26272b url(img/opacity-10.png) repeat; } #nav-topbar .nav ul li { box-shadow: 0 1px 0 rgba(255,255,255,0.06); -webkit-box-shadow: 0 1px 0 rgba(255,255,255,0.06); } #nav-topbar .nav ul li:last-child { box-shadow: none; -webkit-box-shadow: none; } } @media only screen and (max-width: 479px) { /* common */ #nav-topbar .container { padding-left: 0; } #nav-topbar .nav li a { color: #fff; color: rgba(255,255,255,0.8); border-top: 1px solid rgba(255,255,255,0.06); } /* level 1 */ #nav-topbar .nav li > a:hover { background: rgba(0,0,0,0.15); color: #fff; } #nav-topbar .nav li.current_page_item > a, #nav-topbar .nav li.current-menu-item > a, #nav-topbar .nav li.current-post-parent > a { background: rgba(0,0,0,0.15); color: #fff; } } /* header : nav header /* ------------------------------------ */ #nav-header.nav-container { background: transparent; z-index: 97; -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 -1px 0 rgba(0,0,0,0.2), inset 1px 0 0 rgba(0,0,0,0.2), inset -1px 0 0 rgba(0,0,0,0.2); box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 -1px 0 rgba(0,0,0,0.2), inset 1px 0 0 rgba(0,0,0,0.2), inset -1px 0 0 rgba(0,0,0,0.2); } #nav-header .container { padding: 0 15px; } #nav-header .nav-toggle { background: transparent; color: #fff; -webkit-box-shadow: inset 1px 0 0 rgba(255,255,255,0.05), -1px 0 0 rgba(0,0,0,0.2); box-shadow: inset 1px 0 0 rgba(255,255,255,0.05), -1px 0 0 rgba(0,0,0,0.2); } #nav-header .nav-text { color: #fff; color: rgba(255,255,255,0.7); } @media only screen and (min-width: 480px) { /* common */ #nav-header .nav { } #nav-header .nav li a { color: #fff; color: rgba(255,255,255,0.7); } /* level 1 */ #nav-header .nav > li { border-right: none; } #nav-header .nav > li > a:hover, #nav-header .nav > li:hover > a { background: rgba(0,0,0,0.1); } #nav-header .nav li > a:hover, #nav-header .nav li:hover > a, #nav-header .nav li.current_page_item > a, #nav-header .nav li.current-menu-item > a, #nav-header .nav li.current-menu-ancestor > a, #nav-header .nav li.current-post-parent > a { color: #fff; } /* level 2 & 3 */ #nav-header .nav ul { background: #33363b url(img/opacity-10.png) repeat; } #nav-header .nav ul li { box-shadow: 0 1px 0 rgba(255,255,255,0.06); -webkit-box-shadow: 0 1px 0 rgba(255,255,255,0.06); } #nav-header .nav ul li:last-child { box-shadow: none; -webkit-box-shadow: none; } } @media only screen and (max-width: 479px) { /* common */ #nav-header.nav-container { border-left: 0; border-right: 0; } #nav-header .container { padding: 0; } #nav-header .nav { padding-bottom: 20px; } #nav-header .nav li a { color: #fff; color: rgba(255,255,255,0.8); border-top: 1px solid rgba(255,255,255,0.06); } /* level 1 */ #nav-header .nav li > a:hover { background: rgba(0,0,0,0.15); color: #fff; } #nav-header .nav li.current_page_item > a, #nav-header .nav li.current-menu-item > a, #nav-header .nav li.current-post-parent > a { background: rgba(0,0,0,0.15); color: #fff; } }
I found this in the wp-minify-fix plugin cache css file. It’s not part of the default theme css so not sure where it originated. I changed the 819px to 500px and it changed the menu collapse point.
@media only screen and (max-width: 819px){ .nav{font-weight:400} .nav-container{text-transform:none} .nav-toggle,.nav-text{display:block} .nav-wrap{position:relative;float:left;width:100%;height:0;overflow:hidden} .nav-wrap.transition{-webkit-transition:height 0.35s ease;-moz-transition:height 0.35s ease;-o-transition:height 0.35s ease;transition:height 0.35s ease} .expand .nav-wrap{height:auto} .nav{float:left;width:100%} .nav li a{line-height:20px;display:block;padding:8px 20px} .nav li li a{padding-left:15px;padding-right:15px} .nav li>a:after{content:'\f0d7';opacity:0.5;margin-left:6px} .nav>li>a:after{content:'\f0d7';font-size:14px} .nav li>a:only-child:after{content:''} .nav>li{font-size:15px} .nav li > a:hover, .nav li.current_page_item > a, .nav li.current-menu-item > a, .nav li.current-post-parent>a{color:#fff} .nav ul{display:block!important;margin-left:40px} .nav ul li{font-size:13px;font-weight:300} .nav ul li a{padding-top:6px;padding-bottom:6px}}
- The topic ‘Icons instead of toggle menu in mobile version’ is closed to new replies.