css deformed submenu second option and z-index - css

I'm creating a submenu for my website but it needs some little fixes.
First, I can't make the z-index work, is displayed under the content div, in the live example I removed all z-index, and righ now, I really have no idea how this works :(
Second, in the submenu from second option, the box is more large than the first one. I'm trying to fix it but I don't see where the problem is.
/* Sub-menu */
#main-nav ul {
list-style: none;
margin: 0;
padding: 0;
display: none;
position: absolute;
/* rounded corner */
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
#main-nav ul li {
float: none;
display: block;
/* box shadow */
-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 1px 1px rgba(0, 0, 0, .4);
-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 1px 1px rgba(0, 0, 0, .4);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 1px 1px rgba(0, 0, 0, .4);
/* rounded corner */
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
}
#main-nav ul li:last-child {
box-shadow: none;
}
#main-nav ul a {
color: #fff;
background: #474747;
display: block;
white-space: nowrap;
}
#main-nav ul a:hover {
/* gradient */
background: #6a6a6a url(images/nav-bar-bg.png) repeat-x;
background: -webkit-gradient(linear, left top, left bottom, from(#b9b9b9), to(#6a6a6a));
background: -moz-linear-gradient(top, #b9b9b9, #6a6a6a);
background: linear-gradient(-90deg, #b9b9b9, #6a6a6a);
background-image: linear-gradient(-90deg, #cdcdcd, #797979);
}
#main-nav ul li:first-child a {
/* rounded corner */
-webkit-border-radius: 8px 8px 0 0;
-moz-border-radius: 8px 8px 0 0;
border-radius: 8px 8px 0 0;
}
#main-nav ul li:last-child a {
/* rounded corner */
-webkit-border-radius: 0 0 8px 8px;
-moz-border-radius: 0 0 8px 8px;
border-radius: 0 0 8px 8px;
}
#main-nav ul li:first-child a:after {
content:'';
position: absolute;
left: 30px;
top: -8px;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid #444;
}
#menu ul li:first-child a:hover:after {
border-bottom-color: #fafafa;
}
#main-nav:after {
visibility: hidden;
display: block;
font-size: 0;
content:" ";
clear: both;
height: 0;
}
Here's a live example: http://jsfiddle.net/y59kjsLn/1/
Thanks in advance!
Edit: add more css
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clearfix { display: inline-block; }
.clearfix { display: block; zoom: 1; }
Chan this cause the z-index problem?
Edit2: Add the html code
Hmmm maybe has something to do with...
<div id="content">
<article class="post clearfix">
<?php
if(array_key_exists($matches[1], $includes)) {
$content = include($includes[$matches[1]]);
} else header("Location: /home");
?>
</article>
</div>
This is just behind the menu.
#content CSS code:
#content {
opacity: 0.8;
background: #fff;
margin: 30px 0 30px;
padding: 20px 35px;
width: 600px;
float: left;
/* rounded corner */
-webkit-border-radius: 8px;
-moz-border-radius: 8px;
border-radius: 8px;
/* box shadow */
-webkit-box-shadow: 0 1px 3px rgba(0,0,0,.4);
-moz-box-shadow: 0 1px 3px rgba(0,0,0,.4);
box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
#content .error {
color: red;
text-align: center;
}
#content .note {
font-size: 80%;
text-align: center;
}
#content p {
margin-top: 30px;
}
h2.post-title {
margin-top: 15px;
background: #888;
border-radius: 5px;
padding: 0px 5px ;
border-top: 1px solid #889;
border-bottom: 1px solid #889;
text-align: center;
}
h2.post-title a {
color: #FFFFFF;
font-size: 0.9em;
text-shadow: 1px 1px 2px #333333;
}
.post {
margin-bottom: 20px;
}
.post-title {
margin: 0 0 5px;
padding: 0;
font: bold 26px/120% Arial, Helvetica, sans-serif;
}
.post-title a {
text-decoration: none;
color: #000;
}
.post-meta {
margin: 0 0 10px;
font-size: 90%;
}
figure.post-imagen img {
float: left;
margin: 5px;
max-width: 260px;
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clearfix { display: inline-block; }
.clearfix { display: block; zoom: 1; }

Js Fiddle
removed the margin which was affecting the sub menu
#main-nav li:first-child {
margin-left: 10px;
}
edit
Remove and Add
#content
opacity: 0.8; /* removed */
background: rgba(255, 255, 255, 0.55); /* added */
}

Related

Creating space between Side Buttons

I'm trying to create a space down the left hand side of my page for social media buttons, my problem is the buttons will not spread apart to where there is a large enough gap between buttons.
enter image description here
body {
background: darkgrey;
background-image:url('../https://www.dropbox.com/home?preview=city.jpg');
font-family: arial;
}
#wrapper {
width: 800px;
margin: 100px auto 0 auto;
padding-bottom: 20px;
}
#header {
width: 800;
height: auto;
margin: 0;
background: transparent;
}
.logo{
text-align: center;
}
#tabs{
overflow: hidden;
width: 100%;
margin: 0;
padding: 0;
list-style: none;
}
#tabs li{
float: left;
margin: 0 .5em 0 0;
}
#tabs a{
position: relative;
background: #ddd;
background-image: linear-gradient(to bottom, #ccc, #ddd);
padding: .7em 3.5em;
float: left;
text-decoration: none;
color: #444;
text-shadow: 0 1px 0 rgba(255,255,255,.8);
border-radius: 5px 0 0 0;
box-shadow: 0 2px 2px rgba(0,0,0,.4);
}
#tabs a:hover,
#tabs a:hover::after,
#tabs a:focus,
#tabs a:focus::after{
background: #fff;
}
#tabs a:focus{
outline: 0;
}
#tabs a::after{
content:'';
position:absolute;
z-index: 1;
top: 0;
right: -.5em;
bottom: 0;
width: 1em;
background: #ddd;
background-image: linear-gradient(to bottom, #ccc, #ddd);
box-shadow: 2px 2px 2px rgba(0,0,0,.4);
transform: skew(10deg);
border-radius: 0 5px 0 0;
}
#tabs #current a,
#tabs #current a::after{
background: #fff;
z-index: 3;
}
#content
{
background: #fff;
padding: 2em;
height: 520px;
position: relative;
z-index: 2;
border-radius: 0 5px 5px 5px;
box-shadow: 0 -2px 3px -2px rgba(0, 0, 0, .5);
}
p {text-align:left;
line-height:120%;
margin-right: 2cm;
letter-spacing: 0px;
}
#icons {
position: absolute;
top: 86px;
left: -90px;
z-index: 3;
}
table {border: solid darkgrey thin;
}
}
footer {
display: inline-block;
width:800px;
text-align: left;
margin-top: 250px;
}
footer ul {list-style-type: none;
text-align: center;
float: left;
}
footer li {display:inline;
margin-left: 20px;
}
footer a:link{
text-decoration: none;
}
footer p {
float:right;
}
.menu {
word-spacing: 10px;
}

CSS submenu option jumps around

I have a CSS menu on this page: http://itos3test.notexa.be/itos3test/customer-service-oplossingen/. When you hover over "rol van het contact center" or "Bedrijfs doelstellingen" you can see that the submenu has 2 rows.
When I now hover over the third submenu ("Verkoop fondsenwerving" or "Klanten-Trouw verhogen") the fourth submenu jumps to the right, the gap between the first and second row becomes smaller and the items after the fourth display on a third row.
I tried searching for the css that is causing this with firebug, and as far as I can see the containers are all of the correct size. Maybe it inherits something, or I made a horrible mistake in the css, but I just can't see it.
The CSS code:
/* style main menu */
ul.shortcode_menu.solution-finder {
display: inline;
}
ul.shortcode_menu.solution-finder li {
list-style: none;
background: linear-gradient(#00A7FF 3.8%, #27027B) repeat scroll 0 0 #00A7FF;
border-radius: 2px;
float: left;
margin: 0 0 1em 1em;
padding: 0px;
text-align: center;
max-width: 150px;
width: 100%;
height: 80px;
}
ul.shortcode_menu.solution-finder li:hover {
background: linear-gradient(#54575A, #54575A) repeat scroll 0 0 rgba(0, 0, 0, 0);
border-left: 1px solid rgba(106, 115, 123, 0.5);
border-radius: 2px 2px 0 0;
border-right: 1px solid rgba(106, 115, 123, 0.5);
border-top: 1px solid rgba(106, 115, 123, 0.5);
margin-bottom: 0;
}
ul.shortcode_menu.solution-finder li a {
max-width: 150px;
width: 99%;
height: 65px;
margin: 0px;
float: left;
text-align: center;
padding-top: 15px;
color: #FFFFFF;
font-size: 18px;
text-decoration: none;
text-shadow: 0 1px 2px #000000;
}
ul.shortcode_menu.solution-finder li:hover a {
opacity: 0.9;
color: #FFFFFF !important;
}
/* style sub menus */
ul.shortcode_menu.solution-finder li ul.sub-menu {
width: 600px;
}
ul.shortcode_menu.solution-finder li ul.sub-menu li {
display: inline-block !important;
list-style: none;
max-width: 150px;
width: 100%;
height: 80px;
border: 1px solid #DDD;
margin-top: 0.2em;
margin-right: 0.2em;
margin-left: 0;
text-align: center;
padding: 0px 0px;
font-size: 18px;
color: #FFFFFF;
text-shadow: 2px 2px 5px #EEE;
}
ul.shortcode_menu.solution-finder li ul.sub-menu li:hover {
color: #FFFFFF;
text-shadow: none;
}
ul.shortcode_menu.solution-finder li ul.sub-menu li a {
max-width: 150px;
width: 99%;
height: 65px;
/* background: linear-gradient(#00A7FF 3.8%, #27027B) repeat scroll 0 0 #00A7FF;*/
display: block;
}
ul.shortcode_menu.solution-finder li ul.sub-menu li:hover a {
/* opacity: 0.9;
background: linear-gradient(#54575A, #54575A) repeat scroll 0 0 rgba(0, 0, 0, 0);
border-left: 1px solid rgba(106, 115, 123, 0.5);
border-radius: 2px 2px 0 0;
border-right: 1px solid rgba(106, 115, 123, 0.5);
border-top: 1px solid rgba(106, 115, 123, 0.5);
margin-bottom: 0;*/
}
Anybody got an idea ?
Found it: margin-bottom: 0 was the problem

horizontally sub menu should slide content down

I have some issues with my horizontal menu. The main content should avoid the sub menu. So when the sub menu opens it should shove the main content down.
The html
<ul id="menu">
<li class="active">Menu1</li>
<li class="active">Menu2
<ul>
<li class="active">Sub 1</li>
<li class="active">Sub 2</li>
<li class="active">Sub 3</li>
<li class="active">Sub 4</li>
</ul>
</li>
and the css
#menu{
width: 100%;
margin-left:auto;
margin-right:auto;
padding: 15px 0 0 0;
list-style: none;
background: #111;
background: -moz-linear-gradient(#444, #111);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #111),color-stop(1, #444));
background: -webkit-linear-gradient(#444, #111);
background: -o-linear-gradient(#444, #111);
background: -ms-linear-gradient(#444, #111);
background: linear-gradient(#444, #111);
-moz-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 2px 1px #9c9c9c;
-webkit-box-shadow: 0 2px 1px #9c9c9c;
box-shadow: 0 2px 1px #9c9c9c;
min-width: 1100px;
position: relative;
clear: both;
text-align:center;
}
#menu li{
display: inline-block;
padding: 0 0 10px 0;
}
#menu a{
float: left;
padding: 0px 50px 0 0;
color: #999;
text-transform: uppercase;
font: bold 12px/25px Arial, Helvetica;
text-decoration: none;
text-shadow: 0 1px 0 #000;
height: 30px;
}
#menu li:hover > a{
color: #fafafa;
}
*html #menu li a:hover{ /* IE6 */
color: #fafafa;
}
#menu li:hover > ul {
display: block;
}
/* Sub-menu */
#menu ul{
width: 100%;
margin: 0px 0 0 0;
padding: 15px 0 0 0;
list-style: none;
display: none;
position: absolute;
top: 55px;
left: 0px;
background: #111;
background: -moz-linear-gradient(#444, #111);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #111),color-stop(1, #444));
background: -webkit-linear-gradient(#444, #111);
background: -o-linear-gradient(#444, #111);
background: -ms-linear-gradient(#444, #111);
background: linear-gradient(#444, #111);
-moz-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 2px 1px #9c9c9c;
-webkit-box-shadow: 0 2px 1px #9c9c9c;
box-shadow: 0 2px 1px #9c9c9c;
min-width: 1100px;
}
}
#menu ul li{
float: left;
padding: 0 0 10px 0;
position: relative;
}
#menu ul a{
float: left;
height: 30px;
padding: 0px 25px;
color: #999;
text-transform: uppercase;
font: bold 12px/25px Arial, Helvetica;
text-decoration: none;
text-shadow: 0 1px 0 #000;
}
#menu ul a:hover{
background: #0186ba;
background: -moz-linear-gradient(#04acec, #0186ba);
background: -webkit-gradient(linear, left top, left bottom, from(#04acec), to(#0186ba));
background: -webkit-linear-gradient(#04acec, #0186ba);
background: -o-linear-gradient(#04acec, #0186ba);
background: -ms-linear-gradient(#04acec, #0186ba);
background: linear-gradient(#04acec, #0186ba);
}
/* Clear floated elements */
#menu:after{
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
* html #menu { zoom: 1; } /* IE6 */
*:first-child+html #menu { zoom: 1; } /* IE7 */
I tried to change the #menu ul position to relative. But that messes up the whole style.
Anybody who likes to help me? =)
JSFIDDLE: http://jsfiddle.net/M8S3T/
The elements that are absolutely or fixed positioned are removed from the normal flow of the page. You must avoid position:absolute if you want to preserve the flow.
I try to make a quick example to show: http://jsfiddle.net/M8S3T/1/
#menu li{
float:left;
padding: 0 0 10px 0;
width:5em;
}
/* Sub-menu */
#menu ul{
width: 100%;
margin: 40px -80px 0;
padding: 15px 0 0 0;
list-style: none;
display: none;
background: #111;
background: -moz-linear-gradient(#444, #111);
background: -webkit-gradient(linear,left bottom,left top,color-stop(0, #111),color-stop(1, #444));
background: -webkit-linear-gradient(#444, #111);
background: -o-linear-gradient(#444, #111);
background: -ms-linear-gradient(#444, #111);
background: linear-gradient(#444, #111);
-moz-border-radius: 3px;
border-radius: 3px;
-moz-box-shadow: 0 2px 1px #9c9c9c;
-webkit-box-shadow: 0 2px 1px #9c9c9c;
box-shadow: 0 2px 1px #9c9c9c;
min-width: 1100px;
}
#menu li ul li {
float:left;
padding: 0 0 10px 0;
width: 10em;
}
#menu ul a{
float: none;
height: 30px;
padding: 0px 25px;
color: #999;
text-transform: uppercase;
font: bold 12px/25px Arial, Helvetica;
text-decoration: none;
text-shadow: 0 1px 0 #000;
}
I only post you the parts I have changed. With this you can play with the float, and if you use a fixed width for the list items it will work.

Bootstrap fixed navbar getting stuck

I wasn't sure how else to title this but basically what is happening is the navbar seems to be leaving a ghost image of itself. It's fixed and functions otherwise perfectly but after scrolling down on a page, when I scroll back up, it leaves an image on the area of the page that I scrolled down to. The screenshot shows the problem, although I will mention the navbar is white so it's a poor example. When it has color it leaves a colored bar across the page.
I am totally new at web design in every way so please be descriptive when answering. Thanks!
MY BOOTSTRAP CSS:
.container,
.navbar-static-top .container,
.navbar-fixed-top .container,
.navbar-fixed-bottom .container {
width: 940px;
}
.container,
.navbar-static-top .container,
.navbar-fixed-top .container,
.navbar-fixed-bottom .container {
width: 940px;
}
.navbar {
overflow: hidden;
margin-bottom: 0px;
color: transparent;
*position: relative;
*z-index: 2;
}
.navbar-inner {
min-height: 50px;
/* padding-left: 20px; */
padding-right: 20px;
background-color: #ffffff;
/* background-image: -moz-linear-gradient(top, #ffffff, #f2f2f2);
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#f2f2f2));
background-image: -webkit-linear-gradient(top, #ffffff, #f2f2f2);
background-image: -o-linear-gradient(top, #ffffff, #f2f2f2);
background-image: linear-gradient(to bottom, #ffffff, #f2f2f2);
background-repeat: repeat-x; */
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#fff2f2f2', GradientType=0);
border: 1px solid #ed4542;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
-moz-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.065);*/
}
.navbar .container {
width: auto;
}
.nav-collapse.collapse {
height: auto;
}
.navbar .brand {
float: left;
display: block;
padding: 20px 20px 20px;
margin-left: -20px;
font-size: 20px;
font-weight: 200;
color: #555555;
text-shadow: 0 1px 0 #ffffff;
}
.navbar .brand:hover {
text-decoration: none;
}
.navbar-text {
margin-bottom: 0;
line-height: 30px;
}
.navbar-link {
color: #ed4542;
}
.navbar-link:hover {
color: #ed4542;
}
.navbar-form {
margin-bottom: 0;
*zoom: 1;
}
.navbar-form:before,
.navbar-form:after {
display: table;
content: "";
line-height: 0;
}
.navbar-form:after {
clear: both;
}
.navbar-form:before,
.navbar-form:after {
display: table;
content: "";
line-height: 0;
}
.navbar-form:after {
clear: both;
}
.navbar-form input,
.navbar-form select,
.navbar-form .radio,
.navbar-form .checkbox {
margin-top: 15px;
}
.navbar-form input,
.navbar-form select,
.navbar-form .btn {
display: inline-block;
margin-bottom: 0;
}
.navbar-form input[type="image"],
.navbar-form input[type="checkbox"],
.navbar-form input[type="radio"] {
margin-top: 3px;
}
.navbar-form .input-append,
.navbar-form .input-prepend {
margin-top: 6px;
white-space: nowrap;
}
.navbar-form .input-append input,
.navbar-form .input-prepend input {
margin-top: 0;
}
.navbar-static-top {
position: static;
width: 100%;
margin-bottom: 0;
}
.navbar-static-top .navbar-inner {
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}
.navbar-fixed-top,
.navbar-fixed-bottom {
position: fixed;
right: 0;
left: 0;
z-index: 1030;
margin-bottom: 0;
}
.navbar-fixed-top .navbar-inner,
.navbar-fixed-bottom .navbar-inner,
.navbar-static-top .navbar-inner {
border: 0;
}
.navbar-fixed-top .navbar-inner,
.navbar-fixed-bottom .navbar-inner {
padding-left: 0;
padding-right: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
}
.navbar-static-top .container,
.navbar-fixed-top .container,
.navbar-fixed-bottom .container {
width: 1200px;
}
.navbar-fixed-top {
top: 0;
}
.navbar-fixed-top .navbar-inner,
.navbar-static-top .navbar-inner {
/* -webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,.1), 0 1px 10px rgba(0,0,0,.1);
-moz-box-shadow: inset 0 -1px 0 rgba(0,0,0,.1), 0 1px 10px rgba(0,0,0,.1);
box-shadow: inset 0 -1px 0 rgba(0,0,0,.1), 0 1px 10px rgba(0,0,0,.1); */
}
.navbar-fixed-bottom {
bottom: 0;
}
.navbar-fixed-bottom .navbar-inner {
/* -webkit-box-shadow: inset 0 1px 0 rgba(0,0,0,.1), 0 -1px 10px rgba(0,0,0,.1);
-moz-box-shadow: inset 0 1px 0 rgba(0,0,0,.1), 0 -1px 10px rgba(0,0,0,.1);
box-shadow: inset 0 1px 0 rgba(0,0,0,.1), 0 -1px 10px rgba(0,0,0,.1); */
}
.navbar .nav {
position: relative;
right: 0;
display: block;
float: right;
margin: 0;
}
.navbar .nav.pull-right {
float: right;
}
.navbar .nav > li {
float: left;
margin-top: 10px;
}
.navbar .nav > li > a {
float: none;
vertical-align: middle;
padding: 20px 10px 20px;
color: #555555;
font-family: 'Lora', serif;
text-transform: uppercase;
text-decoration: none;
text-shadow: 0 1px 0 #ffffff;
}
.navbar .nav > li > a:focus,
.navbar .nav > li > a:hover {
background-color: #transparent;
color: #7095eb;
text-decoration: none;
}
.navbar .nav > .active > a,
.navbar .nav > .active > a:hover,
.navbar .nav > .active > a:focus {
color: #ed2b28;
text-decoration: none;
background-color: #transparent;
-webkit-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
-moz-box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.125);
}
Third section from the top has the overflow hidden, should be visible.
.navbar {
overflow: visible;
margin-bottom: 0px;
color: transparent;
*position: relative;
*z-index: 2;
}

CSS Triangle Under Button

What I am trying to accomplish on :hover.
.nav li {
margin: 12px 0 0 20px; padding: 0;
color: #000; font-weight: 700;
display: inline-block;
}
.nav li+li:hover {
background: #2f3343;
padding: 5px 10px 5px 10px;
margin: 0 -2px 0 20px;
border-radius: 2px;
font-weight: 700;
border: none;
}
.nav .triangle {
width: 0px;
height: 0px;
border-style: solid;
border-width: 10px 12.5px 0 12.5px;
border-color: #000000 transparent transparent transparent;
}
I would like to put the triangle in the :hover but it's completely messed up. Do I need to set a specific height and add a position?
Try this
i create a new
.nav li {
margin: 12px 0 0 20px; padding: 0;
color: #000; font-weight: 700;
display: inline-block;
padding: 5px 10px 5px 10px;
position:relative;
border-radius: 2px;
}
.nav li:hover {
background: #2f3343;
border: none;
}
.nav li:hover:after {
content:"";
border-style: solid;
position: absolute;
left: 50%;
bottom: -10px;
margin-left:-10px;
border-width: 10px 12.5px 0 12.5px;
border-color: #000000 transparent transparent transparent;
}
Demo
Try the following css:
.arrow {
width: 0;
height: 0;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-top: 10px solid #000;
margin-left: 15px;
display: none;
}
button:hover + .arrow {
display: block;
}
I have made a JSFiddle similar to this. Have a look and provide your comments.

Resources