Div sliding down on click, and reversed, for multiple items - html

So I have a portfolio website. 6 squares which which are clickable. I want the site beneath the item that's is clicked to slide down and i want it to display details for this portfolio item in the space thats created by sliding down the content.
I want the effect described in the following link. But this is only working for one item. I've got 6. If item 1 is clicked, content slides down and you get details. What I want is when you click item 2, the details from item 1 slides back up and the details for item 2 slides down.
How to slide down a div then .fadeIn() the content and vice versa?
An example: http://www.applove.se
Scroll down to the portfolio on this site and click on an item to see what I want to achieve.
This is my html. There is a UL above this, but for some reason when I copy it, the whole thing just gets messed up.
<li class="port_list">
<div id="port_img1"> intro_img1 </div>
</li>
<li class="port_list">
<div id="port_img2"> intro_img2 </div>
</li>
<li class="port_list">
<div id="port_img3"> intro_img3 </div>
</li>
</ul>
<ul id="wrapper_portfolio">
<li class="port_list">
<div id="port_img4"> intro_img4 </div>
</li>
<li class="port_list">
<div id="port_img5"> intro_img5 </div>
</li>
<li class="port_list">
<div id="port_img6"> intro_img6 </div>
</li>
</ul>
CSS wil make sure that the first 3 li will display horizontal. The last three are also displayed horizontally beneath the first three. I am not working with images, but with background-images for every div.
EDIT:
Mike asked me to fiddle my html and css. Zo here it is. http://jsfiddle.net/StillD/bDMxs/
The pink boxes are my portfolio items. Beneath them I want to present detailed information (whole browser width) of the portfolio item you click. So when you click portfolio item 1, the 3 items (displayed horizontally) beneath it should slide down to make room for the details of portfolio item 1. If you click item 2, the details of item 1 should disappear to make room for the details of item 2, and so on.
(The details are represented by the picture of the bird for now).

i think I understand what you want. here is a very simple jsfiddle example.
http://jsfiddle.net/yRcnz/1/
basically you will need some sort of element before each ul so the user has a place to click. once you have that area for a user to interact with, some simple javascript can toggle() the display of the ul elements.
$('.expandable-ul li').click(function() {
$(this).children('img').toggle();
});
$('.expandable-ul img').toggle();

Related

Attaching a HTML anchor link to a Dropdown in a Nav menu bar

<div class="dropdown">
<button class="dropbtn"> Control Center
</button>
<div class="dropdown-content">
Trend
Intel
</div>
</div>
I have a section on my webpage called Control center and I want to make it so that when someone clicks on the Nav Bar, it takes them to that section of the page. I made the Drop down of the Nav Bar on hover so that when they click on the nav bar it would take them to different sections within the page.
When I add <a href="#Control-Center"> part to this the nav bar gets all buggy. I tried changing the heiarchy like this:
<div class="dropdown">
<button class="dropbtn">Control Center</button>
<div class="dropdown-content">
Trend
Intel
</div>
</div>
but it still does not look good. There is functionality but the dropdown goes haywire.
Any advice will be appreciated :)
Thank You
I encountered the same issue a week ago when using this web template:
W3 school template.
It wouldn't jump in the normal sense (out of that Top Nagivation bar).
But it WOULD jump there when I duplicated that JumpTo link on the main page near the top (and hidden it in a closed JS script), then when I click on the top navigation bar button it does jump down to the very bottom of the page where I want it to land.
See below how we did it.
TOP NAV:
Projects
Somewhere near top of page but hidden:
<!-- -->
Destination at bottom of page in footer (where I tested it).
<footer id="JumpTo" class="w3-center w3-black w3-padding-16">
I suppose, not precisely what you're looking for, but maybe try an HTML details element?
<details>
link1<br>
link2<br>
link3
</details>

Preventing dynamic sub nav from starting underneath its parent nav item

I'm building a progressive web app that outputs data onto the pages via an API. For example, there could be one page called about us and in about us could have history, location, etc... for its sub nav. Here are a couple of examples as to what I mean:
When on the health & wellbeing page
When on the about us page
The issue that I am having is because the about us links are contained in a UL element that is contained in the about us LI element, it positions the sub nav to start directly underneath it and not underneath where the logo is.
Here is the structure of the HTML code that populates the navigation, based on when visiting the about us page.
<ul>
<li id="nav-1">
Home
</li>
<li id="nav-2" class="open-two">
Health & Wellbeing
</li>
<li id="nav-13" class="open-two">
About Us<span><i class="arrow down"></i></span>
<ul class="level-two" style="display: grid;">
<li>About Us Home</li>
<li id="nav-8">
History
</li>
</ul>
</li>
</ul>
Now I did try using margin-left:-346px; on the level-two UL element, which produced the following examples:
When on the health & wellbeing page
When on the about us page
Looks better on the health & wellbeing page, but then I realised after seeing the about us page that margin-left:-346px; didn't really fix the issue due to it only moving to the left a certain number of pixels.
So my question is, how do I get the dynamic sub nav to start underneath the logo and not start underneath its parent nav item so it turns out like the third image?
Update: Here is another example of what I am referring to https://jsfiddle.net/hkctdpqn/1/
I figured it out. I had to make the position of the parent UL element relative and make the position of the level-two UL element absolute. Then I adjusted the margin-left value until they all started underneath the logo and not to their parent elements.

element pushed out of anchor

I have this weird thing happening to me.
I have a menu and I try to create a mega menu.
I`m adding a ul in anchor tag to create the mega menu but it s pushed out of it. Anyone know why?
HTML:
<ul class="header_menu">
<li>
<a href="#">
Menu 1
<ul class="sub_menu">
<li>Submenu 1</li>
</ul>
</a>
</li>
and check this picture of html using view source.
image using view source
The ul sub_menu is pushed out of the anchor and its placed near it, not as a parent of anchor tag.
Any ideas?
EDIT:
As Quentin said, and according to w3c "Nested links are illegal".
A more detailed explanation here:
https://www.w3.org/TR/html401/struct/links.html#h-12.2.2
Your HTML is invalid.
See The a element:
Content model: Transparent, but there must be no interactive content descendant.
You cannot have a link as a descendant of another link.
If you remove the nested link, then the problem goes away:
You probably want "Menu 1" to be a link and "Submenu" to be a different link. So end your first link before the nested list.

Hovering over a popup nav menu and have a separate popup display based on which element in menu is being hovered over?

I'm working on a site that has hovering popup nav menu that works exactly the way I want. What I want in addition to the menu is to have another popup somewhere else on the page that contains specific information about the element that the user is currently hovering over. If no elements in the nav menu are being hovered over, I want the popups to be hidden.
I have a jsFiddle that has everything I want except the additional popup field.
I've tried everything I can think of except a JavaScript solution (as I'm not fluent in JS), however, I don't mind a JS solution. I can fumble my way through JS and make occasional changes - I just can't create it.
This hovering popup menu works (full HTML and CSS in the jsFiddle):
<ul>
<li>Nav menu here
<ul>
<li>Sub menu items</li>
</ul>
</li>
<li>More nav menu items</li>
</ul>
How do I get an additional popup field with specific-to-the-hovering-element relevant information, when hovering over one of the top-level menu items?
Here is something you can start with.
You can use JavaScript to hide and unhide the information.
Check this JSFiddle : http://jsfiddle.net/apD26/17/
Sample JS :
$(document).ready(function(){
$('.info').hide();
$('.parent').mouseover(function(){
$('.info').show();
$('.info').text($(this).attr('data-desc'));
});
$('.parent').mouseout(function(){
$('.info').hide();
});
});
Instead of $(this).text() which i have used to show the text, you may store your description in a data attribute in each menu item and display that.
EDIT
Updated the JSFiddle and answer

please help me temporarily change colour of menu items in sequence on page load

I am working on a website which has subtle dark grey menu items on the top of every page. The menu is constructed using a list and some CSS and HTML. Currently using ID in BODY to highlight menu item which corresponds to the page your looking at.
What I am trying to achieve is that when the page loads, each menu item in the list changes in sequence from dark grey to its .hover colour for a second and then fade back to dark grey. The intention is to show the viewer that there is a menu present, yet then allow the menu to be less intrusive as styled.
HTML (only showing the relevent bits of code)
<head>
<!-- InstanceParam name="id" type="text" value="inno" -->
</head>
<body id="##(id)##">
<div class="big-nav-inline"><ul>
<li>Markets</li>
<li>Technology</li>
<li>Innovation</li>
<li>Ventures</li>
</ul></div>
</body>
CSS Explanation (full code is currently too bloated to paste)
I am using the div class for positioning on the page.
I am using the class of each list item to give a different list item color on .hover
I am using <body id=""> to highlight the current page list item and to change a border colour on the page.
Hope you can help!!!
What do i need to use to get the effect im after? Have any of you done this simply?
Kind Regards
Paul
You can achieve this effect by using CSS3 animations/transitions.
See also this post: start css3 animation after entire page load