jQuery Image Popup and fixed navigation - javascript

I downloaded Fancybox pluging from http://fancyapps.com/fancybox and used for open my gallery images in popup.
and also I used fixed navigation when scrolling.
My problem is, when I click on images, it will open in a popup window. It is ok.
But, fixed navigation menu is still appear on the popup window.
![problem][1]
Navigation Menu HTML
<div class="nav-container">
<div id="nav">
<ul>
<li>Home</li>
<li>shop</li>
<li>Gallery</li>
<li>Facilities</li>
<li>Terms</li>
<li>Contact</li>
</ul>
<div class="clear"></div>
</div>
</div>
</div>
Navigation Menu Javascript
jQuery("document").ready(function($){
var nav = $('.nav-container');
$(window).scroll(function () {
if ($(this).scrollTop() > 136) {
nav.addClass("f-nav");
} else {
nav.removeClass("f-nav");
}
});
});
Because of that navigation, user can't close the popup window.
Guys,
please help me to solve this.

Your navigation menu is probably set as position: fixed. This makes it have a z-index which is, by default, above every position:static placed elements (which is the default).
What you should do is edit the CSS of the lightbox so it has position: relative which should make it go above your navigation (assuming it's later in the DOM).
If it's still showing up below your navigation, check what the z-index of your f-nav class is, and change the z-indexof your lightbox so it's higher than the one of the navigation.

Related

Closing a modal box reloads the page

Okay, so I have this weird issue on my website which I might have a hard time explaining. I am working on a website which only has one page(index.html) and no scroll. I have a navbar on the left with some menu items. So when clicked on a menu item a box appears with content. As it is a single page no scroll website, I have used IDs to call those boxes. Please see the code below:
<div class="nav-content">
<ul>
<li>Home</li>
<li>About</li>
<li>Gallery</li>
<li>Contact</li>
</ul>
</div>
when clicked on a menu item this kind of section appears on the screen.
<section class="content show background-overlay" id="about">
<div class="aboutUs">
<h1>About Us</h1>
<div class="overflow-scroll">
Lorem ipsumasfasfasfasfafafsafs
</div>
</div>
</section>
And the browser address bar shows something like this after clicking on the links:
file:///C:/Users/zak/Desktop/web/project1/index.html#home
or
file:///C:/Users/zak/Desktop/web/project1/index.html#gallery
Now I have used a modal box inside the gallery content section and after I close the modal box, the page does not stay at the gallery content section but reloads.
For example:
Modal box is here:
file:///C:/Users/zak/Desktop/web/project1/index.html#gallery
After modal is closed:
file:///C:/Users/zak/Desktop/web/project1/index.html (which is the home content section)
I want the gallery section to stay open even if I close the modal.
For the modal, I have not used any JS or jQuery. It is pure HTML and CSS. To get rid of the issue I have tried a simple jquery code:
$('#modal_close').click(function(e) {
e.preventDefault();
return false;
});
This code just stops everything working.
Can anybody tell me how to stop the page from reloading after the modal box is closed?
You can try to use hide event to make refresh.
$('#modal_close').on('hide', function() {
window.location.reload();
});

Modify existing bootstrap sidebar to collapsible

I've built my project in bootstrap which has a top navigation bar and a sidebar.
Now I need to make sidebar, collapsible like this:
http://www.makerstudios.com/
But sidebar in my project is on left side of the page. How can I make this sidebar collapsible with minimum possible changes?
HTML:
<div class="col-md-3">
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav">
<ul class="nav" id="side-menu">
<li>...</li>
<li>...</li>
</ul>
</div>
</div>
</div>
You could use a simple jquery.
First you need to set up the sidebar to be off-screen though. This can be done by adding a
.sidebar {
left: -300px // For example
}
Then you need to make a jquery code, that listens on clicks on the button you want to be bring out the menu.
When the button is pressed, the jquery code should make the sidebar displayed again, and bring it to a visble range (left:0;)
<script>
$(function(){
$("#menu").click(function open(){
$('.sidebar').animate({ left: '0'}, 500);
});//opening it
$("#close").click(function close(){
$('.sidebar').animate({ left: '-200px'}, 500);
});// 'Closing it'. Takin it back off -screen within the timewindow of 500ms
});
</script>
So what you would have to do now, is setup the bar off-screen, and then create a buttons for your opening/closing.
This solution will make the sidebar go on top of the existing body, but if you would like it do be the same way as it is on the site you've linked, you just have to add a command to the jquery to move the content-partion(visible part) the same amount as the sidebar moves.

Semantic UI Sidebar & Dropdown menu

I am trying to create a simple web ui with semantic ui.
I want a sidebar with a menu in it in some items will have subitems... Shouldn't be that hard hu?
http://jsfiddle.net/ycm8ctfx/
<div class="ui vertical menu sidebar teal">
<div class="menu">
<a class="item" target="_blank" href="http://semantic-ui.com/modules/dropdown.html">
Example
</a>
<div class="ui left pointing dropdown link item">
<i class="dropdown icon"></i>
Messages
<div class="menu">
How do I get the sub-items to "fly-out" of the sidebar over the normal page content? If you click "Messages" within the example, the menu will appear (watch the scrollbar at the bottom to appear) but since those are children of the sidebar, they are being shown within the sidebar. But I want them to float over the normal content! I didn't get it to work via fiddle with the z-index.
if sidebar is configured to use overlay transition it can be fixed by specifying
.ui.sidebar {
overflow: visible !important;
}
taken from here http://jsfiddle.net/59174tt1/2/
It's the combination of position:fixed and overflow on .ui.sidebar. This article might help: http://css-tricks.com/popping-hidden-overflow.
An alternative might be to use an accordion to keep everything within the sidebar.

Navbar in Header JQuery Mobile

EDIT: My temporary solution is to turn off all transitions and use different id for each header. You then get the persistent toolbar, but without transitions.
working example without transitions
I am using a persistent fixed navbar in my header in JQuery Mobile.
I'm navigating between 3 html files, and on the first(main) page there is no problem, but on the second and third page the navbar covers some of the content.
example of broken navbar code for the navbar and header:
<div data-role="header" data-id="header" data-position="fixed">
<h1>Page 1</h1>
Options
<div data-role="navbar">
<ul>
<li><a href="#page1" data-icon="home" data-iconpos="top"class="ui-btn-active ui-state-persist" >Page1</a></li>
<li><a href="#page2" data-icon="info" data-iconpos="top" >Page2</a></li>
<li><a href="#page3" data-icon="gear" data-iconpos="top" >Page3</a></li>
</ul>
</div><!-- /navbar -->
</div><!-- /header -->
I have uploaded an example of the problem here(with pages in one html file instead of three html files) : broken navbar
here's the updated one:
http://jsfiddle.net/LvuUX/2/
You had same data-id="header" for all three pages, as you are using multi-page template so you can't have same id for multiple elements
EDIT: http://jsfiddle.net/LvuUX/3/
looks like jQuery is not using the correct padding-top when page loads. To fix this issue you can just use a fix padding-top for your data-role="content"
<style type="text/css">
.ui-page-header-fixed { padding-top: 5.9em; }
</style>
I think what you're trying to do is similar to the problem I had. I had a fixed positioned navbar but my page content was being hidden underneath it. I solved the problem by applying a top margin to my content div equal to the height of the navbar. (ie. My margin-top of my content div was 50px as that was the height of my navbar.)
Fixed positioned elements are removed from the normal flow. The document and other elements behave like the fixed positioned element does not exist.
I hope I interpreted your question correctly. I've only been learning html&css 3 months but when I saw your question I thought this might help.

Hide div when I click any button on my page

So I have this menu and when I click on a button I need to create another div under the menu. I have done that. But when I click on another button on the menu that div is still there and I want it to dissapear/collapse. So how should I do it? What I found until now is how to hide a div when clicking on a specific show/hide button, but I need to hide that div when I click any button on my page...
Any help is highly appreciated.
My code is this but I don't think it is relevant (I am interested in the process, how should I do it):
<div id="container">
<ul id="nav">
<li>Despre noi</li>
<li>Projects</li>
<li>Implica-te</li>
<li>Stiri</li>
<li>Contact</li>
</ul>
</div>
So this is my menu and when I click on projects this div shows up
<div id="menu_lava">
</div>
which is a lavalamp submenu. But how can I make it to collapse when I click on other buttons on my main menu?
Hide all info-div's on a click and just show the sepcific one:
Here's a jsfiddle (using jQuery):
http://jsfiddle.net/FKeAF/1/

Categories

Resources