jQuery Flyout Menu. Breaking an element out of its parent - html

I'm working on a Shopify project. I am not the designer. I need to make a flyout menu for the shop. The problem is two fold. First of all, the flyout needs to extend to the bottom of the viewport. Secondly, I'd like to bundle everything together in the Navigation Div, but I need to figure out how to break the element out of its parent and then "layer itself" over the rest of the content without moving it around.
I thought I'd just hide the menu with CSS and then use jQuery to un-hide it on rollover. I don't think that will work though. I don't know how to position the flyout so it doesn't schlep everything around.
Here's the site now:
https://hodkiewicz-zieme-and-hirthe180.myshopify.com/
Here's what it should look like: http://tinypic.com/r/35hnyox/6
Here's what's in the nav column currently. I'll probably change the structure.
<div id="navbar" class="green">
<ul id="navigation">
{% for link in linklists.main-menu.links %}
<li><a class="green" href="{{ link.url }}">{{ link.title }}</a></li>
{% endfor %}
<li><a class="green" href="#">{{ linklists.packard.title }}</a>
<ul class="sub-menu">
<li><a class="green" href="#">-1930 Speedster</a></li>
<li><a class="green" href="#">-1929-31 Super 8</a></li>
<li><a class="green" href="#">-Late 1931-32 Super 8</a></li>
<li><a class="green" href="#">-1929-31 Standard 8</a></li>
<li><a class="green" href="#">-Late 1931-32 Standard 8</a></li>
<li><a class="green" href="#">-Rare Parts</a></li>
<li><a class="green" href="#">-745 Parts</a></li>
</ul>
</li>
<li><a class="green" href="#">{{ linklists.cadillac.title }}</a>
<ul class="sub-menu">
<li><a class="green" href="#">-1932-33 V12 & V16</a></li>
<li><a class="green" href="#">-1934-37 V12 & V16</a></li>
</ul>
</li>
<li><a class="green" href="/cart">Cart</a></li>
<li><a class="green" href="/checkout">Check Out</a></li>
</ul><!--Navigation--><!--Navigation-->
<ul class="sub-navs">
<ul class-"sub-nav">
<li>Carburetor</li>
<li>Parts</li>
<li>Manifolds</li>
<li>Accessories</li>
<li>Sculpture</li>
</ul>
</ul>
<img id="#navbar-logo" src="{{'logo.png' | asset_url}}">
<p id="nav-phone" class="black center bold">775.842.4282</p>
<p class="black center nav-small bold">packardcarbs#gmail.com</p>
<p class="black ce
nter nav-small bold">Sparks, NV USA</p>
</div><!--Navbar-->

Here is the desired output with exact functionality required in question.
See fiddle for code : http://jsfiddle.net/NNfUb/2/
Demo: http://jsfiddle.net/NNfUb/2/embedded/result
CSS:
#content
{
position:relative;
}
#flyout_container
{
position:absolute;
width:175px;
top:0;
left:0;
background:#107042;
display:none;
}
.sub-nav
{
padding:0;
margin:0;
display:none;
}
.sub-nav li
{
padding:5px 5px 5px 10px;
display:block;
color:#fff;
font-size:14px;
font-weight:bold;
}
jQuery:
$(document).ready(function(){
var container = $("<div id='flyout_container'>");
container.appendTo($("#content"));
var contentHeight = $("#content").height();
container.css({"height": (contentHeight + 10) + "px"});
$("a#show_sub_nav_1").mouseover(function(){
$("#sub_nav_1").appendTo(container).show();
container.toggle();
//container.show();
var fromTop = parseInt($(this).offset().top);
$("#sub_nav_1").css({"margin-top": (fromTop - 205) + "px"});
});
$("#flyout_container").mouseleave(function(){
$("#flyout_container").hide();
});
});
I have created the above fiddle by copying your source code from your webpage and work on that. I have created the full height functionality which is taking height upto the content height and showing the sub-links as per your desired design provided in screenshot. You need to tweek the css or code if you need any changes or enhancement. It will work on every viewport.
Note: If any issues please let me know. I hope this will solve your problem because i have used different approach.

position: absolute makes the position relative to the nearest non-static-positioned ancestor. So, if you change the navigation ul to position: relative, and the flyout to position: absolute, you will be able to set the position of the flyout menu relative to the main navigation. That means that even if you resize the page, the flyout will still be in the right spot.
#navigation {
position: relative;
}
.flyout {
position: absolute;
top: 0;
left: 100%;
}
(You could also set #navbar or #navigation > li to position: relative instead.)
You'll still need to fiddle with positioning and other styles a bit, but hopefully that sets you on the right path.

Changing the element's position to absolute will allow you to position it accurately without interrupting the flow of the document.
.flyout {
position: fixed;
left: 0px; (number of pixels from the left edge of the document)
top: 0px; (number of pixels from the top edge of the document)
}

Related

Menu Image size not Changing via css

I have this menu bar, which is replaced by Images.
All looks good on normal view, but when I swtich to mobile view
It looks so clumsy. I tried Padding, But the individual cell do not
make up space with each other.
Here is the screenshot
li.topmenu1 {
height: 20px;
}
<nav id="category" class="drawer_block pc">
<ul class="category-nav">
<li class="topmenu1">
<img src="http://azlily.bex.jp/eccube_1/html/template/default/img/menu/home.png">
</li>
<li class="topmenu2">
<img src="/eccube_1/html/template/default/img/menu/products.png">
</li>
<li class="topmenu3">
<img src="/eccube_1/html/template/default/img/menu/about.png">
</li>
<li class="topmenu4">
<img src="/eccube_1/html/template/default/img/menu/howtouse.png">
</li>
<li class="topmenu5">
<img src="/eccube_1/html/template/default/img/menu/column.png">
</li>
<li class="topmenu8">
<img src="/eccube_1/html/template/default/img/menu/FAQ.png">
</li>
</ul>
</nav>
Note - I also tried to include FULL URL of the image
but somehow its not showing up on snippets :/
check this https://jsfiddle.net/1dvy2854/4/
.category-nav li {
display: inline-block;
}
#media only screen and (max-width: 600px) {
.category-nav li {
display: block;
}
.category-nav li img {
max-width: 65px;
display: inline-block;
}}
Make sure that the elements inside category-nav have correct margins and paddings.
If you want to make sure that the individual pictures for the menu look okay, you might want to set styles for the images one by one.
So, in your case you can edit the heights for all of your topmenu1, topmenu2...
Also, you can the inspect tool on Chrome to find what is causing problems like this in your CSS code. You can change the code live and see what change is causing what.

Background image present but not visible

On the following site http://haircolourideas.eu/#section2 I have a ul in the services section and the li's have background images . The li's have classes of service1 , service2 etc. The background images have suddenly become invisible . If I inspect element the css is correct and it shows that the images are present . The site has been live a couple of months and without me changing anything this has just happened today
<ul id="services-list" class="hidden">
<li class="service1 service-img"><label class="btn" for="modal-1"><h3>meche</h3></label></li>
<li class="service2 service-img"><label class="btn" for="modal-2"><h3>tinting</h3></label></li>
<li class="service3 service-img"><label class="btn" for="modal-3"><h3>fashion</h3></label></li>
<li class="service4 service-img"><label class="btn" for="modal-4"><h3>change</h3></label></li>
</ul>
.service1 {
background: url(../img/meche1.png);
cursor: pointer;
}
.service2 {
background: url(../img/tint1.png);
cursor: pointer;
}
.service3 {
background: url(../img/fashion1.png);
cursor: pointer;
}
.service4 {
background: url(../img/change1.png);
cursor: pointer;
}
Remove class hidden from thoes nodes:
<div id="services-info" class="hidden">
<ul id="services-list" class="hidden">
<ul id="services-list" class="hidden">
<li class="service1 service-img"><label class="btn" for="modal-1"><h3>meche</h3></label></li>
<li class="service2 service-img"><label class="btn" for="modal-2"><h3>tinting</h3></label></li>
<li class="service3 service-img"><label class="btn" for="modal-3"><h3>fashion</h3></label></li>
<li class="service4 service-img"><label class="btn" for="modal-4"><h3>change</h3></label></li>
Remove the class="hidden" from your ul
The problem is that the animation doesn't function because in the ul you have class="hidden" which makes opacity: 0 that hides all the ul section. The class="hidden" is applied because you are missing this script in your server jquery.viewportchecker.js. If you open your console with inspect element you can see the error. The script makes the class hidden apply or not based on the section you are. In some way the script got deleted from your server as you can see in the link: http://haircolourideas.eu/js/jquery.viewportchecker.js so you had to put it back and with that also this jquery error:
"Uncaught TypeError: jQuery(...).addClass(...).viewportChecker is not a function"
in you console will disappear and the website will function as before
You can try this: i can say surely show your image.
.hidden {
/* opacity: 0; */
}
If don't need then remove opacity:0 property, otherwise set
opacity: 1;
Otherwise You can remove hidden class from ul
Just remove the class hidden means
<ul id="services-list" class="hidden"> not visible
<ul id="services-list" class=""> visible

jQuery mobile button icon position too far left

I am using JQM 1.4.2 and trying to get the button icons closer to the Text when using the class .ui-btn-icon-left.
I took a screen shot and modified the the list icon the way I want it to look in the middle button. I just cant seem to get the icon off the left side at all. using padding just changed the top and bottom.
What class do I need to use to accomplish this?
<div data-role="navbar" >
<ul id="navfooter">
<li>Tour</li>
<li><a class="ui-nodisc-icon ui-icon-bars ui-btn-icon-left svbtn" href="#listViewPage" data-transition="slide" >List</a></li>
<li><a class="ui-nodisc-icon ui-icon-location ui-btn-icon-left svbtn" href="#map-page" data-transition="slide" >Map</a></li>
</ul>
</div>
Here is the image of what it now looks like after adding the css
.ui-icon-home::after {
position: relative;
left:10px;
}
You can set the left position of the icons within the button:
.ui-navbar a:after {
left: 20% !important;
}
However, this will allow the icon and text to overlap as the buttons get smaller.
A better way to achieve this might be to put the icons inline with the text. You put a span in front of the text with CSS to place the icon. To control the distance between the icon and the text, tweak the margin-right attribute:
<div data-role="navbar">
<ul>
<li><span class="ui-icon-alert ui-btn-icon-notext inlineIcon"></span>Summary
</li>
<li><span class="ui-icon-star ui-btn-icon-notext inlineIcon"></span>Favs
</li>
<li><span class="ui-icon-gear ui-btn-icon-notext inlineIcon"></span>Setup
</li>
</ul>
</div>
.inlineIcon {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
If you want icons in black with no disc behind them add the ui-alt-icon class to the span and change the CSS to get rid of the disc:
<div data-role="navbar">
<ul>
<li><span class="ui-alt-icon ui-icon-alert ui-btn-icon-notext inlineIconNoDisk"></span>Summary
</li>
<li><span class="ui-alt-icon ui-icon-star ui-btn-icon-notext inlineIconNoDisk"></span>Favs
</li>
<li><span class="ui-alt-icon ui-icon-gear ui-btn-icon-notext inlineIconNoDisk"></span>Setup
</li>
</ul>
</div>
.inlineIconNoDisk {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
.inlineIconNoDisk:after {
background-color: transparent !important;
}
Here is a DEMO showing all 3 options
If it's just the home icon you're looking to move, applying the following to that icon should fix it but it's hard to say what the best solution is without seeing the menu in action.
.ui-icon-home::after {
left: (amount to shift left)px;
}
Note that ::after applies styling to just the icon, whereas ".ui-icon-home" applies to the entire anchor element. Again, if you could link to a pastebin or similar, it would be easier to give you a better answer.

scrolling top navigation bar

im trying to create a navigation bar that is sticky when im scrolling down but when i put position:fixed; on the text so they will scroll down too they overlap. i don't want to use jquery because my prof. says so.
<html>
<head> <title> My Portfolio </title>
<link rel="stylesheet" type = "text/css"
href="stylesheet.css"> </head>
<body>
<ul>
Home
<a href="About.html" > ABOUT </a >
<a href="Projects.html" >PROJECTS </a >
<a href="Resume.html" >RESUME </a >
<a href="Gallery.html" > GALLERY </a >
<b> </b>
</body>
</html>
CSS
body{
background-position:fixed;
background-repeat:repeat-x;
background-color:white;
font-family:Arial;
font-size:20px;
}
a{
color:#1b1b1b;
TEXT-DECORATION: NONE;
position:fixed;
z-index:2;
}
b{
top:0;
height:30px;
width: 100%;
background:white;
text-align:left;
position:fixed;
z-index:1;
}
Is this kind of you are looking for?
check the Demo.
http://jsbin.com/tafofesi/1/edit
There's quite a few issues with your code. For one thing, there is no closing tag on your <ul>. Some browsers will add these for you, but you shouldn't count on it. Secondly, <ul></ul> is an unordered list, which means it needs to have list items (<li></li>).
Another thing is that you're treating the <b> tag as an element. By default, <b></b> is meant to apply a bold state to text.
<ul>
<li>LINK</li>
<li>LINK</li>
<li>LINK</li>
<li><b>BOLD LINK</b></li>
</ul>
Your main problem is that you've applied the position: fixed; to your links, and not to their container. What you want is for each link to be positioned relative to the other (position: relative;). Add a container to your menu (<ul>), and make its position fixed. All elements within that container should be positioned relatively or static.
See this example here: http://jsfiddle.net/7LTqQ/.

How do I ensure that all the images are aligned correctly in differing browser windows/resolutions?

Firstly, there are 3 separate images. A chick, the word 'delivery' and 'foodstant' I wanted to align them in such a way--> 3 images
Are there any methods to achieve such positioning which enables an unchanged position despite the resizing of the browser window and perhaps resolution ?
Both Absolute and relative positioning works, but resizing the browser screws up everything.
Margins can't seem to do the trick.. Or I am just less-skilled.
HTML code as follows:
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title> Foodstant Delivery </title>
<link rel="stylesheet" type="text/css" media="screen" href="stylo.css" />
<link rel="shortcut icon" href="favicon.ico" />
</head>
<body>
<figure>
<img id="del" src="images/delivery12.png" alt="Delivery" />
<img id="foo" src="images/foostant2.png" alt="Foodstant" />
<img id="chi" src="images/logochick.png" alt="Chick" />
</figure>
<nav id="hnavbar">
<ul id="hli">
<li><a id="home" href="index.html">Home</a></li>
<li><a id="menu" href="menu.html">Menu</a></li>
<li><a id="cu" href="ContactUs.html">Contact Us</a></li>
<li><a id="au" href="aboutus.html">About Us</a></li>
<li><a id="tc" href="TC.html">Terms & Conditions</a></li>
<li><a id="job" href="jobs.html" target="_blank">Jobs</a></li>
<li><a id="yo" href="order.html">Your Order</a></li>
</ul>
</nav>
</body>
CSS code as follows
/* Foodstant Delivery */
* {
margin: 0;
padding:0;
}
body { font-family: 'Comic Sans MS',Verdana,Helvetica,Courier New,sans-serif;
background:url("images/bg.jpg");
}
/* home page */
#hnavbar{
font-size:2em;
margin-top:-13em;
}
#hnavbar ul li {
list-style-type:none;
width:325px;
display:inline;
padding:0 13px 0 13px;
}
#chi {
position:relative;
top:-30em;
left:10em;
}
#foo {
position:relative;
top:1em;
left:-11em;
}
#del {
position:relative;
top:10.5em;
left:26em;
}
/* home page */
Many thanks in advance.
Specify the values for top and left in percents as opposed to 'em'. These percentages would be relative to the parent element containing these image. OR simply use one single image instead of 3 and use a image map. Here s a coupla online tools to do this:
http://www.mobilefish.com/services/image_map/image_map.php
http://www.image-maps.com/
I recently had to do something very similar to this and after some time I decided I had to use absolute positioning to every link. The problem with your code is that it seems that you don't quite understand how relative and absolute positioning works. Absolute objects are always relative to it's nearer parent set to "relative position". So you should try this:
#hnavbar { position: relative; } //all "absolute" children will be relative to this hnavbar
#home, #menu, ... { position: absolute; }
And after that, you should set the position of every absolute positioned menu link with top/left or bottom/right properties.
For the image, if you don't have links for "Foodstant" and "Delivery", I would really use one single image.
Hope it helps!