How to move an element on the opposite side? html,css,js

I have the following code:

$(document).scroll(function() {
  var scroll = $(this).scrollTop();
  if (scroll >= 150) {
    $("#popUp").css("margin-left", "-425px");
    $("#plus").css("margin-left", "0px");
  }
});

$("#plus").click(function() {
  $("#popUp").css("margin-left", "0px");
  $("#plus").css("margin-left", "-425px");
});

$("#close").click(function() {
  $("#popUp").css("margin-left", "-425px");
  $("#plus").css("margin-left", "0px");
});
* {
  margin: 0;
  font-family: 'Source Sans Pro', sans-serif;
}

#darkBack {
  width: 100%;
  height: 100vh;
  background: rgba(76, 56, 75, .15);
}

#popUp {
  position: fixed;
  max-width: 350px;
  height: 225px;
  background: rgba(236, 240, 241, 1);
  border: 7px solid #fff;
  bottom: 0;
  margin-left: 0;
  -webkit-transition: all 1s ease;
  -moz-transition: all 1s ease;
  -o-transition: all 1s ease;
  transition: all 1s ease;
}

#new span {
  background: #fff;
  position: absolute;
  color: #1c8dc4;
  padding: 4px 10px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-top: -5px;
}

#popUp .close {
  color: #464646;
  right: 8px;
  top: 0px;
  position: absolute;
  font-size: 20px;
  cursor: pointer;
}

#popUp h2 {
  font-size: 17px;
  color: #464646;
  line-height: 24px;
  font-weight: 400;
  text-align: center;
  margin-top: 40px;
  padding: 0 20px;
}

#body {
  height: 1200px;
  background: #eee;
}

a.button {
  margin: 0 auto;
  text-align: center;
  right: 0;
  left: 0;
  position: absolute;
  width: 120px;
  font-size: 15px;
  color: #fff;
  border-bottom: 2px solid #18729f;
  background: #1c8dc4;
  border-radius: 4px;
  padding: 8px 0;
}

#plus {
  position: fixed;
  color: #fff;
  bottom: 15%;
  font-size: 15px;
  margin-left: -425px;
  -webkit-transition: all 1.25s ease;
  -moz-transition: all 1.25s ease;
  -o-transition: all 1.25s ease;
  transition: all 1.25s ease;
  cursor: pointer;
  text-align: left;
  letter-spacing: 1px;
}

#plus span {
  position: absolute;
  margin-top: 38px;
  left: 4px;
}

#plus::after {
  content: '';
  display: block;
  display: relative;
  border-top: 55px solid transparent;
  border-bottom: 55px solid transparent;
  border-left: 55px solid #1c8dc4;
}

@media all and (max-width: 900px) {
  #popUp {
    margin-left: -425px;
  }
  #plus {
    margin-left: 0px;
  }
}
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>

  <div id="popUp">
    <div id="close" class="close"><i class="fa fa-times"></i></div>
    <div id="new"><span>NEW!</span></div>
    <h2>I'm a notification popup that isn't too distracting or in your face. Scroll down or close me and I will go away. You'll still be able to open me later on don't worry.</h2>
    <br>
    <a href="#" target="_blank" class="button">Visit Page</a>
  </div>
  <div id="plus"><span>NEW<br>&nbsp;&nbsp;<i class="fa fa-plus"></i></span></div>

<div id="body"></div>

How would I move the enter image description here to the opposite side of the page? Instead of it appearing at the far left of the page, how would I make it appear at the far right? I have tried changing the margin-left in the js but I am not quite getting it right, as it does not output the expected output. Any suggestions?

62 thoughts on “How to move an element on the opposite side? html,css,js”

Leave a Comment