Keep showing div when not hovering on trigger link anymore - html

I'm having a problem with the menu I just coded: https://jsfiddle.net/nL124rLq/1/
I am using a general selector (~) on my css and I think this might be a mistake, because it might be the origin of my problem:
#nav #link1:hover ~ #flydown {
left:0;
display:block;
}
#nav #link2:hover ~ #flydown {
left:-100%;
display:block;
}
... and so on.
As you can see, everything works fine but when I stop hovering on the anchors, the sliding menu under the links disappears. I understand my code is not made for this to work correctly, but I can't figure out a way of making it work.
I am going to add content (sub-menus) to the coloured areas that form the slider, so they must be clickable and must remain visible when the user hovers over them.
If it's any help, I got the idea from this site: http://www.tiffany.es/
Thank you guys very much in advance and excuse the relatively vague question!

Okay, so I found the solution, more or less. #Michael_B 's help was awesome! The resulting code looks horrible though. Oh well, it works!
Basically I added this to every single link that I have on the nav (link1, link2... etc.):
$("#link1").on("mouseover", function () {
$(".flydown").addClass('permahover1');
});
$(".flydown").mouseleave(function () {
$(".flydown").removeClass('permahover1');
});
...and added the following CSS once for every element in my menu (permahover1, permahover2 etc.) to specify their different positions with left:0%, left:-100%, etc:
.flydown.permahover1 {
left:0%;
display:block;
}
It got really dirty in no time. But I don't know a better solution. Here's a working JSFiddle:
https://jsfiddle.net/nL124rLq/4/
As always, thank you guys very much for your help!

Related

How to move the button under the logo

Im starting to learn HTML and CSS and i want to ask how can i move the button under the logo. As I said im kinda new to this soo please dont be to harsh on me haha. I tried to mess with display, justify-content and align-items, but im not sure that i'm looking at the right place.
P.S The button itself isnt made by me. I just changed it a bit so my first html+css documents would not look that bad. And course I'm not doing this commercially, just for my own satisfaction and learning.
Site
Code
You can use onClick event handler on img html tags. So, you don't need buttons under images. However, if you want to do it, you can use z-index css property.
img{
z-index:1;
}
button{
z-index:0;
}

Css mouseover not appearing

Hi I have a div with a link however when you hover over the div the mouseover state doesn't change i.e. the mouse pointer doesn't change to a finger instead of a mouse
Unfortunately I am unable to replicate this error in jsfiddle it only seems t occur on my Wordpress installation
the address where it occurs is here http://stylrs.com/trustees/ (when you hover over individual names.)
Is there a reason for this?
How can I fix this?
Add this to your css:
.su-lightbox{ cursor: pointer }
Those blocks arn't links at all. I see though you have a click event tied to them. Just give the block a cursor:pointer css style and it will look like a link
try changing with css :
.linkclass:hover {
cursor:pointer;
}
and please edit your question and give us your code. So, we can see the real problem.
you can change it manualy like this :
.your div {
cursor:pointer;
}

Changing css for subnav while keeping original nav with pictures

I want to change the subnavs on this code but everytime I try it takes the parent element (the background image from above.
I would have thought adding the following code would get rid of the background image for the subnavs but it doesn't.
ul.subnav li {
background-color:000;
}
What I want is to do some basic css for the subnavs with the names of each link. Nothing fancy.
Heres a link to the fiddle
http://jsfiddle.net/mitchelll182/t7QQ8/1/
Ok, so I see you're doing a CSS only menu, but that involves putting classes on everything and it ends up being a huge code mess. I think a better way would be to use jQuery. Something like this: http://jsfiddle.net/ewB9b/
See how the HTML code is nice and clean? Just nested UL's with one class. Now in the CSS, you can easily style the main links differently from the drop-downs. Read the comments in the CSS to see what's what.
.
Try:
ul.subnav li {
background-image: none;
background-color:000;
}

IE: element does not move when :hover makes another element visible

I encountered a strange problem in IE 8/7 and I have gone through hell (and back) to reach a minimal test-case that demonstrates the issue...
Consider the following bit of HTML:
<form id="hover-test">
<fieldset>
<div id="hover">
<p>always visible</p>
<p class="hidden">Visble only on hover</p>
</div>
</fieldset>
<fieldset>
Please jump
</fieldset>
</form>
And this bit of CSS:
form { background-color:#f5f5f5; }
.hidden { display:none; }
#hover:hover .hidden { display:block; }
#link { position:relative; }
What it should do: On hover an additional paragraph becomes visible, pushing the next fieldset and all its contents down. (works fine in FF/Chrome/Safari/Opera)
What it does in IE 7/8: The paragraph becomes visible, pushing down the following fieldset. The link however stays fixed in place for reasons I can't fathom.
In the frustrating chase for a minimal mark-up that reproduces the problem (the effect vanished when I removed single lines of CSS from the original code, but my testcase could have them and still be fine... O_o) I identified at least three players working together here:
the fieldset: If I put everything in divs or in a form without fieldsets, all is well
the position:relative: Uncomment that line and voilá - link jumps.
the background color: This makes no sense whatsoever to me, but without this it works.
So, here's the question (apart from the implied "WTF?"):
Has anybody any clue on what is causing this behavior? And how to solve it? Or at least a hint into which of the many known IE issues I could look into to further test stuff?
Maybe I could come up with a way to bend the structure and...say... have the background-color on some additional wrapper div or something, but this seems... somewhat silly, and anyway, I feel as if not understanding this now will make things possibly very complicated down the road.
It was your comment about the position: relative that helped me solve it. That flagged me to think hasLayout! The issue seems resolved if you make sure both form and fieldset have layout set also (just giving it to the #link created the issue). One (among many) ways:
form, fieldset {zoom: 1}
See the working fiddle.
BTW: You should not have two #hover id's in your code. That should be set to a class (maybe it is just an error in your example, but I wanted to note it).

Can't get Div to affect Divs below it

I have a menu that's been giving me quite some trouble. What I'm trying to do is make the menu links, when clicked, reveal a drop down secondary division. However, it's acting as if the menu being revealed is floating and I can't seem to figure out why.
Here's the ideal design I want:
http://jsfiddle.net/WeL6j/7/
Notice how the grey division is affected and slides down as well.
I'd like the same thing to happen with the divs that hold 01, 02, etc and the one with the green 01. Basically all the content below the menu. I've posted a fiddle of my code just to give an idea of what it's doing and so you can edit it in real time. I haven't created any fallback code for it, so it's only really viewable in chrome. (sorry) It's also going to be messy as I've been moving things around trying to get it to work properly. Anyways, here's what I have so far.
-removed-
Thanks in advance for the help, Brian.
Try this:
http://jsfiddle.net/ETaqa/63/
BTW, you should really format the nesting. It was confusing figuring out the div levels.
Hi you can define some properties in you css as like this
.content {
position: relative;
top: -7px;
z-index: 10;
}