Currently, I'm working on the single webpage and got some issue with the final output which is when clicking the link menu, it does not go to the targeted div position(correct me if I'm wrong). And when clicking again the link, it will go to the other position.
I follow this tutorial, callmenick
Here is the reproduction of it, jsfiddle
<nav>
<ul>
<li>Overview</li> <- when any click link, and then click again, there's some action happen. *bugs?*
<li>Tech Spec</li>
<li>Support</li>
</ul>
</nav>
Now I get it,
the Problem is that the fixed nav is not part of the document flow anymore.
Therefore it won't reserve height. Or in other words the rest of the elements don't know its there anymore. Just like display: none;
You need to find a way to push the elements down by the height of the fixed nav but only if the nav is fixed.
There are a couple ways to to that, but it depends on the layout.
First way that comes to mind is applying padding-top: ?px; to the #product-nav, via JS as soon as fixed is applied to the nav.
edit:
https://jsfiddle.net/ju648br4/4/
I see no issue on my machine, but this feature can be approached in a different way. See my example below, this might solve the issue
Add anchor class
Add data attribute
Make global function that scrolls to certain point
So for instance
<div id="button-name"></div>
becomes
<div id="button-name" class="scrollAnchor" data-anchor-dest="#section-more-info"></div>
Now there is a JavaScript action required, this one reads the data-anchor-dest attribute and scrolls to it.
$(".scrollAnchor").click(function(e){
e.preventDefault();
anchorDestination = $(this).data("anchor-dest");
smoothScrollTo(anchorDestination);
});
function smoothScrollTo(element)
{
$("html, body").stop().animate({
scrollTop: $(element).offset().top
}, 1000);
}
Now the usual question, how compatible is it? This compatible, I have tested this myself in IE9 and it works.
This answer may be more of a teardown than a fix, but I hope this helps
What you need to do is to add your missing Buy section and in your navigation add href to the link, like:
<nav>
<ul>
<li>Overview</li>
<li>Tech Spec</li>
<li>Support</li>
<li>Buy</li> <!-- You are missing your href attribute here -->
</ul>
</nav>
All the rest seems to work fine.
Related
I have created a responsive website (www.openlabs.ai) and under our product section I have placed a link to open a page in new tab.
The problem I am facing is that the link opens only when the browser window size is full if I make the browser/chrome window smaller and then try to open the link, nothing happens. I tried to see the problem through google chrome developer tool but I could not find any problem.
<li class="has-children">
Our Products
<ul class="dropdown arrow-top">
<li><a href="4cast/" target="_blank" class="nav-link"><span
class="text-primary">Openlabs:4Cast</span></a></li>
</ul>
</li>
When I do developers tools of chrome and try to click the the link while keeping the window smaller than full I get the following error.
main.js:228 Uncaught TypeError: Cannot read property 'top' of undefined
at HTMLAnchorElement.<anonymous> (main.js:228)
at HTMLBodyElement.dispatch (jquery-3.3.1.min.js:2)
at HTMLBodyElement.y.handle (jquery-3.3.1.min.js:2)
Looking for solution as well as interested to know the reason why it does not open if the window size is smaller, let's says half sized or on mobile.
PS: I am not a web developer.
There is a problem with a function in your main.js.
The function OnePageNavigation(); is to animate the scroll to a section when you click an anchor with hash. But, the selectors that you are using .main-menu li a[href^='#'], .smoothscroll[href^='#'], .site-mobile-menu .site-nav-wrap li a include anchors without hash, for that reason the page is not opened.
Try to remove the selector .site-mobile-menu .site-nav-wrap li a.
I used zurb's foundation for a website which had lots of images distributed over some tabs.
It was very heavy to load so I used jQuery Lazyload to solve the problem. It worked beautifully except for the fact that it only loads the images on the 1st tab, which is the one active by default. The images in other tabs only loaded upon scrolling. Even if you do it by just a tiny bit.
So how do I re-activate Lazyload when navigating between tabs?
I've tried many fixes, including the ones in Lazyload's on website. None of them worked when the content is inside tabs.
But as Lazyload is triggered by scrolling I've managed to activate it by moving the page only 1px. Which is practically unnoticeable.
Here's how to do it in two simple steps...
add this javascript to the bottom of the body tag inside your html file
<script type="text/javascript">
// FUNCTION TO SCROLL 1PX AND TRIGGER THE LAZY LOAD
function tinyScroll() {
window.scrollBy(0, 1);
}
</script>
and add onclick="tinyscroll()" to your tabs. Like this example
<ul>
<li onclick="tinyScroll()" class="tab"></li>
<li onclick="tinyScroll()" class="tab"></li>
<li onclick="tinyScroll()" class="tab"></li>
</ul>
Your own answer is clearly a bad hack. In general I would recommend to use lazySizes. Among other improvements, it detects any image visibility changes automatically. So you don't have to bother to trigger anything.
There are many popup on a page which have overflow:auto property
Structure is -
<div id="popup1">
<div>SomeHTMLSTRUC</div>
<div>SomeHTMLSTRUC</div>
<ul class="scroll"></ul>
</div>
<div id="popup2">
<div>SomeHTMLSTRUC</div>
<div>SomeHTMLSTRUC</div>
<ul class="scroll"></ul>
</div>
This ul has this class of scrolling property.
Now once if I scroll to bottom in one of the popup. How do I set scroll to top when the next time I open another popup popup?
Add
document.getElementById('popup1').children[0].scrollTop = 0;
before the code to open the popup. This assumes that <ul> is the first any only immediate child of the <div>.
Working demo: http://jsfiddle.net/sdz8nc3j/
EDIT: With the recent update to the question making the <ul> the third child, you need to change the [0] to [2]. You could also just find the <ul> instead of relying on the number of children:
document.getElementById('popup1').getElementsByTagName('ul')[0].scrollTop = 0;
Working demo: http://jsfiddle.net/sdz8nc3j/3/
I also made a jQuery version, although it doesn't really save you anything. It also searches for the <ul>.
$popup1 = $("#popup1");
$popup1.click(function(){
$popup1.children('ul').scrollTop(0);
});
Working demo: http://jsfiddle.net/sdz8nc3j/1/
Use this:
document.getElementById("popup1").childNodes[2].scrollTo(0, 0);
This works if the UL is the third child!
jQuery version:
$("#popup1").find("ul").scrollTo(0, 0);
I have a menu and a submenu that the parent menu title itself also leads to a page, the submenu opens on mouseover.
My problem is with touch screens, since there is no 'hover' on touch screen, there is no way to access the submenu, since the parent-menu page opens momentarily after the sub-menu appears without leaving time to choose value from it.
So from your experience is there an easy way to adapt the menu to touch-screens?
Is there a simple or conventional way to mimic mouseover on touchscreen?
I am not actually asking for code, but rather what's the common behavior in this scenarios, I already have a website that I want to make touch-screen friendly.
I obviously prefer a CSS solution over a script-based one.
You could have the submenu appear on press, then the user would drag down (still pressing the screen) and on finger up that could select the option.
Alternatively, you can have one click to open the sub menu, then another to select an item.
On a side note, this question would get a better response on https://ux.stackexchange.com/ it deals with user experience related questions
There are several approaches, for a CSS-only solution you could use the :target pseudo class.
.submenu {
display: none;
}
.submenu:target {
display: block;
}
<ul>
<li>
Foo
<ul id="submenu-1" class="submenu">
<li>Bar</li>
<li>Baz</li>
</ul>
</li>
</ul>
I have a problem whenever I want a button to position or links it seems to JUMP left or right and becomes shaky when I hover over it.
I tried to include some print screens but my reputation here is not high enough.
Cheers,
Ted
check my site to see what I mean. hiretednow.com thanks
my navigation buttons jump to the right when I hover over them:
HOME
<li>Expertise | Skills</li>
<li>Projects</li>
<li>About TED</li>
<li>Get In Touch</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
the same thing happens with certain links that I have created. I checked in Jfiddle and it seems to work fine, perhaps it could be an issue with the Browsers or Javascript?
To position buttons or p style text I use style position...but perhaps someone could explain me how I can do this in CSS instead of HTML as on the mobile phone they don't resize.
EXAMPLES:
img src="assets/img/map.jpg" style="position: absolute; bottom: 340px; right: 140px;"/
p style="position: absolute; bottom: 585px; right: 185px;"/>I AM CURRENTLY LOCATED IN LONDON, UK
a href="https://twitter.com/jus_ted" target="_blank">
1) In your main.css file you have a:hover with margin-right: 600px; which is causing them to jump around.
2) I would imagine that the reason it only happens with some links and not all is the style gets trumped through specificity elsewhere in your CSS. (To learn more about CSS specificity have a google about or try using this which helped me: http://www.stuffandnonsense.co.uk/archives/css_specificity_wars.html)
3) I would need more information about what exactly you're trying to achieve, but I noticed you are using Twitter Bootstrap. You can use pull-left and pull-right classes (experiment with where you put them to see different results) and you can also utilise the grid system by including new and adjusting widths. If you haven't already, check out the Bootstrap documentation on their grid system here