Navigation Bar: Second level with full width - html

I created a navigation bar with a first and second level navigation. You can see the latest version here as a JSFiddle (maybe you have to increase the width of the frame containing the output to see the navigation bar with two levels).
At the moment, I have several issues with this navigation bar:
The width of the first level element "Menu1" should only be the width which it will need and not the width of the total width of the elements inside the second level navigation.
The second level navigation should be width 100% so the same as the yellow header and not only the width of the elements of the second level navigation bar.
So the navigation bar should look like the following image:
But how can this be achieved, especially the width of 100% of the second level navigation bar? I tried this CSS-Tricks: Full Browser Width Bars with "Using pseudo elements", because I did not want to have this definition globally on
html, body {
overflow-x: hidden;
}
Any help is highly appreciated!

Is this what you want http://jsfiddle.net/aytaxykf/5/
i added this ontop of your styling. so you can probably remove some of the rules you have there
.top-bar {
position: relative;
}
.top-bar-section {
height: 70px;
}
ul.sub-menu {
display: block;
position: absolute;
top: 100%;
left: 0;
right: 0;
background: blue;
text-align:center;
}
ul.sub-menu li{
display: inline-block;
float: none;
}
.menu-center a {
position: relative;
}
.menu-center .active > a:before {
position: absolute;
bottom: 0;
left: 50%;
margin-left: -10px;
content: "";
width: 0;
height: 0;
border-style: solid;
border-width: 0 10px 10px 10px;
border-color: transparent transparent lime transparent;
}

Related

.hover stay in same spot while img and text are responsive

What the html looks like
My problem is at a large view the .hover looks fine, but when the screen is small the .hover stops being aligned how I'd like it.
How can I make the .hover look visibly better at smaller views?
You might want to check at which breakpoint your hover stops being the way you want it. You can toggle a :hover in your inspector to see at which width the hover div is not in the desired position anymore.
After you know at what width the div is misplaced, you could add media queries. In that query where you say (max-width: 1000px){} you could change the margin of the hover div.
I think what you could do is place the .hover element into the element that triggers it to show. The .hover element then needs to be positioned absolutely inside of an element that is not position:static;
The benefit of having the hover content inside of a container together with the label means that they move around together when the page gets resized.
You can change where the .hover appears based on the media query.
HTML:
<div class="container">
<div class="label">Label</div>
<div class="hover-content">This is the hover</div>
</div>
CSS:
.container {
position: absolute;
top: 100px;
left: 300px;
border: 1px solid #000;
}
.hover-content {
position: absolute;
top: 0;
left: 100%;
margin-left: 20px;
display: none;
}
.label {
padding: 10px;
}
.container:hover .hover-content {
display: block;
width: 200px;
background-color: #000;
color: #fff;
padding: 10px;
}
#media (max-width: 600px) {
.hover-content {
left: auto;
right: 100%;
margin-left: 0;
margin-right: 20px;
}
}
http://codepen.io/anon/pen/XjobdN

Images Over lapping my navigation bar

Code of navigation bar
ul {
position: fixed;
top: 0;
left: 0;
width: 100%;
overflow: hidden;
list-style-type: none;
background: black;
margin: 0;
padding: 0;
}
li {
float: left;
padding: 25px 25px;
cursor: pointer;
}
a {
text-decoration: none;
color: white;
font-size: large;
}
and code of image
.image {
position: relative;
left: 500px;
overflow: hidden;
So when I scroll text smoothly hides behind navigation bar. but the enter image description hereimage overlaps the navigation bar
right now on my right the div of 'similar questions' is also overlapping the bottom black div
You should set a z-index to your ul and make sure it is higher than what the other elements have.
You will need to add a z-index to the main navigation higher than the content scrolling. As mentioned.
But also you using position: relativeon the image, if you also set its parents position to relative as well thi sway the image will stay within the main contents wrapper, and scroll beneath the menu with the rest of the content.

Write text on a div padding

I currently have a div called testLine used for displaying a color triangle effect using css:
#testLine {
width: 0;
height: 0;
padding-bottom: 47.5%;
padding-left: 47.5%;
overflow: hidden;
}
#testLine:after {
content: "";
display: block;
width: 0;
height: 0;
margin-left: -1000px;
border-bottom: 1000px solid transparent;
border-left: 1000px solid #4679BD;
}
This works fine but the issue is the following:
How can I do to have a text over that triangle? I mean, I've tried with z-index but with no success (css it is not my strong point) and I didn't know if it is even possible to write text on it. What can be other possibilities? (I really don't want to use a resource consuming image for the background). I really appreciate any help that can lead me to a solution.
PrintScreen - http://i.imgur.com/dRCKVNO.jpg
edit, html code:
<div id="testLine"></div>
<div id="text">Testing Testing</div>
use position with alignment...something like:
#text {
position: absolute;
/* this will make div fall out of
page flow anad align to viewports dimension*/
top:0;
/* position to top*/
left:20px;
right:0
/*if needed*/
bottom:0
/*if needed*/
}
working demo
Use z-index with a position property, for example:
#testLine {
position: relative;
z-index: 9999;
}
Without position property z-index not work

CSS Submenu under its parent

I have a navigation:
<ul>
<li>Button
<div class="sub-container">Sub navigation</div>
</li>
</ul>
Sub container is set to opacity 0 and on hover of LI opacity goes to 1.
Now I have a problem that sub-container has a border and that border is on top of the parent LI element. I want LI element to be on TOP of the sub-container child element. So that they will look "merged".
I tried z-index -1 solution which works PERFECTLY in FireFox, but in Chrome it crashes.
Screenshot:
This is my CSS code:
#topBarHeader nav ul.main-nav {
list-style: none;
position: absolute;
left:0;
display: inline-block;
z-index: 100;
}
#topBarHeader nav ul.main-nav > li {
float: left;
display: inline-block;
padding: 15px 17px 10px 17px;
border: 1px solid rgba(255, 255, 255, 0);
margin-right: 10px;
}
#topBarHeader nav li .sub-container {
position: absolute;
top: 49px;
left: 0px;
width: 640px;
opacity: 0;
visibility: hidden;
overflow: scroll;
overflow-x: hidden;
height: 380px;
background: white;
z-index: -1;
border: 1px solid #d5dbdf;
}
#topBarHeader nav li:hover > .sub-container {
opacity: 1;
visibility: visible;
}
Here is the link to my page menu. (very slow, on a bad server.)
You should try declaring position: relative on the parent <li> element, or else absolute positioning may not work properly.
I wouldn't say this is a bug with Chrome, but more like how different browsers attempt to handle ambiguous rules when there isn't enough information.
[Edit]: I think I understand your problem now. The trick to make the top border disappear behind the active tab, is to actually wrap the content in the <li>, and then assigning it a higher z-index compared to the dropdown content, and change the bottom border colour to match the background so that it disappears.
Here is a Fiddle as a proof-of-concept - http://jsfiddle.net/teddyrised/EPYvq/

CSS Image hover works horizontally but not vertically

I currently am working a CSS navigation system on my client's website at http://cjcdigital.net/clients/andrea and while the top navigation has been working fine, I am unable to recreate the rollover effect on the vertical sidebar containing the social media buttons.
To achieve the top navigation effects I followed the steps at:
http://www.elated.com/articles/css-rollover-buttons/
With my navigation elements each being stacked top/bottom.
For the side navigation however, despite setting the image:hover to push the sprite to the left, the image hover property does not kick in at all.
Below is some code from the top nav, and below that is code form the side nav.
#headerMenu {width: 1200px;}
#headerMenu ul{display: inline;}
#headerMenu li a{top:334px; position:absolute;}
#magazine
{
display: block;
width: 112px;
height: 17px;
background: url("./images/magazine.gif") no-repeat 0 0;
left:160px;
}
#magazine:hover
{
background-position: 0 -17px;
}
#magazine span
{
position: absolute;
top: -999em;
}
Social Navigation
#facebook
{
display: block;
width: 149px;
height: 57px;
background: url("./images/facebook.gif") no-repeat 0 0;
}
#facebook:hover
{
background-position: -300 0;
}
#facebook span
{
position: absolute;
top: -999em;
}
Thanks in advance for any assistance
You haven't specified any units in your CSS declaration for #facebook:hover. You probably wanted to do something like:
#facebook:hover
{
background-position: -300px 0;
}