Note that there are some explanatory texts on larger screens.

plurals
  1. POtoggling css 'top' property position for chrome browser
    primarykey
    data
    text
    <p>I have a div(#aboutform) that is below the browser window and positioned originally as 'bottom'. Then when the #about div is clicked #aboutforms position is redefined to 'top' so that the div pops up from the bottom of the window.</p> <p>What I am trying to do is to toggle this popup animation but I can't seem to redefine #aboutforms position to 'bottom' so that it returns to its original position. </p> <p>I have tried removing the top property by using $(this).css('top', ''); but it will only work for a second before switching back to being defined by 'top.' </p> <p>CSS</p> <pre><code>#aboutform{ background-color: white; position: absolute; width: 100%; z-index: 4; text-align: center; margin: 0 auto; height: 1150px; bottom: -1150px; border-top:2px solid black; } </code></pre> <p>jQuery</p> <pre><code> $('#og').click(function() { $(this).data('clicked', true); }); $('#about').click(function() { var aboutFormTop = 85; if ($('#og').data('clicked')) { var $this = $("#aboutform"); $this.css("top", $this.position().top); $("#aboutform").animate({ 'top': aboutFormTop }, 1000) $("#og").animate({'bottom': '-=-65px'}, 100) } </code></pre> <p>2nd half which I am troubleshooting</p> <pre><code> //redefines #aboutform's position to 'top' for chrome browser var $this = $("#aboutform"); $this.css("top", $this.position().top); $("#aboutform").toggle(function() { $(this).animate({ 'top': aboutFormTop }, 1000); }, function() { //redefines #aboutform's position to 'bottom' //for chrome browser but only for a second //('top' position becomes dominant) var $this = $("#aboutform"); $this.css("bottom", $this.position().bottom); $(this).css('top', ''); $(this).animate({ 'bottom': -1150 }, 1000); }); }); </code></pre> <p>edited code and solution</p> <pre><code> $('#og').click(function() { $(this).data('clicked', true); }); $('#about').click(function() { var aboutFormTop = 85; if ($('#og').data('clicked')) { //$("#nav").animate({'bottom': '-=77px'}, 100); var $this = $("#aboutform"); $this.css("top", $this.position().top); $(this).animate({"top": 0}, 1000); $("#aboutform").animate({ 'top': aboutFormTop }, 1000) $("#og").animate({'bottom': '-=-65px'}, 100) } //redefines #aboutform's position to 'top' for chrome browser var $this = $("#aboutform"); $this.css("top", $this.position().top); $(this).animate({ 'top': 0 }, 1000); $("#aboutform").animate({ 'top': aboutFormTop }, 1000); $("#aboutform").css('bottom', 'auto'); $("#minleft").click(function(){ $("#aboutform").css('top', 'auto'); $("#aboutform").animate({ 'bottom': -1150 }, 1000); }); }); </code></pre>
    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