WordPress.org

Support

Support » Themes and Templates » [Resolved] My style.css must be retarded (or I am)

[Resolved] My style.css must be retarded (or I am)

  • Goodvalley
    Member

    @goodvalley

    …it’s likely that I am.

    Ok, I’m trying to build a simple dropdown menu with css, nothing more. So it should be a piece of cake.

    I am using the SilverOrchid theme. It has a menu, but I need to add another menu which will have different links for every post. So I want to build a css menu which will be embedded in posts.

    I’m no expert nor programmer, but it’s not exactly my first day with WordPress either.

    Well, I’m simply not able to make the first sentence of the code in the style.css to work.

    For example, in the “text” screen of a post I put this code:

    <div id="my-header">
    
       <ul class="my-menu">
          <li><a href="">Item 1</a></li>
          <li><a href="">Item 2</a>
             <ul>
                <li><a href="">Item 2-1</a>
                   <ul>
                      <li><a href="">Item 2-1-1</a></li>
                      <li><a href="">Item 2-1-2</a></li>
                      <li><a href="">Item 2-1-3</a></li>
                      <li><a href="">Item 2-1-4</a></li>
                   </ul>
                </li>
                <li><a href="">Item 2-2</a></li>
                <li><a href="">Item 2-3</a></li>
                <li><a href="">Item 2-4</a></li>
                <li><a href="">Item 2-5</a></li>
             </ul>
             </li>
          <li><a href="">Item 3</a></li>
          <li><a href="">Item 4</a></li>
          <li><a href="">Item 5</a></li>
          <li><a href="">Item 6</a></li>
          <li><a href="">Item 7</a></li>
          <li><a href="">Item 8</a></li>
    	</ul>
    </div>

    Then I go to the style.css and add the following:

    .my-menu ul {
    		list-style:none;
    	}

    And it doesn’t work. I’ve changed everything, from “class” to “div”, adding #my-header and so on, and it simply does nothing. Yes, that is a very small piece of code and it should have a lot more. But I can’t solve the issue with the “list-style:none;” in any way.

    Here is the code in the style.css for the menu in my theme:

    #gazpo-nav {
    	background:#f6f6f6 url("images/nav-bg.png") repeat-x 0 0;
    	border-bottom:2px solid #ccc;
    	border-top:1px solid #ececec;
    	display: block;
    	float: left;
    	margin: 0 auto;
    	width: 100%;
    	position:relative;
    	z-index:4;
    }
    
    #gazpo-nav .main-menu ul,
    div.menu ul {
    	list-style: none;
    	margin: 0;
    	padding-left:0;
    	white-space:nowrap;
    }
    
    #gazpo-nav .main-menu li,
    div.menu li {
        float: left;
        position: relative;
    }
    
    #gazpo-nav a {
    	color:#737373;
        display: block;
        font-family: 'Droid Sans', sans-serif;
    	font-weight: bold;
    	text-shadow: 1px 1px 0px #fff;
      	font-size: 16px;
        line-height: 28px;
        margin-top: 1px;
        padding: 6px 20px;
        text-decoration: none;
    }
    #gazpo-nav .menu ul li.hover,
    #gazpo-nav .menu ul li:hover,
    #gazpo-nav ul.menu li.hover,
    #gazpo-nav ul.menu li:hover {
    	position: relative;
    	z-index: 599;
    	cursor: default;
    }
    #gazpo-nav ul ul {
     float: left;
        left: 0;
        position: absolute;
    	display:none;
        top: 40px;
        width: 180px;
    	z-index: 598;
    }
    #gazpo-nav ul ul li {
    	min-width: 180px;
    }
    #gazpo-nav ul ul ul {
    	left: 100%;
    	top: 0;
    	padding-left:2px;
    }
    
    #gazpo-nav ul ul a {
    	line-height: 1em;
        padding: 10px;
    	width: 180px;
    	height: auto;
    	margin-bottom:-1px;
    	font-size: 14px;
    	background: #f9f9f9;
    	border-bottom: 1px solid #ddd;
    	overflow:hidden;
    }
    
    #gazpo-nav ul ul a:hover {
    	color: #373737;
    }
    
    #gazpo-nav li:hover > a,
    #gazpo-nav ul ul :hover > a {
    	color: #373737;
    }
    #gazpo-nav ul li:hover > ul {
    	display: block;
    }
    #gazpo-nav ul li.current_page_item > a,
    #gazpo-nav ul li.current-menu-ancestor > a,
    #gazpo-nav ul li.current-menu-item > a,
    #gazpo-nav ul li.current-menu-parent > a {
    	color: #373737;
    }
    * html #gazpo-nav ul li.current_page_item a,
    * html #gazpo-nav ul li.current-menu-ancestor a,
    * html #gazpo-nav ul li.current-menu-item a,
    * html #gazpo-nav ul li.current-menu-parent a,
    * html #gazpo-nav ul li a:hover {
    	color: #373737;
    }
    
    #gazpo-nav li.submenu>a{
    	background: url(images/arrow_down.png) no-repeat 98% 50%;
    }
    
    #gazpo-nav li ul li.submenu>a{
    	background:#f9f9f9 url(images/arrow_right.png) no-repeat 98% 50%;
    }
    
    #gazpo-nav li ul li.submenu>a:hover{
    	background:#f9f9f9 url(images/arrow_right.png) no-repeat 98% 50%;
    }

    I’ve tried to copy some pieces of the same code above, but nothing works.

    What am I doing wrong?

Viewing 15 replies - 16 through 30 (of 77 total)
  • Goodvalley
    Member

    @goodvalley

    Hahaha, good one!

    You see? Not even the tiniest skill for coding anything…

    DMBarber, a big thank you!

    Glad I could help.

    Goodvalley
    Member

    @goodvalley

    DMBarber, still here?

    I’m coping the code for the menu styling from a video, and the author puts this code:

    * {
         padding:0px;
         margin:0px;
       }

    I want to substitute “*” by the proper word, but I don’t know how to do it.

    Should I put

    .my-menu ul {
    padding:0px;
    margin:0px;
    }

    or shoul I put “.my-menu ul”?

    Thanks, promise not to bother you again, hehe.

    Goodvalley
    Member

    @goodvalley

    OK, I put it in the same place you told me, so it is:

    #content .entry #my-header ul {
    list-style: none;
    padding:0px;
    margin:0px;
    }

    As far I understand, this is the place to put all styling that will affect all the menu, right?

    Thanks

    No bother. When writing css a * is used as a wild card. This means it will automatically substitute for any selector. When used by itself, it means “everything” which in this case makes padding and margins for everything a value of 0. Sidenote: 0 can be used alone, you do not need px.

    To target your specific list, you should use the selector:

    #content .entry #my-header ul

    to avoid confusing the style sheet (actually the browsers interpretation of the style sheet). So it will be:

    #content .entry #my-header ul {
    list-style: none;
    margin: 0;
    padding: 0;
    }

    Hope that helps.

    You got it right. Good job!

    Goodvalley
    Member

    @goodvalley

    Ooops

    That was intended to center the list in the post, but it remains on the left side… mmmm, why is that?

    You simply removed the “space” around your list. To center it, you need to define its width as less than its parent container and add ‘auto’ to the left and right margin. Try this (this is untested, but should work. 80% means 80% of the parent container, you make it more or less to suit your needs):

    #content .entry #my-header ul {
    display: block;
    width: 80%;
    list-style: none;
    margin: 0 auto;
    padding: 0;
    }
    Goodvalley
    Member

    @goodvalley

    Thanks DMBarber, I owe you a beer or two!

    Happy to help.

    Goodvalley
    Member

    @goodvalley

    Um, it’s not working.

    Anyway, I will finish all design and details, after that I will post if there is still that issue or another. I want to try to solve it myself, I’m asking too much and that’s not fair.

    See you later!

    You will need to seperate your list styling from the “centering” styling and be very specific about it. In Firebug, this works:

    #content .entry #my-header ul {
    list-style: none;
    }
    
    #content .entry #my-header ul.my-menu {
    padding: 0;
    margin: 0 auto;
    display: block;
    width: 80%;
    }

    No bullets and centered.

    Goodvalley
    Member

    @goodvalley

    Aaah, that was what I was thinking…

    I’m finishing the whole thing, now I’m adding my own designing details, let’s see if I can get it right.

    Thanks, I will post the final code.

    Goodvalley
    Member

    @goodvalley

    Yeah, it’s working…

    Now I’m fighting with borders and some other details, let’s see if I’m done within an hour…

    Goodvalley
    Member

    @goodvalley

    Ok, I’m done with a pretty decent 1.0 version of what I need.

    DMBarber, when I put the code like this

    #content .entry #my-header ul {
    list-style: none;
    margin: 0;
    padding: 0;
    }

    it works perfectly. But as I said, the menu is to the left. But the rest of it is perfectly aligned, the submenus and everything.

    Buy if I try to center the menu putting the code you just told me

    #content .entry #my-header ul {
    list-style: none;
    }
    
    #content .entry #my-header ul.my-menu {
    padding: 0;
    margin: 0 auto;
    display: block;
    width: 80%;
    }

    it goes centered but loses the alignment. You can see how it gets if you go to http://www.drumscult.com/es/sin_categoria/menu-drummers/

    I can’t find where’s the problem

    Sorry for so many questions, I really appreciate your help

Viewing 15 replies - 16 through 30 (of 77 total)
  • The topic ‘[Resolved] My style.css must be retarded (or I am)’ is closed to new replies.