z-index is not working for navigation bar - css

I have a drop-down CSS menu. The drop down <div> should start above the page, behind my fixed navigation bar and when a navigation button is "moused over". It uses a CSS transition to move the submenu down the page, making it visible.
The problem is.. it keeps rendering the submenu above my navigation bar (in terms of z-index). I need it to render behind the navigation bar.
Click here to see the webpage
(The page is intentionally aligned to the left for now - ignore this)
Here is how the HTML is layed out:
<div id="nav">
<ul>
<li>Title 1</li> <!-- has no submenu -->
<li>Title 2
<div>
<!-- Submenu Content -->
</div>
</li>
</ul>
</div>
and here is my CSS:
#nav {
position:absolute;
width:<?php echo ($navbutwidth*$numititles)+($numititles-1); ?>px;
background-color:<?php echo $colnavbg; ?>;
z-index:5 !important;
}
#nav ul {
list-style-type:none;
margin:0;
padding:0;
overflow:hidden;
width:<?php echo $navbarwidth; ?>px;
z-index:3 !important;
}
#nav ul li {
float:left;
}
#nav ul li > a {
width:<?php echo ($navbutwidth-16); ?>px;
height:<?php echo $navbutheight; ?>px;
line-height:<?php echo $navbutheight; ?>px;
display:block;
text-decoration:none;
border-left:1px Solid <?php echo $colnavbutborder; ?>;
padding-left:15px;
background-color:<?php echo $colnavbutbg; ?>;
color:<?php echo $colnavbuttxt; ?>;
border-radius:10px 10px 0px 0px;
}
#nav ul li > a:hover {
background-color:<?php echo $colnavbutbghov; ?>;
color:<?php echo $colnavbuttxthov; ?>;
}
#nav ul li > div {
position:absolute;
top:-<?php echo $navsubbutheight-$navbutheight; ?>px;
left:0px;
width:<?php echo $navsubbutwidth; ?>px;
height:<?php echo $navsubbutheight-1; ?>px;
text-align:left;
display:block;
padding:0;
background-color:<?php echo $colsubnavbutbg; ?>;
border-top:1px Solid #FFF;
border-bottom:1px Solid #FFF;
z-index:1 !important;
-webkit-transition:all 0.2s ease-in-out;
-ms-transition:all 0.2s ease-in-out;
transition:all 0.2s ease-in-out;
}
#nav ul li:hover > div {
top:<?php echo $navbutheight; ?>px;
display:block;
}
#nav ul li > div:hover {
background-color:<?php echo $colnavbutbghov; ?>;
}

Add position: relative; z-index: 1000; to .a1.
Having overflow: hidden on your ul will prevent anything outside that ul from showing up.

Related

WordPress Query Image Size

How can I make the slider box frame bigger within the query for my Church website slider. The $width and $height only changes the size of image. The image on the slider is getting chopped off - I want to show image slider box as big as the frame. Or how can I crop the image so it won't cut it off - to see the full image size click on image to see the post.
I want to make the width of slider box 600 and the height 300 but the letters at the bottom of box keep changing position and doesn't look right.
Website: brbconline.org
<div id="featuredContainer">
<div id="featured">
<ul>
<?php query_posts( 'posts_per_page=5' ); ?>
<?php $recentPosts = new WP_Query(); $recentPosts->query('category_name='. $church_slider .'&showposts= 7'.''); while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
<?php $image = ""; $first_image = $wpdb->get_results("SELECT guid FROM $wpdb->posts WHERE post_parent = '$post->ID' "."AND post_type = 'attachment' ORDER BY `post_date` ASC LIMIT 0,1"); if ($first_image) {$image = $first_image[0]->guid;} ?>
<?php $width = "570"; $height = "255"; ?>
<li>
<h2><?php the_title(); ?></h2>
<img class="featimg" src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php echo $image ?>&w=<?php echo $width ?>&h=<?php echo $height ?>&zc=1" alt="<?php the_title(); ?>" height="<?php echo $height ?>" width="<?php echo $width ?>" />
</li>
<?php endwhile; ?>
</ul>
</div>
</div> <!--end featuredContainer-->
CSS is here:
/* -----FEATURED STUFF----- */
#featuredContainer {margin:0 0 40px; padding: 0; width:560px;position:relative; height:290px; overflow:hidden; border: 1px solid #666; border-bottom:none;}
#featured {overflow:hidden; width:560px; height:290px; position:relative;}
#featured ul, #featured li{margin:0;padding:0;list-style:none; position:relative; overflow:hidden; width:560px; height:290px;}
#featured li h2 a {position: absolute; bottom:0; left: 0; line-height: 36px; padding:0; text-align:center; font-size: 12px; color: #fff; background-repeat: repeat-x; background-position: left center; width: 100%; font-weight:bold;}
#featured li h2 a {color:#fff;}
span#prevBtn a,
span#prevBtn a:link,
span#prevBtn a:visited,
span#nextBtn a,
span#nextBtn a:link,
span#nextBtn a:visited {
margin: 0;
font-weight:bold;
cursor: pointer;
position: absolute;
font-size:12px;
padding:8px 15px;
background: #6a3b14 url('images/buttonback.jpg') repeat-x center;
line-height:20px;
color:#fff;
font-weight:bold;
outline: none;
}
span#prevBtn a {bottom:0px; left:0px; border-right:1px solid #89642D;}
span#nextBtn a {bottom:0px; right:0px; border-left:1px solid #89642D;}
span#prevBtn a:hover, span#nextBtn a:hover {text-decoration: none; background: #6a3b14 url('images/buttonback.jpg') repeat-x top;}
span#prevBtn a:active, span#nextBtn a:active {background: #6a3b14 url('images/buttonback.jpg') repeat-x bottom;}

CSS Properties won't render

my CSS properties won't render. Fonts, widths etc. do nothing and I have no idea why. I've tried multiple things.
I'd like to have a percentage width for the nav and the logo but all render 100% width. It seems like I have a huge misunderstanding on how CSS works but after I read, I still don't get it. I have normalize.css added in Wordpress too.
If I add and span class around the text, it will change the text but it doesn't help with the issue of element size.
My Code:
*,
*:after,
*:before {
-moz-box-sizing:border-box;
box-sizing:border-box;
-webkit-font-smoothing:antialiased;
font-smoothing:antialiased;
text-rendering:optimizeLegibility;
}
a {
text-decoration:none;
}
body {
font-family: 'Roboto', sans-serif;
font-size:100%;
}
h1,h2,h3,h4,h5,h6 {
font-family: 'Rhodium Libre', serif;
}
header {
position:fixed;
top:0px;
width:100%;
background-color:#000;
opacity:0.9;
z-index:10000;
}
//desktop
/*logo*/
.logo-holder {
position:relative;
float:left;
display:inline-block;
font-family: 'Rhodium Libre', serif;
font-size:2.4em;
background-color:white;
width:200px;
}
/* nav */
.nav-holder {
position:relative;
float:right;
width:500px;
}
nav {
}
/*nav design*/
nav ul {
display:inline;
}
nav ul li {
position:relative;
display:inline-block;
cursor:pointer;
padding-top:4px;
padding-bottom:4px;
font-family:'Rhodium Libre', serif;
font-size:1.35em;
}
nav ul li:hover, nav ul li:active {
background:transparent;
color:#5F8E14;
}
nav ul li a {
padding-left:0.5em;
color:#FFF;
}
nav ul li a:hover, nav ul li a:active {
color:#5F8E14;
}
//sub menu
nav.sub {
}
nav.sub ul {
display:inline;
}
nav.sub ul li {
position:relative;
display:inline-block;
cursor:pointer;
padding-top:2px;
padding-bottom:2px;
font-family:'Rhodium Libre', serif;
font-size:1.1em;
}
nav.sub ul li:hover, nav.sub ul li:active {
background:transparent;
color:transparent;
}
nav.sub a:hover, nav.sub ul li a:active {
text-decoration: underline;
}
<body>
<!-- header -->
<header>
<div class=logo-holder">
why is nothing changing here?
</div>
<div class="nav-holder">
<nav>
<?php wp_nav_menu( array( 'theme_location' => 'header-menu' ) ); ?>
</nav>
<nav class="sub">
<?php wp_nav_menu( array( 'theme_location' => 'sub-menu' ) ); ?>
</nav>
</div> <!--nav holder-->
</header>
<!-- /header -->
</body>
Thanks for any help!
// does not make a valid comment in CSS. /* ... */ does.
Also,
<div class=logo-holder">
is obviously lacking a ".

Why does the navbar change position when using the dropdown menu?

I've some troubles with the navigation bar from my website. The position of the navigation bar changes when the dropdown menu becomes visible.
Also when resizing the browser the navigation bar change.
This is ofcource not really my intention. So please can someone help me?
I would appreciated very much.
This is my css code I'm using.
/*main menu*/
.nav-top {list-style:none;
}
ul.nav-top ul { margin-top:-40px; margin-bottom:-50px; margin-left:-21px; margin-right:-50;
position: relative; display:none; }
ul.nav-top li { display:inline-block;
padding:40px;
margin-right:19px;
position:relative;
}
ul.nav-top li:hover> ul { display:block; }
ul.nav-top li a { display:block;
text-decoration:none;
border-bottom: 2px solid transparent;
}
ul.nav-top a:hover{ color:#686A6A;
border-bottom:2px solid #E4E4E4;
}
/*sub menu*/
ul.nav-top ul ul { clear:both;
border: solid 1px ffffff; }
ul.nav-top li li {
display:block;
/* Introducing a padding between the li and the a give the illusion spaced items */
padding:2px; padding-top:10px;
}
ul.nav-top ul ul li {
}
ul.nav-top ul ul a{
white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */
}
ul.nav-top ul ul li:hover a{ /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
text-decoration:none; background:#FFF;
}
ul.nav-top ul ul li:hover a:hover{ /* Here we define the most explicit hover states--what happens when you hover each individual link. */
color:#686A6A; border-bottom:2px solid #E4E4E4;
}
thanks for your answer.
This is my HTML:
</head>
<body>
<div id="header">
<img src="images/logo-marco-kaller.png">
<ul class="nav-top">
<li>home</li>
<li>about</li>
<li>work
<ul>
<li>design</li>
<li>paintings</li>
<li>sculptures</li>
</ul>
<li>shop</li>
<li>news</li>
<li>contact</li>
</ul>
</div>
<div id="background"></div>
<div class="wrapper">
<div id="content-background"><br>
<h1>Marco Kaller</h1>
<p>Welkom op de site van Marco Kaller!</p>
<div id="content">
</div>
</div>
</div>
<div id="footer">
<img width="25" height="25" alt="facebook Marco Keller" src="images/facebook.png" />
<ul class="talen">
<li>language:</li>
<li>en</li>
<li>nl</li>
<li>de</li>
</ul>
<hr class="faded" />
</div>

Specific display of inline-block with H1 and Image

I'm making my page and while doing it I've encountered a big problem for me because it makes my all effort useless if i can't do it.
In my page Header with menu and everything i can't make 3 images and one H1 to be displayed inline. I wouldn't be posting but I've tried everything and it doesn't work. in a trivial web site it works perfectly but i don't know why in my it doesn't work...
here is my code.
<div id="header">
<img src="img/pl.jpg" width="25" height="15" alt="pl">
<img src="img/no.jpg" width="25" height="15" alt="no">
<img src="img/usgb.jpg" width="25" height="15" alt="en">
<h1 class="title"><?php echo $TITLE; ?></h1>
<div id="nav">
<?php echo $ABOUTME; ?>
<?php echo $GOALS; ?>
<?php echo $ACHIEVEMENTS; ?>
<?php echo $CV; ?>
<?php echo $CREATIVITY; ?>
<?php echo $FREETIME; ?>
<?php echo $CONTACT; ?>
<div class="navEnding"></div>
</div>
And my CSS:
#header {
position:fixed;
margin:0;
padding:0;
top:0%;
left:0%;
width:20%;
height:100%;
z-index:50;
color:#f9f89d;
font-family:"Allura", cursive;
font-size:130%;
background:#f00;
}
.languageFlag { position:relative; display:inline-block; margin:0; padding:0; width:auto; }
.languageFlag img { display:inline-block; width:100%; height:100%; }
.title { position:relative; display:inline-block; margin:0%; padding:0; left:200%; width:200%; height:5%; overflow:hidden; }
#nav {
position:relative;
margin:0;
padding:0;
width:500%;
height:500%;
background:#00f;
}
#nav a:link, #nav a:visited {
display:inline-block;
margin:0.5% 0;
background:#385160;
text-align:left;
text-decoration:none;
border:0;
color:#f9f89d;
}
#nav a:hover, #nav a:active {
text-align:right;
}
.nav1 { width:55%; padding:0 40% 0 5%; }
.nav2 { width:45%; padding:0 50% 0 5%; }
.nav3 { width:35%; padding:0 60% 0 5%; }
.nav4 { width:30%; padding:0 65% 0 5%; }
.nav5 { width:25%; padding:0 70% 0 5%; }
.nav6 { width:20%; padding:0 75% 0 5%; }
.nav7 { width:15%; padding:0 80% 0 5%; }
.navEnding { display:inline-block; margin:0.5% 0; background:#385160; width:90%; min-height:10%; }
Try this. I also removed some unnecessary css.
Fiddle
CSS
#header {
position:fixed;
margin:0;
padding:0;
top:0%;
left:0%;
width:100%;
height:20%;
z-index:50;
color:#f9f89d;
font-family:"Allura", cursive;
font-size:130%;
background:#f00;
}
.languageFlag {
position:relative;
display:inline-block;
margin:0;
padding:0;
width:auto;
}
.languageFlag img {
display:inline-block;
width:100%;
height:100%;
}
.title {
display:inline-block;
}
#header is not long enough for the h1 to fit inside it. try making width:100%
#header {
width: 100%;
}
http://jsfiddle.net/MtcSY/
Edit: hand rolling this advanced css can be very dififcult, I would recommend using a framework like bootstrap

Strange CSS behavior

Sorry for the length of the post. This is quite a weird problem and I want to give as much info as possible.
I have the following css rules I am using for a horizontal navigation menu. The menu is created using ASP:repeaters and a database table of items.
#nav
{
margin: 0px;
padding:0px;
list-style-type: none;
height: 20px;
margin-right:auto;
margin-left:auto;
width:726px;
}
#nav > li
{
margin:0px;
padding:0px;
display:inline-block;
color: #FFFFFF;
height:17px;
border:0px;
width:90.75px;
text-align:center;
position:relative;
float:left;
}
#nav > li > ul
{
margin:0px;
padding:0px;
position: absolute;
left: -999em;
display:block;
overflow:visible;
z-index:100;
width:150px;
background-color:#eee;
}
#nav > li:hover > ul
{
left:0px;
z-index:100;
box-shadow: 0px 0px 5px #555;
-moz-box-shadow: 0px 0px 5px #555;
-webkit-box-shadow: 0px 0px 5px #555;
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
/* IE 5-7 */
filter: alpha(opacity=80);
/* Netscape */
-moz-opacity: 0.8;
/* Safari 1.x */
-khtml-opacity: 0.8;
/* Good browsers */
opacity: 0.8;
}
#nav > li > ul > li
{
left:0px;
display:block;
color:#333;
width:150px;
text-align:left;
height:auto;
}
#nav a, #navbottom a
{
line-height:20px;
display:block;
height:20px;
border-bottom:2px solid #0c1b53;
}
#nav a:link, #navbottom a:link, #nav a:visited, #navbottom a:visited
{
border-bottom:2px solid #0c1b53;
color: #FFFFFF;
text-decoration: none;
}
#nav a:hover, #navbottom a:hover
{
border-bottom:2px solid #fff;
}
#nav a:active, #navbottom a:active
{
border-bottom:2px solid #fff;
color: #FEFFBD;
text-decoration: none;
}
#nav > li > ul > li a:link
{
margin:10px;
line-height:15px;
height:auto;
color:#444;
border-bottom: 1px solid #777;
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
/* IE 5-7 */
filter: alpha(opacity=100);
/* Netscape */
-moz-opacity: 1.0;
/* Safari 1.x */
-khtml-opacity: 1.0;
/* Good browsers */
opacity: 1.0;
}
#nav > li > ul > li a:hover
{
color:#222;
border-bottom: 1px solid #555;
}
The HTML it produces is below:
<ul id="nav">
<li>
<input type="hidden" name="ctl00$TopNavRepeat$ctl01$LinkIdField1" id="ctl00_TopNavRepeat_ctl01_LinkIdField1" value="1" />
<a id="ctl00_TopNavRepeat_ctl01_HyperLink1" title="Home Page" href="../default.aspx">Home </a>
<ul></ul>
</li>
<li>
<input type="hidden" name="ctl00$TopNavRepeat$ctl02$LinkIdField1" id="ctl00_TopNavRepeat_ctl02_LinkIdField1" value="10" />
<a id="ctl00_TopNavRepeat_ctl02_HyperLink1" title="News from the IMA" href="../news/list.aspx">News </a>
<ul></ul>
</li>
<li>
<input type="hidden" name="ctl00$TopNavRepeat$ctl03$LinkIdField1" id="ctl00_TopNavRepeat_ctl03_LinkIdField1" value="11" />
<a id="ctl00_TopNavRepeat_ctl03_HyperLink1" title="About the IMA" href="../organisation/history.aspx">Organisation </a>
<ul>
<li><a id="ctl00_TopNavRepeat_ctl03_DropDownList_ctl01_HyperLink1" title="about the IMA" class="dropdown_Item" href="../organisation/history.aspx">About </a>
</li>
<li><a id="ctl00_TopNavRepeat_ctl03_DropDownList_ctl02_HyperLink1" title="This is a description" class="dropdown_Item" href="list.aspx?type=all">Members </a>
</li>
<li><a id="ctl00_TopNavRepeat_ctl03_DropDownList_ctl03_HyperLink1" class="dropdown_Item" href="../Boats/list.aspx#">Boats</a>
</li>
</ul>
</li>
<li>
<input type="hidden" name="ctl00$TopNavRepeat$ctl06$LinkIdField1" id="ctl00_TopNavRepeat_ctl06_LinkIdField1" value="14" />
<a id="ctl00_TopNavRepeat_ctl06_HyperLink1" href="../adverts">Ads </a>
<ul>
<li><a id="ctl00_TopNavRepeat_ctl06_DropDownList_ctl01_HyperLink1" title="All For Sale Items" class="dropdown_Item" href="../adverts/list.aspx?type=sale">For Sale </a>
</li>
<li><a id="ctl00_TopNavRepeat_ctl06_DropDownList_ctl02_HyperLink1" title="All Wanted Items" class="dropdown_Item" href="../adverts/list.aspx?type=wanted">Wanted </a>
</li>
<li><a id="ctl00_TopNavRepeat_ctl06_DropDownList_ctl03_HyperLink1" title="Advertise with the IMA" class="dropdown_Item" href="../adverts/edit.aspx?action=New">Post an Ad </a>
</li>
</ul>
</li>
</ul>
The Menu this produces (some list items have been omitted for shortness) is below. Despite the two item "Organisation" and "Ads" each having three child items and despite each child item seeming to be identical the second item in organisation displays with the rules for nav > li a instead of nav > li > ul > li a.
As the menu displays http://dl.dropbox.com/u/4913815/Untitled.png
I've been going through it and as far as i cant tell what is happening. Can anyone explain this?
There is no #nav > li > ul > li a:visited or active rules defined. The members link is taking information from the #nav a:active instead and so displaying incorrectly.
Changing #nav > li > ul > li a:link to #nav > li > ul > li a:link, #nav > li > ul > li a:visited, #nav > li > ul > li a:active fixes this issue

Resources