How to css 3rd li in hierarchy? - php

I'm pretty sure I'm not getting the hierarchy in css for building this. I can't seem to find a place that will actually explain it to me, and how each level works. I've found some that show, but when you build it if you don't know, at least for me, it's kind of hard to see. Never really used css suprisingly until now. If someone wouldn't mind pointing out my error and explaining it please. :)
I'm just trying to add a 2nd drop down (a drop down to my drop down) that will show up horizontally under the initial hidden drop down, when selecting the correct one so the correct php id will populate in the link. I included the PHP just so if I put it in wrong someone could point that out to me as well.
also to add: the 2nd level hidden drop down links seem to be there when I hover over "project" instead of when hovering over the populated projects like it should. The weird thing is the links don't actually show up (not visible), but if i put my mouse there ie lets me know theres a link.
http://jsfiddle.net/HHwLH/

In your css
#navbar li:hover ul, #navbar li.hover ul {
position: absolute;
display: inline;
left: 0px;
width: 100%;
margin: 0px;
padding: 0px;
}
your sub menu and sub sub menu is affected by this.
When you hover on the li all ul descendants will be affected (submenu and subsubmenu)
in your markup the uls are children of the li so you can use the children selector instead of the descendant selector to only show the direct child menu/ul.
#navbar li:hover > ul, #navbar li.hover > ul {
position: absolute;
display: inline;
left: 0px;
width: 100%;
margin: 0px;
padding: 0px;
}
This will work for both submenu and subsubmenu
FIDDLE

Related

Move Specific Elements

I'm currently building a site using WordPress. I'm trying to layout a listview for the products page with CSS but I am experiencing a couple of problems. The code behind these elements are within the WordPress files so I'd rather not touch those if possible.
What I'm trying to do is move "MSDS" next to the title as it was below the title before. I've set it to relative position and moved it using top and right pixel values.
Example 1
Example 2
My first problem is that if you look at Example 1. I have positioned "MSDS" next to that specific title but when you look at Example 2, it has a shorter product name but the positioning of "MSDS" is the same therefore it looks silly. How do I go about fixing this?
My second problem may be fixed if the first is fixed but on a maximised window, the layout looks fine but when resized to a smaller window then the window covers "MSDS" but the title looks fine as it wraps so it's viewable on the page.
I'm not entirely sure where to look or what specific things I should be looking for to find a fix for this. So any help would be much appreciated. The code below is what I used to reposition the "MSDS"
.product-list .product-thumb .description {
position: relative;
bottom: 26px;
left: 290px;
width: 30px;
}
You can always use :after for these things
These should help.
Add these in your stylesheet to
.product-list .product-thumb .description:after {
position: absolute;
content: "MSDS";
color: blue;
}
You can style the element accordingly then
you are looking for position: relative and position: absolute i think.
Try this: https://jsfiddle.net/r5rnyh3y/1/
.title {
display: inline-block;
position: relative;
}
.title a {
position:absolute;
right: -100%;
margin-right: -10px;
display: inline-block;
width: 100%;
}

Drop down menu appearing behind images

I can't for the life of me figure out why the drop down when hovering over the "about" menu item is appearing behind the images, see this link http://www.ziprfit.com.au/index.php (I hope it's OK to post the link).
All search results suggest z-index, well the z-index for the images in there goes to 6, and I've set the menu to 100 and it still appears behind the images.
On the server side this is generated by PHP.
Thanks for your help.
Add position: relative; in your #nav ul ul
#nav ul ul {
z-index: 100;
display: none;
position: relative;
}
Add position: relative; and z-index: 100; to your #nav div :)

Wordpress menu cannot be centered

I am working with the site cardinalmma.com/ but you can see that the menu is not centered. For example see the news menu its in the left portion but with some padding. I want it to be centered can anyone help me.
thanks
Somdeb
You want the individual navbar labels centered, correct?
li.menu-item {
text-align: center;
}
This targets the <li> tags in your menu, identified by the .menu-item class. The text-align: center; rule takes care of centering the <a> tag with your text in it.
In my browser, this modification makes it look like this:
Try something in your css stylesheet to make the menu items be align center.
try something with the class menu and the li part:
.menu {
text-align: center;
}
Or something in that direction
Please update your css. This should resolve your issue.
.menu_top a {
color: #eee;
font-weight: bold;
line-height: 3.4em;
padding: 0 14px;
text-decoration: none;
height: 50px !important;
text-align: center;
display: block;
}
.menu_top ul ul li a {
text-align:left;
}
To center the navbar labels use this css courtesy of Surreal Dreams:
li.menu-item {
text-align: center;
}
Now to elaborate on how to find this solution. The best way to edit/develop CSS for wordpress is to use firebug or Chrome's developer tools to find the element you want to modify.Then you can add CSS right there and see the results real-time (these changes are not permanent). I would say it is likely this is how Surreal Dreams found the solution.
If you want to learn more about using the Chrome dev tools tool go to this page: https://developers.google.com/chrome-developer-tools/.
If you are new to CSS (I dont know if you are new to CSS or if youre problem is strictly editing CSS) for wordpress you should go check out http://www.codecademy.com/tracks/web

Scrolling message board, how do I link to an id in a div within a div?

Ok so this might be very basic but I'm struggling here.
I've got limited space but I need a comments board so I need to be able to scroll through messages. I've got my database and php setup and the messaging works fine. I've done the layout with div's so that all the comments are within the master comments div with is set to overflow: hidden, hiding the messages that don't fit. Every message is then formed as a div (which has 2 div's inside for subject/sender and comment sections). Each of the message div's is automatically given an id by the script so I have something to target here.
What I would like to do is to have the messages scroll so that when you click 'down', the topmost message will disappear and the messages will move in line so that the next one is now topmost. Is this possible? I tried to play around with childNodes but couldn't get it to work.
Also, does my layout solution make any sense? Should I change it to lists?
CSS is
#kommentit { // <- all comments
position: absolute;
margin-top: 50px;
margin-left: 475px;
width: 400px;
height: 400px;
overflow: hidden;}
.sitoja { // <- this is the single comment binder
position: relative;
width: 400px;
background: #fff;
border-radius: 10px;
padding: 0;}
I assign id for every message so I get
<div class="sitoja" id="[i]">
in php
echo '<div class="sitoja" id="'.stripslashes($info2->id).'">';
You can view the dummy of the message board here: http://pohjis.site40.net/testi.php
There are many ways to do it.
The simplest is changing overflow: hidden; to overflow: scroll;.
You can also display: none; the topmost comment to make the lower ones move up.
And you can scroll the div with javascript.
BTW, with some adjustment of the css you don't need position: absolute; - not using that will make designing things easier.

change the absolute position from left to right on a span tag depending on class

This is my first question here but I'm sure there are many more to come.
I have a small position problem that I would like to know if it's even possible to achieve.
I have an unordered list (<ul>) with floated <li>s, for the main options i float these left, and for the contact and support options I float them right, so far so good. Now i have a <span> inside each <li> which i display under the horizontal list, the list is for a menu. These <span>s works as description to menu choice and for the normal options I use position:absolute; top:30px; left:0; this works as suspected. Now I would like to change the position attributes for those menu items that i float right so that the span gets position:absolute; top:30px; right:0; and this doesn't work at all. It seems like it's impossible to change this with a more specific css rule then the other, yet the float works great.
the html:
<div id="menu">
<ul>
<li>Menu1<span>Info1</span></li>
<li>Menu2<span>Info2</span></li>
<li class="support">Support1<span>Info3</span></li>
</ul>
The css:
#menu{position:relative;}
#menu ul{list-style:none;}
#menu ul li{float:left;}
#menu ul li.support{float:right;}
#menu ul li span{display:none;}
#menu ul li:hover span{display:block; position:absolute; top:30px; left:0;}
#menu ul li.support:hover span{display:block; position:absolute; top:30px; right:0}
The last line in the css make no difference!
If anyone has an answer or a work around I greatly appreciate the help.
Question answered and problem solved. Check James Arons or mercator's posts.
Even thought you set right:0, your left:0 is still being inherited. You need to set left:auto to override that style for the support class.
Judging from that CSS, you don't seem to understand CSS correctly, or you aren't using it correctly at least. You might want to read the SitePoint article about the cascade, specificity and inheritance for a good introduction.
The reason that doesn't work is because the last two lines of that CSS apply to the list items with the support class. The second-to-last line applies to all list items, and the last line then adds to that for the support list items. So, since there's no left property in that last line, the left property cascades down from the previous line, making it left: 0 too.
When you're using a class to mark a special case, you shouldn't be repeating all the CSS of the general case, but only provide the CSS necessary to change it:
#menu ul li:hover span {display:block; position:absolute; top:30px; left:0;}
#menu ul li.support:hover span {left:auto; right:0;}
That CSS will mean the support-class list items get all the CSS the other list items get, but with the left property reset to default, and the right property set instead.
Hmm weird. I can't tell you why your code does not work, should work since the support:hover span is a more specific selector.
Found a fix though:
Position absolute elements got left: 0; by default.
If you remove left: 0; from the span selector it will work.
Your code would look like this:
#menu{position:relative;}
#menu ul{list-style:none;}
#menu ul li{float:left;}
#menu ul li.support{float:right;}
#menu ul li span{display:none;}
#menu ul li:hover span{display:block; position:absolute; top:30px;}
#menu ul li.support:hover span{display:block; position:absolute; top:30px; right:0}

Categories