CSS id is passing to the rest of the website - php

I´m trying to do a navigation menu on a website and for some reason what i defined in the id topnav_ubid is getting applied to the rest of the site, especially on a:link and a:visited. I just wanted the style to be applied to the menu. I tried wraping inside a div but still no luck. What's wrong with my code? Can someone help?
I defined this on my style.css
#topnav_ubid ul li {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
#topnav_ubid li {
float: left;
}
#topnav_ubid a:link, a:visited {
display: block;
width: 85px;
height: 20px;
font-weight: bold;
color: #FFFFFF;
background-color: orange;
text-align: center;
padding: 4px;
text-decoration: none;
text-transform: uppercase;
}
#topnav_ubid a:hover, a:active {
background-color: #7A991A;
And had this in HTML:
<div id="topnav_ubid">
<ul>
<li><? print $MSG_501; ?></li>
<?php
if($_SESSION["BPLowbidAuction_LOGGED_IN"]) {
/* user is logged in, give link to edit data or log out */
?>
<li class="<?=$user_menu_style;?>"><? print $MSG_622; ?></li>
<li><? print $MSG_245; ?></li>
<?php
} else {
/* user not logged in, give link to register or login */
?>
<li class="<?=$user_login_style;?>"><? print $MSG_259; ?></li>
<?php
}
?>
<li><? echo $MSG_5085 ;?></li>
<li><? echo $MSG_31_0048; ?></li>
<li> <? print $MSG_164; ?></li>
</ul>
</div>

#topnav_ubid a:link, a:visited { actually are two selectors: #topnav_ubid a:link and a:visited. The second one applies to every visited link, regardless of its parent.
I think you meant this to be #topnav_ubid a:link, #topnav_ubid a:visited {. The same mistake is made in the next selector: #topnav_ubid a:hover, a:active.
I usually add a break after a comma in a list of selectors, so it would be written as:
#topnav_ubid a:link,
#topnav_ubid a:visited {
That way, it's much easier to instantly see all the selectors and you are less likely to make this mistake.
Also note, that in your developer tools (F12) in your browser, you can inspect which styles are applied and which selector caused that. That should help you find any invalid selectors pretty easily.

Related

Link not clickable in Wordpress Menu but can be opened in a new tab

Disclaimer: I am sorry the post looks too big but I just thought I should provide all the details. I am sure the issue is something very stupid but I am not able to figure out :(
Background: I am creating a wordpress site using an awesome theme called Parallax from Access Press. I wanted to play out my business website before buying the pro version so decided to make a few changes myself.
Problem: You can either use the theme's menu (which allows animation and same page scroll; This Golum wantses) or use native wordpress menus (which does not allow scrolling; Golum hateses).
Workaround Tried: I figured I can go into the header.php and add one menu item manually. So following is the code per my understanding:
<nav id="site-navigation" class="main-navigation">
<div class="menu-toggle"><?php _e( 'Menu', 'accesspress_parallax' ); ?></div>
<?php
$sections = of_get_option('parallax_section');
if(of_get_option('enable_parallax') == 1 && of_get_option('enable_parallax_nav') == 1):
?>
<ul class="nav single-page-nav">
<?php
$home_text = of_get_option('home_text');
if(of_get_option('show_slider')== "yes" && !empty($home_text)) : ?>
<li class="current"><?php echo esc_attr($home_text); ?></li>
<?php endif;
if(!empty($sections)):
foreach ($sections as $single_sections):
if($single_sections['layout'] != "action_template" && $single_sections['layout'] != "blank_template" && $single_sections['layout'] != "googlemap_template" && !empty($single_sections['page'])) :
$title = get_the_title($single_sections['page']); ?>
<li><?php echo $title; ?></li>
<?php
endif;
endforeach;
endif; ?>
<li>Pre-order Here</li>
</ul>
<?php
else:
<some more code that picks custom menu if you choose to skip parallax menu>
</nav>
The first LI item just puts the text 'Home' in the page. Second one picks all the values from parallax menu. The Last LI item is the one I have included.
<li>Pre-order Here</li>
Behavior: This perfectly adds the item to the menu and also appears to be clickable. The problem is - when it is clicked, it does nothing. If I right click it and open in a new tab, it works perfectly fine. Including related CSS below for your reference
Edit: If I include a link to another section of the page. it works. Example: http://domain.com/#section-20
.main-navigation {
float: right;
max-width: 80%;
margin-top: 15px;
}
.logo-top .main-navigation{
float: none;
width: auto;
text-align: center;
max-width: none;
}
.main-navigation ul {
list-style: none;
margin: 0;
padding-left: 0;
display: inline-block;
}
.main-navigation ul li{
position: relative;
}
.main-navigation > ul > li {
float: left;
position: relative;
font-family: 'Oxygen', sans-serif;
font-weight: 400;
}
.main-navigation > ul > li > a{
text-transform: uppercase;
font-size:14px;
padding: 5px 15px;
}
.main-navigation > ul > li.current a{
color: #E66432;
}
.main-navigation a {
display: block;
text-decoration: none;
color:#333;
}
.main-navigation ul ul {
background: #FFF;
position: absolute;
top: 100%;
left:0;
z-index: 99999;
padding:0 10px;
font-size: 15px;
box-shadow: 1px 1px 2px rgba(0,0,0,0.3);
display: none;
}
.main-navigation ul ul ul {
left: 100%;
top: 0;
}
.main-navigation ul ul a {
min-width: 200px;
}
.main-navigation ul ul li {
border-bottom: 1px solid #EEE;
padding: 8px 0;
}
.main-navigation ul ul li:last-child{
border:none;
}
.main-navigation li:hover > a {
color: #E66432;
}
.main-navigation ul li:hover > ul {
display: block;
}
.main-navigation .current_page_item > a,
.main-navigation .current-menu-item > a {
color: #E66432;
Thanks #pschueller and #dingo_d!!
You pushed me into the correct direction. The github to the JS plugin for scroll has the secret sauce.
I had to add a class='external' to my tag with the href and update the jquery.nav.js with the following:
Replaced
filter: '',
with
filter: ':not(.external)',

WordPress Custom Menu (3rd Level Nesting Issue)

I've ran into a problem using a custom WordPress menu that I can't seem to solve, so after doing a lot of searching the web & failing to fix this over the past few days, I've decided to see if anybody here on StackOverflow can help.
Please note: I would use a Walker function for this but I'm too far gone with the code right now and the way the design works I'm having to build the menu this way.
My snippet for my dropdown: http://pastebin.com/8Stfs90c (would post but it would crucify the screen).
I’m having trouble with the 3rd level of my dropdown menu. In this image: http://s13.postimg.org/lxhslt0lz/image.png you can see that there’s a <li></li> that I’ve highlighted (Pages, About Me, About Us). The structure is as follows
Pages (Parent)
About Me (Parent: Pages)
About Us (Parent: About Me)
And these are fine, BUT when it goes to the third dropdown, it cuts of the <li> and leaves the rest of the Pages children and puts them into a separate container and not the <li> for Pages.
So it should work like so:
Pages (Parent)
About Me (Parent: Pages)
About Us (Parent: About Me)
Right Sidebar (Parent: Pages)
Left Sidebar (Parent: Pages)
Our Process (Parent: Pages)
And all though it may look like this on the dropdown (visually), as you can see in the code it isn’t represented by this. I think the problem I’m having is the checks I’m doing for closing the </li> is wrong. I’ve had this problem for a few days and I just can't seem to fix it. I was going to post this on the WordPress based forum but it's more of a PHP error than anything else.
Here’s a quick screenshot of me hovering over the elements that should be in Pages: http://s23.postimg.org/ef4ame6m3/image.png - as you see they’re separated from the <li>.
To replicate this what I've done is just created a menu structure in WordPress and used the code that's in the snippet (basically I just pasted it into the index.php file) to show how it's being represented.
I really hope somebody can help with this as it has been driving me mad and put a holt on my project for the past few days.
Apologies for the links above, I would post them directly in (screenshots & code) but I didn't want to take away from the actual problem.
If somebody does manage to provide me with the solution I'd be more than happy to buy you a virtual coffee or two!
Out of curiosity, I could be missing the point, is there a reason why would not want to use wp_nav_menu() to handle all of this?
Ex below would output the correct structure for you to theme as your screenshot if applied in your context?
wp_nav_menu( array( 'container' => 'nav', 'container_class' => 'your-class', 'fallback_cb' => 'wp_page_menu', 'theme_location' => 'primary-menu' ) );
Thanks.
Had a quick look at the code, I suppose line 100-130 are dealing with the third dropdown. Actually whats happening is you already have an ol on line 105, then its again being called through the loop on line 122.
echo "<ol><li><a href='" . $link . "'>" . $t->title . "</a></li></ol>";
I think the problem is on line 128 you have to remove ol from the end and create a new condition just for this.
Sorry if i am not being of any help but its really hard to picture the whole code in mind without seeing it. If you are really stuck send the ftp details in chat and i can have a look.
Hi There try this css code to create multiple Nested menu create.
WP code for menu in header.php
<nav class="photoshoot-menu">
<?php wp_nav_menu(array('theme_location' => 'primary','container' => ' ')); ?>
</nav>
CSS Code Add in your style.
.photoshoot-menu {
float: right;
width: auto;
padding-left: 0px;
padding-right: 0px;
}
.photoshoot-menu ul {
padding-left: 0px;
margin: 0px;
}
.photoshoot-menu > ul li {
display: inline-block;
position: relative;
text-transform: uppercase;
margin: 3px 2px;
position: relative;
}
.photoshoot-menu > ul > li > a {
color: #212121;
display: inline-block;
padding: 8px 20px;
border: 1px solid #4f4f4f;
border-radius: 4px;
}
.photoshoot-menu > ul > li > a:hover,
.photoshoot-menu > ul > li > a:focus,
.photoshoot-menu > ul > li.current_page_item > a {
background-color: #343434;
color: #f45c06;
}
.photoshoot-menu ul ul {
border-radius: 4px;
border: 1px solid #4f4f4f;
background-color: rgba(38, 38, 38, 0.95);
opacity: 0;
position: absolute;
top: 42px;
width: 100%;
min-width: 170px;
z-index: 1;
visibility: hidden;
transition: all 0.5s ease-in-out;
-webkit-transition: all 0.5s ease-in-out;
}
.photoshoot-menu ul li:hover > ul {
opacity: 1;
visibility: visible;
}
.photoshoot-menu ul ul li {
width: 100%;
}
.photoshoot-menu ul ul li a {
display: inline-block;
line-height: 16px;
padding: 5px;
color: #FFF;
width: 100%;
}
.photoshoot-menu ul ul li a:hover,
.photoshoot-menu ul ul li a:focus {
color: #f45c06;
}
.photoshoot-menu ul ul ul {
left: 99%;
top: 0px;
}
<nav class="photoshoot-menu">
<ul class="menu" id="menu-all-pages">
<li>Home
</li>
<li>Level 1
<ul>
<li>Level 2
<ul>
<li>Level 3
<ul>
<li>Lorem Ipsum
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>Sample Page
</li>
</ul>
</nav>

IE Drop menu not working

I have a website with a css drop menu, which works fine on chrome and firefox, but in IE the drop menu doesn't display.... it's almost like it doesn't exist at all...
I've tried multiple times to copy some code or menus from other sites i have that do work in IE, but without success.
Here's the html...
<ul id="menu">
<li>INTRO |</li>
<li>HOME |</li>
<li>ACCOMMODATION & RATES |</li>
<li>INFO |</li>
<li>ACTIVITIES |
<ul class="sub-menu">
<li>GARDEN ROUTE ACTIVITIES</li>
</ul>
</li>
<li>GOLF |</li>
<li>NEWS |</li>
<li>CONTACT US |</li>
<li>DIRECTIONS |</li>
<li>GALLERY</li>
</ul>
the CSS
/*Initialize*/
ul#menu, ul#menu ul.sub-menu {
padding:0px 0 0px 0;
margin: 0px;
/*background-color:#9A844C;*/
}
ul#menu li, ul#menu ul.sub-menu li {
list-style-type: none;
display: inline-block;
display:inline;
}
/*Link Appearance*/
ul#menu li a, ul#menu li ul.sub-menu li a {
text-decoration: none;
color: #573A2F;
padding: 0px;
display:inline-block;
font-size:10px;
}
ul#menu li a:hover {
text-decoration: none;
color: #000;
padding: 0px;
display:inline-block;
}
/*Make the parent of sub-menu relative*/
ul#menu li {
position: relative;
padding-bottom:5px;
z-index:100001;
}
/*sub menu*/
ul#menu li ul.sub-menu {
display:none;
position: absolute;
top: 20px;
left: 0;
width: 200px;
background-color:#E2D9C6;
z-index:100001;
}
ul#menu li:hover ul.sub-menu {
display:block;
z-index:100001;
}
ul#menu li ul.sub-menu:hover {
display:block;
color: #573A2F;
z-index:100001;
}
Any help would be greatly appreciated...
I have checked with your code and it is working in my system. I have checked in IE7,8 and 9.
Another suggestion just change below css and check again:
I have just changed from "ul#menu li ul.sub-menu:hover" to "ul#menu li:hover ul.sub-menu"
ul#menu li:hover ul.sub-menu {
display:block;
color: #573A2F;
z-index:100001;
}
As others have stated, your code works with IE7, IE8 and IE9.
If the issue is really with IE6, I am not going to solve your current problem, because of the following line:
It is not worth it
And with this i don't mean that YOUR WORK is not worth it, but that nobody should still develop for IE6. It's a 10 years old browser, which should be put to sleep as soon as possible. And it's not just my opinion, but Microsoft's! see HERE and notice the Microsoft copyright at page footer.
Also, see HERE for browser usage statistics: IE6 is used by just 0.6% of internet users. Is your time worth it?

including span in php array?

I'm still learning php, so I'm not entirely sure how to address..
I need to have an image and some text display in a php array. Currently, I'm using a span but it's not working properly- only one span is showing the image I've established in the stylesheet.
I'm wondering if there is a better way to achieve this, or if I've just missed an error?
live site
<div class="pagination">
<ul>
<li><?php previous_post_link('<span class="left-arrow"></span> older posts'); ?></li>
<li><?php next_post_link('<span class="right-arrow"></span> newer posts'); ?></li>
</ul>
</div><!-- end pagination -->
#blog .pagination {
background: url('img/arrow_left.png') no-repeat;
height: 169px;
width: 635px;
float: right;
margin-right: 14px;
padding-bottom: 20px;
text-align:center;
}
#blog .pagination ul {
display:inline;
margin: 0 auto;
}
#blog .pagination ul li {
display: inline;
margin: 0 auto;
width: 290px;
}
#blog .pagination .left-arrow {
padding-right: 20px;
}
#blog .pagination .right-arrow {
padding-left: 20px;
}
#blog .pagination .left-arrow span {
background: url('arrow_left.png') no-repeat;
}
#blog .pagination .right-arrow span {
background: url('arrow_right.png') no-repeat;
}
I think the problem is your #blog .pagination shows the left_arrow.png as a background image. The #blog .pagination .left-arrow span and .right-arrow span are not showing because the extra span on the end means your need another span inside the span with that class name..
→ Try this at the top:
<div class="pagination">
<ul>
<li><?php previous_post_link('<span class="left-arrow"><span> ... </span></span> older posts'); ?></li>
<li><?php next_post_link('<span class="right-arrow"><span> ... </span></span> newer posts'); ?></li>
</ul>
</div><!-- end pagination -->
Does the arrow show up now?
#blog .pagination .left-arrow span {
background: url('arrow_left.png') no-repeat;
}
#blog .pagination .right-arrow span {
background: url('arrow_right.png') no-repeat;
}
This code will attempt to put a background image in a <span> that is inside a block with class="right-arrow", which is not the same thing as <span class="right-arrow">.
I'm not sure why one of them is working though. If you name your classes like this it might work better: #blog .pagination span.left-arrow or just span.left-arrow
The problem on you #blog is with the right arrow image. You have entered an incorrect source for the image.
If you correct the image source, right arrow image will show.
correct:
#blog .pagination span.left-arrow {
background: url('img/arrow_left.png') no-repeat;
}
#blog .pagination span.right-arrow {
background: url('img/arrow_right.png') no-repeat;
}

New line (in the code) after <li> element breaking layout

Weirdly, I've never come across this issue before, but I've just started making a site and the top navigation isn't playing nicely.
I want a small amount of white space between each menu item, but when I have new lines between my <li> elements and my <a> elements in my IDE (Netbeans), the white space disappears, yet it looks fine if I have <li><a></a></li> all on the same line. I was always under the impression html ignored white space in the code.
I've checked for any weird characters causing problems in other text editors and can't find anything.
Here's the code...
Like this the menu looks correct but code looks ugly (I know it looks fine when it's this simple, but I'm going be adding more complexity in which makes it look awful all on one line):
<ul id="menu">
<li>About</li>
<li class="active">Track List</li>
<li>Stats</li>
<li>Stats</li>
</ul>
Produces:
Like this the menu looks wrong but code looks fine:
<ul id="menu">
<li>
About
</li>
<li class="active">
Track List
</li>
<li>
Stats
</li>
<li>
Stats
</li>
</ul>
Produces:
wrong http://img708.imageshack.us/img708/6628/screenshot20100618at000.png
I'm sure it's something simple I'm doing wrong... but can someone shed some light on this for me?
Sorry for the lengthy post (my first on stackoverflow).
Edit - Full CSS and HTML:
body {
/* font-family: 'Lucida Sans Unicode', 'Lucida Grande', sans-serif; */
font-family: 'Trebuchet MS', Helvetica, sans-serif;
/* font-family: 'Copperplate', 'Copperplate Gothic Light', sans-serif; */
}
a {
color: #FFFFFF;
text-decoration: none;
}
#container{
margin: 0 auto;
width: 800px;
}
#content {
margin-top: 50px;
}
#header {
background-image: url("../images/absolute_radio_logo.png");
border-bottom: solid 1px #777777;
background-repeat: no-repeat;
width: 800px;
height: 86px;
padding-bottom: 15px;
}
#menu {
float: right;
}
#menu li {
display: inline;
padding: 5px;
background-color: #932996;
border-bottom: solid 1px #932996;
}
#menu li:hover {
border-bottom: solid 3px #FF0000;
}
#menu li.active {
background-color: #58065e;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Radio - Statistics</title>
<link rel="stylesheet" type="text/css" href="http://localhost/resources/css/style.css" />
</head>
<body>
<div id="container">
<div id="header">
<ul id="menu">
<li>
About
</li>
<li class="active">
Track List
</li>
<li>
Stats
</li>
<li>
Stats
</li>
</ul>
</div>
<div id="content">
<!-- content -->
Elapsed Time: 0.0033 - Memory Used: 0.4MB
</div>
</div>
</body>
</html>
It seems to be totally fine with the CSS you supplied, so I'm guessing there must be some other rule affecting your links. Could you please supply us with a live preview or the full stylesheet?
Edit:
Seems to be an issue with how "display: inline" collapses the elements contents, though I couldn't find any proof of that. Change
#menu li {
display: inline;
}
to
#menu li {
display: inline-block;
}
or add a margin to it:
#menu li {
display: inline;
margin-right: 5px;
}
To fix the alignment of the text, I'll go ahead and recommend you float the lis. Someone please correct me if this is a horrible idea. Add
#menu {
overflow: hidden;
}
#menu li {
float: left;
}
to your existing rules.
Just as a guess try setting the line-height for the li & a tags to 1em or even 0
#menu li, #menu a {
line-height: 1em;
}
Firstly, those two screenshots appear to be swapped around, the first has gaps between the links, caused by the white-space in the second code snippet.
This new white-space-collapse property may be able to help.
#menu li{white-space-collapse:discard}
via: http://safalra.com/web-design/html-and-css/white-space-property/
If that doesn't work, the next option is to set the <a> tags to block level elements and the <li> tags to inline.
#menu li{display:inline}
#menu li a{
display:inline-block
padding: 5px;
background-color: #932996;
border-bottom: solid 1px #932996;
}
#menu li a:hover{
border-bottom: solid 3px #FF0000;
}
#menu li.active a {
background-color: #58065e;
}
so it seems the targeted answer's have all been provided, so I'd just like to add that as a rule of thumb I always use normalize.css which is a css library that ensures normal
you can download it or use npm install normalize.css
You must set overflow: hidden on the parent box, then set position: relative on the <li>:
ul {
margin: 0;
display: flex;
flex-wrap: wrap;
padding: 25px;
margin: 5px 0;
overflow: hidden
}
ul li {
display: inline-block;
padding: 19px 10px;
text-align: center;
position: relative
}
ul li::before {
content: '';
position: absolute;
width: 400%;
height: 1px;
background: #f3f3f3;
bottom: 0;
right: -250px
}

Categories