Note that there are some explanatory texts on larger screens.

plurals
  1. POone page website with css transition to sweep content in from alternating sides
    primarykey
    data
    text
    <p>I am trying to create a one page website with 7 navigation links. See my fiddle below.</p> <p>The first navigation link is located in the top left corner, for now its text called "home". The other 6 links are located underneath my "middle" div.</p> <p>I am trying to achieve the following effect:</p> <ul> <li>the home page is always displayed upon landing</li> <li>the 6 links underneath the "middle" div should appear from either the left side of the screen or right side simply depending on this logic: 1st transition enter screen from right side, 2nd transition enter screen from left side, all subsequent transitions to alternate sides.</li> <li>Each transition should push the existing content off the screen instead of overlapping it.</li> <li>If the navigation links are explored in sequence from page 1 to page 6, each time a link is clicked the transition should alternate sides. In my current fiddle (although not working correctly) the pages 1 through 6 will all enter the screen from right hand side and if you navigate backwards from 6 to 1 they all enter the screen from the left. This is not what I am looking for. I want alternating sides regardless of which link is clicked except home link in top left.</li> <li>when the home link is clicked when viewing another links content the transition should appear from top of the screen and push the existing content off the bottom of the screen. This transition should happen behind all the other divs ie. header and footer.</li> </ul> <p>If anyone is able to help me I would really appreciate it as this has taken me quite some time and research.</p> <p>Here is my html:</p> <pre><code> &lt;div class="main"&gt; &lt;div class="main_header"&gt; &lt;div id="navigation"&gt; &lt;a id="home_link" href="index.php"&gt;Home&lt;/a&gt; &lt;form action="url" method="post" class="formTop"&gt; &lt;input type="text" class="login" Value="Email Address"onfocus="if (this.value == 'Email Address') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Email Address';}" /&gt; &lt;input type="password" class="login" value="Password" onFocus="if (this.value == 'Password') {this.value = '';}" onBlur="if (this.value == '') {this.value = 'Password';}" /&gt; &lt;input type="submit" class="submitButton" value="Log in" /&gt; &lt;a href="sign up url"&gt;Sign Up&lt;/a&gt; &lt;/form&gt; &lt;/div&gt; &lt;!--navigation--&gt; &lt;/div&gt; &lt;!--main_header--&gt; &lt;div class="main_header_bottom"&gt;&lt;/div&gt; &lt;div id="middle"&gt; &lt;div id="page1_content" class "content"&gt;Page 1 Content&lt;/div&gt; &lt;div id="page2_content" class "content"&gt;Page 2 Content&lt;/div&gt; &lt;div id="page3_content" class "content"&gt;Page 3 Content&lt;/div&gt; &lt;div id="page4_content" class "content"&gt;Page 4 Content&lt;/div&gt; &lt;div id="page5_content" class "content"&gt;Page 5 Content&lt;/div&gt; &lt;div id="page6_content" class "content"&gt;Page 6 Content&lt;/div&gt; &lt;/div&gt; &lt;!--middle--&gt; &lt;div class="sub_footer"&gt; &lt;a href="javascript:;" id="page1" class="links"&gt;Page 1&lt;/a&gt; &lt;a href="javascript:;" id="page2" class="links"&gt;Page 2&lt;/a&gt; &lt;a href="javascript:;" id="page3" class="links"&gt;Page 3&lt;/a&gt; &lt;a href="javascript:;" id="page4" class="links"&gt;Page 4&lt;/a&gt; &lt;a href="javascript:;" id="page5" class="links"&gt;Page 5&lt;/a&gt; &lt;a href="javascript:;" id="page6" class="links"&gt;Page 6&lt;/a&gt; &lt;/div&gt; &lt;!--sub_footer--&gt; &lt;div class="footer"&gt; &lt;p&gt;&lt;a href="contactme.php" target="_blank"&gt;| Contact |&lt;/a&gt; &lt;br /&gt; &lt;SCRIPT LANGUAGE="JavaScript"&gt; today = new Date(); y0 = today.getFullYear(); &lt;/SCRIPT&gt;Copyright &amp;copy; 2012- &lt;SCRIPT LANGUAGE="JavaScript"&gt; document.write(y0); &lt;/SCRIPT&gt; MySampleSiteUnderSonstruction.com. All Rights Reserved&lt;/p&gt; &lt;/div&gt; &lt;!--footer--&gt; &lt;/div&gt; &lt;!--main--&gt; </code></pre> <p>Here is my CSS</p> <pre><code>body { background-color: #F5F5F5; padding: 0; margin: 0; text-shadow: 1px 1px 1px #CCC; font: 0.7em Arial, sans-serif; line-height: 1.5em; color: #454545; overflow-x: hidden; } a { color: #0E4D8B; background: inherit; } a:hover { color: #000; background: inherit; } a.title { color: #B41A1A; background: #FFF; } h1 { font: bold 2em Arial, Sans-Serif; letter-spacing: -1px; padding: 16px 0 0 8px; margin: 0; } h2 { margin: 0; padding: 0; font: normal 1.6em Arial, Sans-Serif; letter-spacing: -1px; } h1 a { color: #FFF; background: inherit; } h1 a, h2 a { text-decoration: none; } h1 a:hover, h2 a:hover { color: #BFE1ED; background: inherit; } h3 { font: 90% Arial, Sans-Serif; margin: 0 0 10px 0; padding: 0; color: #5f5f5f; background: #FFF; } p { align:center; margin: 0 0 0px 0; line-height: 1.5em; } .main { margin: 0; overflow: hidden; } .main_header { background-color: #6E6D71; height: 75px; } .main_header_bottom { height: 20px; } #navigation { height: 75px; margin: 0; padding-left: 100px; box-shadow: inset 0 -20px 20px -20px #000; } #home_link { float: left; background-image: url(http://wwwdrumtranscriptions/new/home.png); background-repeat: no-repeat; height: 36px; margin-top: 20px; width: 40px; } .formTop { float: right; margin-top: 15px; margin-right: 75px; height: 45px; padding: 5px 8px 0px; } .login { border: 1px solid #333; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; box-shadow:inset 0 0 4px ##333; -webkit-box-shadow:inset 0 0 4px #333; -moz-box-shadow:inset 0 0 4px #333; color: #6E6D71; font-size: 12px; background-color: #CCC; padding: 8px; } #middle { background-color: blue; padding-top: 5px; height: 200px; /* test only */ margin-left: 110%; /* Start position: right outside */ -webkit-transition: margin-left 1s; -moz-transition: margin-left 1s; -o-transition: margin-left 1s; transition: margin-left 1s; } #middle.page1_inside { margin-left: 0; } #middle.page2_inside { margin-left: -100%; } #middle.page3_inside { margin-left: -200%; } #middle.page4_inside { margin-left: -300%; } #middle.page5_inside { margin-left: -400%; } #middle.page6_inside { margin-left: -500%; } #middle.transition { /* Effects only */ -webkit-transition: margin-left 1s; -moz-transition: margin-left 1s; -o-transition: margin-left 1s; transition: margin-left 1s; } .content { width: 100%; margin-right: 10px; } #page1_content { margin-left: 0; background-color: black; color: yellow; } #page2_content { margin-left: 100%; background-color: yellow; color: black; } #page3_content { margin-left: 200%; background-color: purple; color: red; } #page4_content { margin-left: 300%; background-color: green; color: orange; } #page5_content { margin-left: 400%; background-color: red; color: purple; } #page6_content { margin-left: 500%; background-color: purple; color: green; } .sub_footer { text-align: center; } .links { display: inline-block; padding: 0px 15px 0px 15px; } .footer { clear: both; text-align: center; color: #808080; background: #f0f0f0; padding: 10px 0 5px 0; border-top: 1px solid #eee; } .footer p { line-height: 2em; } .footer a { color: #4F4F4F; background: #f0f0f0; border-bottom: 1px dotted #808080; text-decoration: none; } </code></pre> <p>Here is my js</p> <pre><code>$(document).on("click", ".links", function () { $("#middle").removeClass(); /* Remove all classes */ $("#middle").addClass("transition " + this.id + "_inside"); /* add 'transition' for effects and eg. 'home_inside' classes */ }); </code></pre> <p>Here is my <a href="http://jsfiddle.net/RobbieP14383/hJbyq/12/" rel="nofollow">Fiddle</a></p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload