CSS Bootstrap - Horizontal nav using ul li right aligned, and - css

I am using twitter bootstrap 2.3, I need the menu to be aligned to the right and also need the anchor to have a diferent widt, depending on the size of the world inside the anchor.
With next code, it's working, I leave empty columns with offset class, but not sure it there is a better to achieve the same result with another technique.
What I don't know how to do it is get the same "empty space separation" between each li, each li having a different width.
<div class="row_fluid">
<ul class="menu_logged span7 offset5">
<li class="span1 offset6"><a>Test</a></li>
<li class="span1"><a>Medium phrase</a></li>
<li class="span1">123</li>
<li class="span1">Hello World</li>
<li class="span2">Back</li>
</ul>
</div>
Any help?
Thank you

Related

Keep css floats horizontally aligned

Why does the div to the right float higher than the two divs to the left? How can i get them all aligned to the top?
HTML
<header>
<div class="nav" style="width:100%;border:#900 thin solid;">
<ul id='nav-left' style="list-style-type:none;float:left;width:30%;">
<li class='nav-link'>Bookstore</li>
<li class='nav-link'>Authors</li>
</ul>
<h1 class='nav-logo' style="width:30%;float:left;background-image:url();">
Logo
</h1>
<div class='nav-right' style="width:30%;float:right;">
<li class='nav-link'>Sign in</li>
<li class='nav-link'>Sign up</li>
</div>
<div style="clear:both;">
See fiddle http://jsfiddle.net/e6h3jyb4/
You have li elements that aren't contained within a ul element. If you wrap those li elements in a ul, then that should fix your alignment issues. In addition, I would suggest that you make all of your columns float: left. Your last column is float: right, and since each has a width of 30%, you will have a large margin between the last two columns. You could also fix that by making your widths 33.33% so it is closer to 1/3 without any leftover margin.
When you add the <ul> to the list elements it adds a margin. Add the <ul> tag to the right-hand list and it will fix it.

How can I render the triangle outside the container element?

I'm trying to build a menu with CSS. When the li element has a class of active, I want a triangle (of a specific size) to appear next to the container. Please see the following http://jsfiddle.net/hcabnettek/MeczJ/
As I increase the left property, the arrow goes to the end of the container, but slides behind it. I tried z-index and various other things but I can't seem to figure it out.
Any help would really be appreciated. Thanks all!
<nav>
<ul class="nav main-nav">
<li class="active">
<a href="/home">
<i class="icon-home"></i>
<h6>Home</h6>
<div class="items"></div>
</a>
</li>
</ul>
</nav>
Make the li set to overflow: visible. This should probably fix the problem. If not, also check that the ul, which has a set width, is also set to overflow: visible.

CSS Dropdown Remove Text Wrap

How do I remove text wrapping for the child elements in a dropdown?
JSFiddle with CSS here: http://jsfiddle.net/6Bqfn/4/
<ul>
<li>Home</li>
<li>Shop
<ul class="children">
<li>Longer Title</li>
<li>Short</li>
<li>Short</li>
</ul>
</li>
</ul>
I can't get the ul holding the children elements to resize to the size of the largest child li.
You need to include white-space:nowrap; in your css for the items you wish not to wrap:
ul.children li {
white-space:nowrap;
}
This will force all items to show up on a single line, and since all your widths are set to auto, it'll expand accordingly. I updated your jsFiddle as well.
You might try something like embedding a non-breaking space...
Longer Title

Slide-out menu with CSS transitions

I have a vertical menu that needs some sub-menus. I can accomplish a decent-looking one just by putting a ul tag inside the link I want to expand and absolute-positioning it on hover, with display:none when it's inactive. But I'd like to make it slide out, and I haven't had any luck doing so. I have this basic markup:
<aside>
<ul>
<li>Link Text</li>
<li class="more">
Base
<ul>
<li></li>
</ul>
</li>
</aisde>
The aside tag is itself a secondary navigation menu, the main one is in my header. It is position:fixed for easy access while scrolling.
The ul tag inside of <li class="more"> is absolutely positioned, anchored to -1px on the top and width:154px, and on hover it becomes display:block; left:154px (of course, it is display:none when inactive). I have tried transitioning the left property, but it does not change anything, it acts as if my transition weren't even there.

Highlight sub menu item when being viewed

I have a menu that is basically nothing but a bunch of unordered lists inside of each other. Here is an example:
<div id="horiz-menu" class="moomenu"><div class="wrapper">
<ul class="menutop">
<li><span>Home Page (top menu item)</span>
<ul>
<li><span>Second page (sub menu item)</span>
</li>
</ul>
</li>
<li class="parent active"><span>Resources (top menu item)</span>
<ul>
<li id="current" class="active"><span>Third Page (sub menu item)</span>
</li>
<li><span>Fourth Page (sub menu item)</span>
</li>
</ul>
</li>
</ul>
</div></div>
It is styled to look like the top menu items are the horiz nav menu and the sub menu items are a vertical drop down list (no scrolling) when the top menu item is hovered over; hidden other wise. That all works. My question is what would be the proper way to code css so the sub menu items get highlighted (the background color should change) when the visitor is on that page (not simply hovering over that menu item)?
I have tried this:
#horiz-menu ul li.active {background-color:#000;}
#horiz-menu ul li#current {background-color:#000;}
I don't know if this is the way to do this or not. Can some one help? If your confused I want to be able to use css to color the second ul with an li class="active" or an id="current". The "active" and "current" id and class get applied dynamically to what ever list item the page being viewed is.
Thanks!
Try the addClass Method in the JQuery
$("a.classname").click(function(){
$("li#idname").addClass("active");
});
Using the .active class with background color SHOULD work, however, it depends on what other CSS you have. You have to make sure the specificity of the .active or #current is greater than the default styling (#horiz-menu ul li). Also, be sure to double check that it is the li that has the default background css rather than the anchor inside of it.

Resources