Issue with z-index and positioning - css-position

I am having trouble with z-index at the moment. Using some of the answers above has progressed the issue but has not solved it yet.
My Over div has a relative position and z-index of 99999 My under div has a fixed position and z-index of 0.
I tried what was mentioned in this thread and changed my under div to a relative position, however while this hides the div intially, when I click a button to slide the Over div to the right to reveal the under div, it is not there, it is at the bottom of the page under the footer.
I am copying an example put online, and in the sample online it works with the relative and fixed positions. Its the FB style menu. Slide your content to the right to reveal your menu. i believe thats why its fixed, rather than relative.
I was hoping someone could advise why this works in the example as everyone above noted that z-index works within a context.
Online Example http://media02.hongkiat.com/mobile-navi-with-jquery/demo/index.html
EDIT: Adding sample code.
HTML Markup:
<div id="w">
<div id="pagebody">
<header id="toolbarnav">
<h1>HK Mobile</h1>
</header>
<section id="content" class="clearfix">
<h2>Welcome to the Mobile Site!</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed lorem sapien, auctor placerat varius sed, aliquam et nibh. Quisque posuere erat nec tortor vestibulum id dignissim quam ornare. Suspendisse sapien ante, pellentesque non interdum ac, feugiat at eros. Morbi lacus augue, blandit ac porta a, rutrum quis tellus. Nam ut velit lorem, sit amet placerat lorem.</p>
<img src="img/hongkiat-lim.png" alt="Hongkiat Lim" class="photo">
<p>Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam convallis lacinia dapibus. Sed nunc enim, ultrices nec suscipit ac, malesuada pharetra diam. Etiam massa orci, pellentesque nec lacinia eu, vulputate non est. Donec faucibus, tellus eu ultrices lobortis, leo nisl iaculis elit, id dictum arcu massa in nibh. Nulla auctor vehicula rutrum. Vivamus mi mauris, molestie sit amet placerat ac, tempor vitae nisi. Fusce pharetra eleifend aliquam. Cras ultricies orci sit amet ligula tempor pulvinar.</p>
<p>Vivamus consectetur nulla vel neque accumsan bibendum lacinia nibh venenatis. Morbi placerat tempor nunc, eu congue metus pellentesque vitae.</p>
<p>Maecenas lacinia commodo venenatis. Sed nec mauris sapien. Donec eget justo sapien, id elementum magna. Integer et orci quis urna tempus eleifend eget eu nulla. Quisque interdum porttitor tincidunt. Nulla ornare dolor elit, eu adipiscing felis. Nulla viverra blandit bibendum. Mauris non tellus lacus.</p>
<p>Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Aliquam convallis lacinia dapibus. Sed nunc enim, ultrices nec suscipit ac, malesuada pharetra diam. Etiam massa orci, pellentesque nec lacinia eu, vulputate non est. Donec faucibus, tellus eu ultrices lobortis, leo nisl iaculis elit, id dictum arcu massa in nibh.</p>
<p>Nulla auctor vehicula rutrum. Vivamus mi mauris, molestie sit amet placerat ac, tempor vitae nisi. Fusce pharetra eleifend aliquam. Cras ultricies orci sit amet ligula tempor pulvinar. Vivamus consectetur nulla vel neque accumsan bibendum lacinia nibh venenatis. Morbi placerat tempor nunc, eu congue metus pellentesque vitae.</p>
<p>Maecenas lacinia commodo venenatis. Sed nec mauris sapien. Donec eget justo sapien, id elementum magna. Integer et orci quis urna tempus eleifend eget eu nulla. Quisque interdum porttitor tincidunt. Nulla ornare dolor elit, eu adipiscing felis. Nulla viverra blandit bibendum. Mauris non tellus lacus.</p>
<p><center><img src="img/pencilman.jpg" alt="pencilmannn"></center></p>
</section>
</div>
<div id="navmenu">
<header>
<h1>Menu Links</h1>
</header>
<ul>
<li>Home</li>
<li>About Us</li>
<li>Advertise</li>
<li>Write for Us</li>
<li>Contacts</li>
<li>Privacy Policy</li>
</ul>
</div>
</div>
CSS:
body { background: #181c1f; font-family: "Trebuchet MS", Arial, Tahoma, sans-serif; font-size: 62.5%; line-height: 1; }
a { -webkit-tap-highlight-color: rgba(0,0,0,0); -webkit-touch-callout: none; }
img { border: 0; }
img.photo { padding: 2px; background: #888; border: 1px solid #cecece; border-bottom-color: #aaa; border-right-color: #aaa; float: right; margin-left: 20px; margin-right: 11px; }
ul,ol,h1,h2,h3,h4,h5,h6,p { display: block; }
#w { position: relative; overflow-x: hidden; overflow-y: hidden; }
/** #group core body **/
#w #pagebody { position: relative; left: 0; max-width: 640px; min-width: 320px; z-index: 99999; }
#w #navmenu { background: #475566; height: 100%; display: block; position: fixed; width: 300px; left: 0px; top: 0px; z-index: 0; }
/** #group header **/
#w #pagebody header#toolbarnav { display: block; position: fixed; left: 0px; top: 0px; z-index: 9999; background: #0b1851 url('img/tabbar-solid-bg.png') top left no-repeat; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; -o-border-radius: 5px; border-bottom-right-radius: 0; -moz-border-radius-bottomright: 0; -webkit-border-bottom-right-radius: 0; border-bottom-left-radius: 0; -moz-border-radius-bottomleft: 0; -webkit-border-bottom-left-radius: 0; height: 44px; width: 100%; max-width: 640px; }
#w #pagebody header#toolbarnav h1 { text-align: center; padding-top: 10px; padding-right: 40px; color: #e6e8f2; font-weight: bold; font-size: 2.1em; text-shadow: 1px 1px 0px #313131; }
#w #pagebody header #menu-btn { display: block; float: left; width: 53px; height: 30px; background: url('img/nav-btn.png') no-repeat; margin-top: 6px; margin-left: 8px;}
#w #pagebody #content { display: block; background: #fff; padding: 5px 12px; margin-top: 40px; min-height: 550px; height: 100%; z-index: 9999; }
#w #pagebody #content h2 { border-bottom: 1px solid #ddd; border-top: 1px solid #ddd; color: #181818;
font-family: "Droid Serif", Georgia, serif; font-size: 2.6em; line-height: 1.8em; font-weight: 500; margin-top: 25px; margin-bottom: 25px; padding: 12px 0; text-align: center; }
#w #pagebody #content h3 { font-family: "Calibri", Verdana, Arial, sans-serif; font-weight: 700; font-size: 1.8em; line-height: 1.75em; text-transform: capitalize; margin-bottom: 5px; color: #222; }
#w #pagebody #content p { font-size: 1.4em; line-height: 1.6em; margin-bottom: 15px; color: #444; }
#w #pagebody #content a { color: #78a5ce; }
#w #pagebody #content a:hover { color: #678eb2; }
/** #group nav menu **/
#w #navmenu header { display: block; background: #303a44; height: 44px; }
#w #navmenu header h1 { text-align: center; padding-top: 10px; color: #e6e8f2; font-weight: bold; font-size: 2.1em; text-shadow: 1px 1px 0px #313131; }
#w #navmenu ul { list-style: none; background: #475566; height: 100%; }
#w #navmenu ul li { display: block; }
#w #navmenu ul li a { position: relative; display: block; border-bottom: 1px solid #303c4a; padding: 14px 11px; font-weight: bold; color: #f0f0f0; text-shadow: -1px -1px 1px #222; font-size: 1.6em; text-decoration: none; }
#w #navmenu ul li a:hover { color: #cad0e6; text-decoration: none; }
#w #navmenu ul li a::after {
content: '';
display: block;
width: 6px;
height: 6px;
border-right: 3px solid #d0d0d8;
border-top: 3px solid #d0d0d8;
position: absolute;
right: 30px;
top: 45%;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
#w #navmenu ul li a:hover::after { border-color: #cad0e6; }
/** #group misc **/
.blue { color: #1c609f !important; font-weight: bold; }
/** #group clearfix **/
.clearfix:after { content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }
.clearfix { display: inline-block; }
html[xmlns] .clearfix { display: block; }
* html .clearfix { height: 1%; }
My code is not the exact same but its similar. I just want to understand why z-index works in this example with 2 different positions set, relative and fixed, as that is what I need to achieve.

Related

HTML - Gap between Main content and Footer

I'm using this footer as reference to my Website but I've detected a situation when the main content is short, which creates a gap between both elements (See image below).
Anyone can give me a hand in this? :) I'll post the necessary code!
#inherits LayoutComponentBase
<div class="sidebar">
<NavMenu />
</div>
<div class="main">
<div class="top-row px-4 auth">
<LoginDisplay />
</div>
#Body
<!-- footer -->
https://codepen.io/scanfcode/pen/MEZPNd (HTML and CSS of Footer is here)
</div>
main CSS:
You may need to update your HTML structure in right panel.
follow
<div class="content">
<h1>Sticky Footer with Negative Margin 1</h1>
<div class="push">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.
</p>
</div>
</div>
<footer class="footer">
Footer
</footer>
<style>
html, body {
height: 100%;
margin: 0;
}
.content {
padding: 20px;
min-height: 100%;
margin: 0 auto -50px;
}
.footer,
.push {
height: 50px;
}
* {
box-sizing: border-box;
}
body {
font: 16px Sans-Serif;
}
h1 {
margin: 0 0 20px 0;
}
p {
margin: 20px 0 0 0;
}
footer {
background: #42A5F5;
color: white;
line-height: 50px;
padding: 0 20px;
}
</style>

I'm having some difficulty with media query

I'm working on a Responsive Html email and media query is not working properly.
https://drive.google.com/open?id=1brZBV7hLqRw_KL37NXMyWgwYJpuz1Hpq
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Our Vineyard</title>
<style type="text/css">
body {
margin: 0; padding: 0;
}
#media only screen and (max-width: 660px) {
table.container { width: 480px !important; }
td.logo img { display: none; }
td.logo { background: #fff url(images/logo_medium.gif) no-repeat 10px 10px; height: 45px; }
}
#media only screen and (max-width: 510px) {
table.container { width: 100% !important; }
table.container td { border: none !important; }
td.logo { background: #fff url(images/logo_small.gif) no-repeat center 10px; height: 32px; }
}
</style>
</head>
<body bgcolor="#efe1b0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#efe1b0">
<tr>
<td>
<table class="container" width="640" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" class="logo" bgcolor="#ffffff" style="padding: 10px 20px 0px 30px;
border-left: 1px solid #dbc064; border-right: 1px solid #dbc064; border-top: 1px solid #dbc064;">
<img style="margin-left: -15px;" src="images/logo_large.gif" alt="Our Vineyard" width="585" height="45" border="0"></a>
</td>
</tr>
<tr>
<td valign="top" class="headline" bgcolor="#ffffff" style="padding: 15px 20px 5px 30px; border-left: 1px solid #dbc064; border-right: 1px solid #dbc064; font-family: Arial, Helvetica, sans-serif; font-size: 16px; line-height: 22px;">
<h1 style="margin: 0px 0px 15px 0px; font-weight: normal; font-size: 32px; color: #723c7f;">Main Heading Here</h1>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#f5f2e5" class="banner" style="border-left: 1px solid #dbc064; border-right: 1px solid #dbc064;">
<img src="images/banner_large.jpg" width="638" height="180" alt="Photo of Our Vineyard">
</td>
</tr>
<tr>
<td valign="top" bgcolor="#f5f2e5" valign="top" class="content" style="padding: 30px 30px 10px 30px; border-right: 1px solid #dbc064; border-left: 1px solid #dbc064; font-family:Arial, Helvetica, sans-serif; font-size: 16px; line-height:22px; color: #654308; background: #f5f2e2 url(images/banner_large_ghost.jpg) no-repeat 0px 0px;">
<table width="160" align="right" class="button" style="margin: 0px 0px 10px 30px;">
<tr>
<td style="text-align: center; background-color: #71a412; padding: 10px 15px; border-radius: 5px;">
Learn More
</td>
</tr>
</table>
Lorem ipsum dolor sit amet consec tetur adip isicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam quis nostrud exercita tion ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum eu fugiat nulla.
<br><br>
Enjoy,
<br>
<img src="images/chris.gif" alt="Chris" width="90" height="40">
</td>
</tr>
<tr>
<td valign="top" bgcolor="#f5f2e5" class="promos" style="padding: 10px 30px 25px 30px; border-right:1px solid #dbc064; border-left:1px solid #dbc064; background-color: #f5f2e5; font-family: Arial, Helvetica, sans-serif;">
<table class="promo_1" width="270" align="left">
<tr>
<td>
<img class="promo" alt="Promo image 1" src="images/promo_1_large.jpg">
<h3 style="font-size:16px;">Promo heading here</h3>
Lorem ipsum dolor sit amet consectetur incididunt ut labore et dolore magna aliqua elit sed do eiusmod.
<br><br>
Learn more
</td>
</tr>
</table>
<table class="promo_2" width="270" align="right">
<tr>
<td>
<img class="promo" alt="Promo image 2" src="images/promo_2_large.jpg">
<h3 style="font-size:16px;">Promo heading here</h3>
Lorem ipsum dolor sit amet consectetur incididunt ut labore et dolore magna aliqua elit sed do eiusmod.
<br><br>
Learn more
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#55315d" class="callout" style="background-color: #55315d; padding: 30px; border-right: 1px solid #dbc064; border-bottom: 1px solid #dbc064; border-left: 1px solid #dbc064;">
<table class="callout_1" width="135" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="135" style="padding-left: 10px; padding-right: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; line-height: 16px; color: #ffffff;">
<img src="images/icon_grapes.gif" width="75" height="75"><br>
Lorem ipsum dolor sit amet conctetur adipi eiu smod incid amet idun.
<br><br>
Learn more
</td>
</tr>
</table>
<table class="callout_2" width="135" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="135" style="padding-left: 10px; padding-right: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; line-height: 16px; color: #ffffff;">
<img src="images/icon_bottle.gif" width="75" height="75"><br>
Ddolore eu fugiat nulla pariatur cupi datat excepteur occaet cupi noin.
<br><br>
Learn more
</td>
</tr>
</table>
<table class="callout_3" width="135" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="135" style="padding-left: 10px; padding-right: 10px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: #ffffff;">
<img src="images/icon_basket.gif" width="75" height="75"><br>
Eiusmod tempor inci didunt ut magna aliqua ut enim ad iam quis.
<br><br>
Learn more
</td>
</tr>
</table>
<table class="callout_4" width="135" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="135" style="padding-left: 10px; padding-right: 10px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: #ffffff;">
<img src="images/icon_camera.gif" width="75" height="75"><br>
Excepteur sint occaecat cupidatat non proident sunt in culpa qui molit.
<br><br>
Learn more
</td>
</tr>
</table>
<br style="clear: both;">
</td>
</tr>
<tr>
<td valign="top" class="footer" style="padding: 10px 0px 30px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #b2a16e;">
© Your Company Name. PLEASE DO NOT REPLY TO THIS MESSAGE:
<br><br>
Your privacy is important to us. Please use this link to unsubscribe.
<br><br>
Lorem ipsum dolor sit amet consectetur adipi sicing elit sed do eiusmod tempor inci didunt ut labore et dolore iqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
email.html
You missing the meta viewport at head tag
<meta name="viewport" content="width=device-width, initial-scale=1.0">
You need add to head tag, the #media will apply base on device witdh
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
And notice that css content will apply the last match selector from top to down.
If you want to hide the logo you need move #media 660px move down below #media 510px
#media only screen and (max-width: 510px) {
table.container { width: 100% !important; }
table.container td { border: none !important; }
td.logo { background: #fff url(images/logo_small.gif) no-repeat center 10px; height: 32px; }
}
#media only screen and (max-width: 660px) {
table.container { width: 480px !important; }
td.logo img { display: none; }
td.logo { background: #fff url(images/logo_medium.gif) no-repeat 10px 10px; height: 45px; }
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Our Vineyard</title>
<style type="text/css">
body {
margin: 0; padding: 0;
}
#media only screen and (max-width: 660px) {
table.container { width: 480px !important; }
td.logo img { display: none; }
td.logo { background: #fff url(images/logo_medium.gif) no-repeat 10px 10px; height: 45px; }
}
#media only screen and (max-width: 510px) {
table.container { width: 100% !important; }
table.container td { border: none !important; }
td.logo { background: #fff url(images/logo_small.gif) no-repeat center 10px; height: 32px; }
}
</style>
</head>
<body bgcolor="#efe1b0">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#efe1b0">
<tr>
<td>
<table class="container" width="640" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top" class="logo" bgcolor="#ffffff" style="padding: 10px 20px 0px 30px;
border-left: 1px solid #dbc064; border-right: 1px solid #dbc064; border-top: 1px solid #dbc064;">
<img style="margin-left: -15px;" src="images/logo_large.gif" alt="Our Vineyard" width="585" height="45" border="0"></a>
</td>
</tr>
<tr>
<td valign="top" class="headline" bgcolor="#ffffff" style="padding: 15px 20px 5px 30px; border-left: 1px solid #dbc064; border-right: 1px solid #dbc064; font-family: Arial, Helvetica, sans-serif; font-size: 16px; line-height: 22px;">
<h1 style="margin: 0px 0px 15px 0px; font-weight: normal; font-size: 32px; color: #723c7f;">Main Heading Here</h1>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#f5f2e5" class="banner" style="border-left: 1px solid #dbc064; border-right: 1px solid #dbc064;">
<img src="images/banner_large.jpg" width="638" height="180" alt="Photo of Our Vineyard">
</td>
</tr>
<tr>
<td valign="top" bgcolor="#f5f2e5" valign="top" class="content" style="padding: 30px 30px 10px 30px; border-right: 1px solid #dbc064; border-left: 1px solid #dbc064; font-family:Arial, Helvetica, sans-serif; font-size: 16px; line-height:22px; color: #654308; background: #f5f2e2 url(images/banner_large_ghost.jpg) no-repeat 0px 0px;">
<table width="160" align="right" class="button" style="margin: 0px 0px 10px 30px;">
<tr>
<td style="text-align: center; background-color: #71a412; padding: 10px 15px; border-radius: 5px;">
Learn More
</td>
</tr>
</table>
Lorem ipsum dolor sit amet consec tetur adip isicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam quis nostrud exercita tion ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum eu fugiat nulla.
<br><br>
Enjoy,
<br>
<img src="images/chris.gif" alt="Chris" width="90" height="40">
</td>
</tr>
<tr>
<td valign="top" bgcolor="#f5f2e5" class="promos" style="padding: 10px 30px 25px 30px; border-right:1px solid #dbc064; border-left:1px solid #dbc064; background-color: #f5f2e5; font-family: Arial, Helvetica, sans-serif;">
<table class="promo_1" width="270" align="left">
<tr>
<td>
<img class="promo" alt="Promo image 1" src="images/promo_1_large.jpg">
<h3 style="font-size:16px;">Promo heading here</h3>
Lorem ipsum dolor sit amet consectetur incididunt ut labore et dolore magna aliqua elit sed do eiusmod.
<br><br>
Learn more
</td>
</tr>
</table>
<table class="promo_2" width="270" align="right">
<tr>
<td>
<img class="promo" alt="Promo image 2" src="images/promo_2_large.jpg">
<h3 style="font-size:16px;">Promo heading here</h3>
Lorem ipsum dolor sit amet consectetur incididunt ut labore et dolore magna aliqua elit sed do eiusmod.
<br><br>
Learn more
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#55315d" class="callout" style="background-color: #55315d; padding: 30px; border-right: 1px solid #dbc064; border-bottom: 1px solid #dbc064; border-left: 1px solid #dbc064;">
<table class="callout_1" width="135" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="135" style="padding-left: 10px; padding-right: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; line-height: 16px; color: #ffffff;">
<img src="images/icon_grapes.gif" width="75" height="75"><br>
Lorem ipsum dolor sit amet conctetur adipi eiu smod incid amet idun.
<br><br>
Learn more
</td>
</tr>
</table>
<table class="callout_2" width="135" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="135" style="padding-left: 10px; padding-right: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; line-height: 16px; color: #ffffff;">
<img src="images/icon_bottle.gif" width="75" height="75"><br>
Ddolore eu fugiat nulla pariatur cupi datat excepteur occaet cupi noin.
<br><br>
Learn more
</td>
</tr>
</table>
<table class="callout_3" width="135" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="135" style="padding-left: 10px; padding-right: 10px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: #ffffff;">
<img src="images/icon_basket.gif" width="75" height="75"><br>
Eiusmod tempor inci didunt ut magna aliqua ut enim ad iam quis.
<br><br>
Learn more
</td>
</tr>
</table>
<table class="callout_4" width="135" align="left" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" width="135" style="padding-left: 10px; padding-right: 10px; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 16px; color: #ffffff;">
<img src="images/icon_camera.gif" width="75" height="75"><br>
Excepteur sint occaecat cupidatat non proident sunt in culpa qui molit.
<br><br>
Learn more
</td>
</tr>
</table>
<br style="clear: both;">
</td>
</tr>
<tr>
<td valign="top" class="footer" style="padding: 10px 0px 30px 0px; font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #b2a16e;">
© Your Company Name. PLEASE DO NOT REPLY TO THIS MESSAGE:
<br><br>
Your privacy is important to us. Please use this link to unsubscribe.
<br><br>
Lorem ipsum dolor sit amet consectetur adipi sicing elit sed do eiusmod tempor inci didunt ut labore et dolore iqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

In Vue.js how to make a nav fade in on scroll down event and fade out where scroll pageYOffset = 0

I am working on a Vue.js project and i am stuck on a small animation for the header navbar.
I want to listen to the users scroll event and fade in and out the nav-bar, if user scrolls down, fade in and if user scrolls back to top: 0 fade out, and show a full screen intro without navigation bar. the nav is fixed/sticky at the top.
How can i do this using Vue.js?
for a better visualization :
this is the screenshot of my page
I adapted this solution to your case by adding showNavbar property to your data object that change the navbar state and using transition element with name='fade' that wraps navbar element, in your CSS you have to add the following rules :
.fade-enter-active
{
transition: all 1s;
}
.fade-leave-active {
transition: all 2s;
}
.fade-enter, .fade-leave-to {
opacity: 0;
}
finally you should add an event listener to scrolling event like :
window.addEventListener('scroll', this.handleScroll);
and checking the value of window.pageYOffset as follow :
window.pageYOffset>0?this.showNavbar=true:this.showNavbar=false;
the following code works fine :
new Vue({
el: '#app',
data() {
return {
showNavbar:false
}
},
methods:{
handleScroll (event) {
window.pageYOffset>0?this.showNavbar=true:this.showNavbar=false;
}
},
created () {
window.addEventListener('scroll', this.handleScroll);
},
destroyed () {
window.removeEventListener('scroll', this.handleScroll);
}
})
body {
margin: 0;
font-size: 28px;
font-family: Arial, Helvetica, sans-serif;
}
.header {
background-color: #f1f1f1;
padding: 30px;
text-align: center;
}
#navbar {
overflow: hidden;
background-color: #333;
}
#navbar a {
float: left;
display: block;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
#navbar a:hover {
background-color: #ddd;
color: black;
}
#navbar a.active {
background-color: #4CAF50;
color: white;
}
.content {
padding: 16px;
}
.sticky {
position: fixed;
top: 0;
width: 100%;
}
.sticky + .content {
padding-top: 60px;
}
.fade-enter-active
{
transition: all 1s;
}
.fade-leave-active {
transition: all 2s;
}
.fade-enter, .fade-leave-to {
opacity: 0;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" >
</head>
<body>
<div id="app">
<div class="header">
<h2>Scroll Down</h2>
<p>Scroll down to see the sticky effect.</p>
</div>
<transition name="fade">
<div id="navbar" class="sticky" v-if="showNavbar">
<a class="active" href="javascript:void(0)">Home</a>
News
Contact
</div>
</transition >
<div class="content">
<h3>Sticky Navigation Example</h3>
<p>The navbar will stick to the top when you reach its scroll position.</p>
<p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
<p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
<p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
<p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
<p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
<p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
<p>Some text to enable scrolling.. Lorem ipsum dolor sit amet, illum definitiones no quo, maluisset concludaturque et eum, altera fabulas ut quo. Atqui causae gloriatur ius te, id agam omnis evertitur eum. Affert laboramus repudiandae nec et. Inciderint efficiantur his ad. Eum no molestiae voluptatibus.</p>
</div>
</div>
</body>
</html>

Reloading page is flashing content on slot in vue component

Is there any way to avoid this flicker on page refresh, it's a modal component which takes HTML as slot, but when I refresh the page it flashes. My app is not using a router so it's not complete SPA.
see the gif.
Here is the code.
.body {
padding: 2em;
text-align: center;
display: table-cell;
vertical-align: middle;
}
.modal-mask {
position: absolute;
z-index: 9998;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, .5);
display: table;
transition: opacity .3s ease;
}
.modal-wrapper {
display: table-cell;
vertical-align: middle;
}
.modal-container {
width: 70%;
margin: 1em auto;
padding: 20px 30px;
background-color: #fff;
border-radius: 2px;
box-shadow: 0 2px 8px rgba(0, 0, 0, .33);
transition: all .3s ease;
font-family: Helvetica, Arial, sans-serif;
}
.modal-header h3 {
margin-top: 0;
color: #42b983;
}
.modal-body {
margin: 20px 0;
}
.modal-default-button {
float: right;
}
/*
* The following styles are auto-applied to elements with
* transition="modal" when their visibility is toggled
* by Vue.js.
*
* You can easily play with the modal transition by editing
* these styles.
*/
.modal-enter {
opacity: 0;
}
.modal-leave-active {
opacity: 0;
}
.modal-enter .modal-container,
.modal-leave-active .modal-container {
-webkit-transform: scale(1.1);
transform: scale(1.1);
}
<!-- template for the modal component -->
<script type="text/x-template" id="modal-template">
<transition name="modal">
<div class="modal-mask">
<div class="modal-wrapper">
<div class="modal-container">
<div class="modal-header">
<slot name="header">
default header
</slot>
<button class="modal-default-button" #click="$emit('close')">Close</button>
</div>
<div class="modal-body">
<slot name="body">
default body
</slot>
</div>
<div class="modal-footer">
<slot name="footer">
default footer
<button class="modal-default-button" #click="$emit('close')">
OK
</button>
</slot>
</div>
</div>
</div>
</div>
</transition>
</script>
<!-- app -->
<div id="app">
<button id="show-modal" #click="showModal = true">Show Modal</button>
<!-- use the modal component, pass in the prop -->
<modal v-if="showModal" #close="showModal = false">
<!--
you can use custom content here to overwrite
default content
-->
<div slot="body">
<div class="modal-body">
<h4>Text in a modal</h4>
<p>Duis mollis, est non commodo luctus, nisi erat porttitor ligula.</p>
<h4>Popover in a modal</h4>
<p>This button should trigger a popover on click.</p>
<h4>Tooltips in a modal</h4>
<p>This link and that link should have tooltips on hover.</p>
<hr>
<h4>Overflowing text to show scroll behavior</h4>
<p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
<p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
<p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
<p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
<p>Cras mattis consectetur purus sit amet fermentum. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
<p>Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor.</p>
<p>Aenean lacinia bibendum nulla sed consectetur. Praesent commodo cursus magna, vel scelerisque nisl consectetur et. Donec sed odio dui. Donec ullamcorper nulla non metus auctor fringilla.</p>
</div>
</div>
<h3 slot="header">custom header</h3>
</modal>
</div>
<script src="https://unpkg.com/vue#latest/dist/vue.js"></script>
<script>
// register modal component
Vue.component('modal', {
template: '#modal-template'
})
// start app
new Vue({
el: '#app',
data: {
showModal: false
}
})
</script>
Most usually this is due to the fact that your vue.js requires to load until it is able to do what you want.
You basically load html content which is by default visible.
After the html you load vue and vue will hide your content due to your v-if or v-show statements. The most simple way to ensure something like this is not happening is to use the v-cloak directive plus a little bit of css.
Place it at a very high level as given in this example
<div id="app"><!-- vue mounted at this div -->
<div v-cloak>
<!-- your actual code / content -->
</div>
</div>
And the css
[v-cloak] { display: none; }
The v-cloak property will be removed as soon as vue is done with loading. Therefore everything is hidden until vue is done with loading. This should ensure your content is not flashing.

Is this a possible browser quirk with safari and column wrapped flexbox's?

Compare how my flexbox looks in chrome or firefox and how it looks in safari. Chrome & Firefox are correct.
In Safari, It's acting like the minimum height of the flex box is calculated based on the bottom position of the last flex item, whereas in other browsers it seems to calculate the minimum height of the flex box based upon any flex item which takes it over the minimum.
Can anybody find out if my code is wrong or confirm that this is a bug?
View snippet in full page to see.
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
.wrapper {
margin: 0 auto;
max-width: 984px;
}
.container {
margin: 0 80px;
padding: 30px 0;
}
h1 {
margin: 0;
}
.top {
position: relative;
display: flex;
flex-direction: column;
max-height: 800px;
flex-wrap: wrap;
}
.prod-header {
order: 3;
width: 49%;
padding-left: 30px;
}
.prod-header img {
width: 100%;
}
.my-slider {
order: 1;
width: 51%;
padding-right: 30px;
}
.my-slider img {
width: 100%;
}
.prod-info {
order: 4;
width: 49%;
padding-left: 30px;
}
.prod-video {
order: 2;
width: 51%;
padding-right: 30px;
}
.prod-video iframe {
width: 100%;
}
.prod-review {
position: absolute;
bottom: 0;
right: 0;
order: 5;
padding-left: 30px;
width: 49%;
}
.prod-review img {
width: 100%;
}
<div class="wrapper">
<div class="container">
<div class="top flex">
<header class="prod-header">
<h1><img src="http://placehold.it/608x300"></h1>
<p>Family trivia game</p>
</header>
<div class="my-slider">
<img src="http://placehold.it/608x675">
</div>
<div class="prod-info">
<p>Lorem ipsum Occaecat qui proident aute id voluptate velit nulla anim incididunt.</p>
<p>Lorem ipsum Velit sint dolore dolor irure ullamco eu. Lorem ipsum Aute irure velit ad in sunt Duis sint veniam minim in labore voluptate. Lorem ipsum Laborum dolore eiusmod Ut deserunt occaecat aliquip amet do esse quis tempor et.</p>
</div>
<div class="prod-video">
<div class="videoWrapper">
<iframe width="420" height="315" src="https://www.youtube.com/embed/KqtvA6xo4DE" frameborder="0" allowfullscreen></iframe>
</div>
</div>
<div class="prod-review">
<img src="http://placehold.it/608x375">
<a class="button" href="#">Buy now</a>
</div>
</div>
</div>
</div>
It looks like this is indeed a Safari-specific Bug.