Bootstrap Narrow marketing + Justified nav? - css

I'm trying to use Bootstrap's narrow marketing example with the justified nav example.
However I've hit a bit of a problem trying to create a Dropbox using the justified nav template. Select "Downloads" from the header and the table styled is wrong I believe it's because of display: table-cell; but of course if you remove that it messes up.
I've come up with this

Just change
.navbar .nav li {
display: table-cell;
width: 1%;
float: none;
}
with
.navbar .nav > li {
display: table-cell;
width: 1%;
float: none;
}
and each of the items of the submenu will be a line. This way, you will only apply that three rules to the direct li child of the .nav class and not to the other li elements.
Result: JsFiddle

Related

html css Vertical list aligning top

I'm trying to create a container with 4 columns, on the top theres an image with some text below it.
But it doesnt align towards the top, but bottom
This is the styling for li
#carousel-navigation li {
list-style: none;
display: inline-block;
width: 23%;
background-color: blue;
}
Here is the fiddle: (the images on the bottom should be on the top instead)
http://jsfiddle.net/G6Jnh/
I'm thinking a table might be easier but it should only be used to display data and not layout they say...
You need to add vertical-align property like following:
#carousel-navigation li {
list-style: none;
display: inline-block;
width: 23%;
background-color: blue;
vertical-align:top; /* add this */
}
Demo
Display the ul as a table and the li as table cells and then use vertical-align as you need to align
#carousel-navigation ul {
display: table;
}
#carousel-navigation li {
display: table-cell;
vertical-align: top;
}
Updated Demo
I added a float: left to your styling for the li and it seems to work.

Bootstrap dropdown list float left

I have a site link: http://www.dentalmarketing.com.au/stage/test/2/
If you click on the menu link SUB SITES, as you can see the drop down list appears as normal list. Is there a way to float the LI list in Bootstrap CSS so that the list would appear like inline?
I have tried inserting my css
.mainnav ul.dropdown-menu > li {
float:left !important;
}
But somehow it just doesn't work. Thanks much for your time and expertise.
Yes, with display: inline-block then you also need to set a width to the ul
You could also use float... here is what the css should look like with either way :
width's may vary
.open > .dropdown-menu {
display: block;
float: left;
width: 400px;
}
or
.open > .dropdown-menu {
display: inline-block;
width: 400px;
}

<ul> cannot be centerred with media queries

I have spent like 4 hours and still cannot fix it, I have 2 divs, one floated left and one right, in left div I have text and in right I have a <*ul>, when I use text-align:center; based on media query for the left template it works perfectly, but I also want the <*ul> to be centered when the browser width is reduced. Please take a look here and let me know what I am doing wrong and where exactly ? http://goo.gl/OJ5OHt THANKS A LOT to anyone who helps me get out of this..
The problem is not so much the UL but the children LI, that are floated left.
You have two options:
A)
Set a fixed width to UL and center via margin auto:
.social-icons ul {
margin: 5px auto;
width: 220px;
}
B) Remove the float from the children LI, set them to inline and set their children A to inline-block (and then UL text-align would work):
.social-icons ul {
text-align: center;
}
.social-icons ul li {
display: inline;
float: none;
}
.social-icons ul li a {
display: inline-block;
}
The only ways I can see to do this is to add the following to your ul style under your media query:
margin: 0 auto;
width: 217px;
It needs to be a fixed width.
OR
Change your ul to:
text-align: center;
And your li and a items to:
display: inline-block;
Either way should work.

Strange Disapearing elements in small browsers when hover

Hi There when I make my browser smaller than 420px (Using Chrome Stable) the Navigation elements in the first navigation line disapear, when I hover them. I cannot find the mistake.
Can anybody help? Website is: http://www.tokemedia.de
go to style.css and change display:inline to inline-block;
#navi ul li {
float: left;
margin-left: 10px;
list-style: none;
text-align: center;
display: inline-block;/* not inline*/
}

How to distribute HTML list items evenly in an unordered list

I want my li elements that form a horizontal menu to be distributed evenly across the width of my ul element. I normally float my li elements to the left and add some margin. But how do I put the proper spacing so they extend from the left of my ul element to the right edge?
Here's an example jsfiddle of a menu not distributed across the ul.
The spacing has to be the same between each li. But the li elements may be different lengths.
Yet another approach. This is something I use when trying to span a menu evenly across the page. It is nice if you have a dynamic menu that will change depending on certain conditions (like an admin page that only shows up if you are logged in as an admin).
CSS:
nav div ul {
display: table;
width: 100%;
list-style: none;
}
nav div ul li {
display: table-cell;
text-align: center;
}
nav div ul li a {
display: block;
}
I was kinda lazy, and just copied this from my current project, so you will have to adapt it to fit your code, but it is my preferred method of creating a horizontal menu
EDIT: You can make it look like it spans better by adding this:
CSS:
nav div ul li:first-child {
text-align: left;
}
nav div ul li:last-child {
text-align: right;
}
again, untested, just typed.
You'll need to set the width of the li elements to force them to fill the space:
ul {
width: 100%;
}
li {
float: left;
width: 33%;
}
(Fiddle demo)
If you add more items to the list, you'll need to adjust the percentage width - eg with four items, the width will be 25%.
I have two answers for you.
If you want to stick with the float model:
Your ul element needs to have the overflow property set (without this property, your ul (or any element containing floated elements) is not given a height (this is expected behavior, mind you: http://www.quirksmode.org/css/clearing.html) and will therefore default to a height of 0 - the effect of this will be that if you set different background colors for your ul/li and body, the background of your ul will not seem to display).
ul {
text-align: center;
width: 300px;
overflow: auto;
}
Your li elements need to have widths set, otherwise - as floated elements - their width will be set to whatever they contain. I've used pixels, below, but you can use a percentage value too.
li {
float: left;
margin: 5px 0 5px 0;
width: 100px;
text-align: center;
}
Use the display:inline-block property for your li elements (if support for old browsers isn't a priority). IE 7 does not support this, so it's not useful if you need wide cross-browser support, but it creates the effect you want - though make sure you then delete any spaces between your </li> and <li> tags, otherwise they will be counted in the overall width and will show up as spaces between the elements.
One advantage that this method has is that you don't have to know or set the width of the container ul if you use percentage widths on your contained li elements, you still get the centering for free with the text-align property you already have. This makes your layout very responsive.
Here's markup and CSS that works the way I think you are requesting:
Markup:
<ul>
<li>banana</li><li>orange</li><li>apple</li>
</ul>
CSS:
li {
display:inline-block;
margin:5px 0 5px 0;
width:33.33%;
}
ul {
text-align: center;
}
If you'd rather keep the markup on multiple lines, then you'll have to fiddle with the left and right margins of your li elements in the CSS.
If you add li elements, you'll have to change the percentage width to match (for example, with four li elements in your markup, you'd need to change your CSS to have a width of 25% for each one).
Html:
<ul>
<li>1</li>
<li>2 <br>4</li>
<li>3</li>
</ul>
Css:
ul {
list-style: none;
font-size: 0;
text-align: justify;
}
ul:after {
content: '';
display: inline-block;
width: 100%;
}
li {
font-size: 100px;
display: inline-block;
}
codepen
I don't get your question clearly so I assumed that you might want this:
li {
border:solid 1px red;
clear:both;
display:block;
float: left;
margin: 5px;
width:100%;
}
ul {
text-align: center;
width:300px;
}

Resources