Split wordpress sub-menu into two columns - html

I tried some code snippets to split wordpress sub-menu into two colums and I got some success. But they are not fully splitted. There is white space beneath odd menu-items and white-space above even menu-items. Link for Menu
In the above web page, Menu --> Nawishta Prime Time --> Season 2
It seems the menu-items are not in line and creating white gaps. Following is the CSS code I used:
.sub-menu-columns ul.sub-menu li {
clear: initial;
display: inline-block;
float: left;
width: 50%;
}
.sub-menu-columns ul.sub-menu li:nth-child(odd) {
float: left;
margin-right: 300px;
}
.sub-menu-columns ul.sub-menu li:nth-child(even) {
float: right;
}
I applied this class "sub-menu-columns" on the menu item "Season 2" in wordpress menu settings.
What I need is to remove gaps like:

There is not enough space for your elements to be next to each other. With using margin you are taking up the space, so it breakes to the next line.
Please remove the margin-right: 300px; This is not the right way to go.
There are multiple ways to achieve what you like.
You can set a width for your menu, so the child elements now how to stretch the 50% you have defined:
.sub-menu { width: 480px; }
Using this, your columns will align next to each other.
If you do not want to use a fixed width, you can for example use CSS grid to define how the child columns should look like:
.sub-menu { display: grid; grid-template-columns: 1fr 1fr; }

Related

My li is floating left at larger screen but when it is on extra small screen the li does down. How can I put my li float left at smaller screen too?

I am making a navbar. In this navbar I used two li tages. One is of language and another is of currency. When I make the screen size to extra small I want the litags to float left. But it goes down of another. How can I fixed this problem.
Also my collapse button is not positioning in correct place. Need a solution for that too.
I have tried with float-xs-leftclass and also css media query. None of them worked.
I want the "EN" and "USD" option to float left an extra small screen and I also want the search and total amount of money option to look cool
One way to achieve what you asked for is to use the CSS property display: flex on the parent element of the li tags (for instance, a ul tag) in conjunction with the flex-wrap: nowrap. Here is an example that might work on small screens:
nav {
width: 100%;
}
ul {
width: 100%;
list-style: none;
padding: .5em;
display: flex;
flex-wrap: nowrap;
background: slategrey;
}
li {
margin: .5em;
padding: 1em;
background: lightblue;
}
<nav>
<ul>
<li>Language: French</li>
<li>Currency: Euros €</li>
</ul>
<nav>

How to display more than 3 items in a row?

I have a problem displaying a portfolio on my site. I would like to display more than 3 in row, like here.
Is there any easy CSS command to change it?
Yes there is.
Simply change the width of the li elements to something smaller or equal to 25%.
.home-section ul li {
float: left;
margin-right: 5.63%;
width: 20%; /*changed this value*/

Difficulty centering images on html+css site

I created a website for a friend: http://personaltrainerffm.de/
and the logos underneath (see pictures) won't be shown centered. Also when browsing with a mobile device, it will get screwed. Can you please help?
THANK YOU VERY MUCH in advance
Screenshot on smartphone
Those logo containers (.container-erfahr ul li) all have a float: left setting in their CSS. Since the second one is higher than the third one, the fourth one is positioned below the third one (i.e. right of the second one) in the mobile view - that's the way floats work.
To fix this and center them, erase the float:left and define them all as display: inline-block. To center the elements, add text-align: center to their container element .container-erfahr.
These are the changed rules:
.container-erfahr ul li {
display: inline-block;
margin: 30px;
padding: 0px;
border: 0px solid lightgray;
list-style: none;
}
.container-erfahr {
margin-top: 100px;
margin-left: 0px;
text-align: center;
}

Width: Auto not working on dropdown navigation

Going to be quite difficult to explain this so I've created a JS-Fiddle so you guys can see what I mean...
If you look under the 'products' tab the second link in the list I've made quite long, the result is that it overflows out the boundaries of the list. How can I make this that if a link is very long, that the width of the containing ul stretches to contain the link?
Again having a look at the JSfiddle will make things more clear in what's happening and what needs to be done.
PS - Need to get it to work without editing the HTML at all!
//Ignore this
Just remove the fixed width of your list:
ul li {
display: block;
position: relative;
float: left;
width: 140px; // <-- Remove this
height: 25px;
}
It will make your default width for your list become auto and you're done.
Demo: http://jsfiddle.net/Kpxpf/5/
Just change the width:140px; to min-width:140px; in ul li
Demo :
http://jsfiddle.net/Kpxpf/6/
You're constraining the width of your <li>s from the style on the top-level menu. This will keep your intended width: 140px; on the top-level menu and allow the sub menu to size based on its content.
jsFiddle
ul#menu li ul li {
width:auto;
}
You are setting a fixed width on the nested lists.
Change the ul li styles to:
#menu > li {
display: block;
position: relative;
float: left;
width: 140px;
height: 25px;
}
This will remove the fixed width from the nested uls allowing them to take as much space as needed.
jsFiddle

CSS styling navigation buttons

You can see an attempt at what I'm trying to do here: http://rjlacount.com/clients/GreenTree/
I want the navigation li's to determine padding automatically so they can stretch across the entire width of the inner wrapper. So, if I added another li or took one out, they would still be centered and the padding of each li would just increase/decrease to make up for it.
Right now I'm floating the last navigation li to the right and adding padding to each one to try to get it as close to full-length as possible. So it's almost how I want it to look, but I have a space between the last two items that I'd like to get rid of.
Is this possible? Thanks for any help.
I don't believe this will work in < IE8, but you could always provide a float or display: inline-block fallback to those browsers using a conditional stylesheet.
Example
CSS
ul {
display: table;
width: 100%;
}
ul li {
display: table-cell;
}
ul li a {
display: block;
width: 100%;
height: 100%;
text-align: center;
}
jsFiddle.
jsFiddle with one more li, you'll notice the CSS is constant :P