-1

Here, I would like to fix my footer at the below of the page. I cannot seem to do it for this page whereas the css codes for footer works well on the other pages. Again, I would like to place the footer fixed at the below of the page.

Need help on this.

(function() {
  function onSubmitClicked(event) {

    var product = document.getElementById('product'),
      productVal = product.value,
      profile = document.getElementById('profile'),
      profileVal = profile.value;
    url = 'testPoint.html?product=' + encodeURIComponent(productVal) + '&profile=' + encodeURIComponent(profileVal);
    location.href = url;
  }

  var submitButton = document.getElementById('btngo');
  submitButton.addEventListener('click', onSubmitClicked);
})();
body {
  background-color: #d62929;
  margin: 0;
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: whitesmoke;
  font-weight: bold;
  font-size: 18px;
}

li {
  float: left;
}

li a,
.dropbtn {
  display: inline-block;
  color: black;
  text-align: center;
  padding: 22px 30px;
  text-decoration: none;
}

li a:hover,
.dropdown:hover .dropbtn {
  background-color: #c12525;
  color: white;
}

li.dropdown {
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: whitesmoke;
  min-width: 250px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.dropdown-content a {
  color: black;
  padding: 20px 20px;
  text-decoration: none;
  display: block;
  text-align: left;
  font-size: 15px;
}

.dropdown-content a:hover {
  background-color: #c12525;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.active {
  background-color: #d62929;
  color: white;
  font-weight: bold;
  font-size: 18px;
}

@media screen and (max-width: 600px) {
  ul li,
  ul li {
    float: none;
  }
}

@media screen and (max-width: 300px) {
  footer {
    -webkit-order: 3;
    order: 3;
  }
}

h1 {
  font-size: 40px;
  font-weight: bold;
}

h2 {
  font-size: 20px;
  font-weight: bold;
}

p2 {
  font-size: 15px;
  font-weight: bold;
}

tr,
td {
  padding: 15px;
  text-align: left;
}

table {
  margin: auto;
  border-collapse: collapse;
  width: 30%;
  table-layout: fixed;
  text-align: center;
}

tr {
  height: 200px;
  vertical-align: middle;
  text-align: left;
}

.button {
  background-color: #4CAF50;
  border: none;
  color: white;
  padding: 16px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  transition-duration: 0.4s;
  cursor: pointer;
}

.button2 {
  background-color: white;
  color: black;
  border: 2px solid black;
  width: 8%;
}

.button2:hover {
  background-color: black;
  color: white;
}

.button3 {
  background-color: white;
  color: black;
  border: 2px solid black;
  width: 8%;
}

.button3:hover {
  background-color: black;
  color: white;
}

.rfloat {
  margin: 5px;
  text-align: center;
}

.clear {
  clear: both
}

footer {
  background: #aaa;
  color: #fff;
  text-align: center;
  padding: 1rem;
  clear: both;
  /* clearing floating affects from both left,right sides */
}

.footp {
  margin: 0;
  padding: 0;
  margin-left: 20px;
  display: inline-block;
  line-height: 30px;
  vertical-align: top;
}
<ul>
  <li><a href="home.html">Home</a></li>
  <li class="dropdown">
    <a class="active dropbtn" href="javascript:void(0)">Capacity Study</a>
    <div class="dropdown-content">
      <a href="mainFrame.html">Conduct Study</a>
      <a href="report.html">Reports</a>
    </div>
  </li>
  <li><a href="contact.html">Contact</a></li>
</ul>
<div class="txt">
  <table>
    <tr>
      <td>
        <p2>Choose a Product : </p2>

        <select id="product"> 
 
 <!--Setting the 'NONE' value for the drop down menu list option when user do not want to choose any value. optgroup is used for the subtitles off the main product dept.-->
 <optgroup label="DEFAULT">
 <option value = "NONE">NONE</option>
 </optgroup>
 
 <!--Product List for PCR Legacy-->
 <br><br>
 <!--End of first drop down list-->
 </select>
        <br><br>

        <p2>Choose a Profile : </p2>
        <select id="profile"> 
 
 <optgroup label="DEFAULT">
 <option value = "NONE">NONE</option>
 </optgroup>
 </select>
      </td>
    </tr>
  </table>
  <br><br><br>

  <div class="rfloat">
    <input type="button" value="Back" onclick="goBack()" class="button button3" />
    <input type="submit" id="btngo" value="Go" class="button button2" />
  </div>

  <div class="clear"></div>
  <br><br><br>
</div>

<div>
  <footer>
    <p class="footp">&copy;All rights reserved.</p>
    <p class="footp">|</p>
    <p class="footp">Internal Use Only</p>
    <p class="footp">|</p>
    <p class="footp">Maintained By</p>
  </footer>
</div>
Rob
  • 14,746
  • 28
  • 47
  • 65
cerberus99
  • 159
  • 1
  • 2
  • 11
  • So would you like to fix your footer on the bottom of your page? if so just add css position: fixed; bottom: 0; – zhuravlyov Oct 05 '17 at 03:34
  • Thank you for the feedback. No, I do not want it to be fixed - where when I scroll down the page, the footer can be seen. I do not want the footer to be seen when user scrolls up and down the page, I just want the footer to be placed below the page. – cerberus99 Oct 05 '17 at 03:40
  • @cerberus99 check this out I have updated the answer as well https://jsfiddle.net/2h6j11kL/ – Aamir Shahzad Oct 05 '17 at 03:47

2 Answers2

1

See the snippet below. This will force the footer to be on the bottom of the page only if the content isn't high enough.

See the answer of Staale @ How do you get the footer to stay at the bottom of a Web page?

(function() {
  function onSubmitClicked(event) {

    var product = document.getElementById('product'),
      productVal = product.value,
      profile = document.getElementById('profile'),
      profileVal = profile.value;
    url = 'testPoint.html?product=' + encodeURIComponent(productVal) + '&profile=' + encodeURIComponent(profileVal);
    location.href = url;
  }

  var submitButton = document.getElementById('btngo');
  submitButton.addEventListener('click', onSubmitClicked);
})();
/* --- This below --- */ 
* {
  margin: 0;
}

html,
body {
  height: 100%;
}

.wrapper {
  min-height: 100%;
  height: auto !important;
  height: 100%;
  margin: 0 auto -62px;
  /* the bottom margin is the negative value of the footer's height */
}

.push {
  height: 62px;
  /* .push must be the same height as .footer */
}

/* --- This ahead --- */

body {
  background-color: #d62929;
  margin: 0;
}

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: whitesmoke;
  font-weight: bold;
  font-size: 18px;
}

li {
  float: left;
}

li a,
.dropbtn {
  display: inline-block;
  color: black;
  text-align: center;
  padding: 22px 30px;
  text-decoration: none;
}

li a:hover,
.dropdown:hover .dropbtn {
  background-color: #c12525;
  color: white;
}

li.dropdown {
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: whitesmoke;
  min-width: 250px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.dropdown-content a {
  color: black;
  padding: 20px 20px;
  text-decoration: none;
  display: block;
  text-align: left;
  font-size: 15px;
}

.dropdown-content a:hover {
  background-color: #c12525;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.active {
  background-color: #d62929;
  color: white;
  font-weight: bold;
  font-size: 18px;
}

@media screen and (max-width: 600px) {
  ul li,
  ul li {
    float: none;
  }
}

@media screen and (max-width: 300px) {
  footer {
    -webkit-order: 3;
    order: 3;
  }
}

h1 {
  font-size: 40px;
  font-weight: bold;
}

h2 {
  font-size: 20px;
  font-weight: bold;
}

p2 {
  font-size: 15px;
  font-weight: bold;
}

tr,
td {
  padding: 15px;
  text-align: left;
}

table {
  margin: auto;
  border-collapse: collapse;
  width: 30%;
  table-layout: fixed;
  text-align: center;
}

tr {
  height: 200px;
  vertical-align: middle;
  text-align: left;
}

.button {
  background-color: #4CAF50;
  border: none;
  color: white;
  padding: 16px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  margin: 4px 2px;
  transition-duration: 0.4s;
  cursor: pointer;
}

.button2 {
  background-color: white;
  color: black;
  border: 2px solid black;
  width: 8%;
}

.button2:hover {
  background-color: black;
  color: white;
}

.button3 {
  background-color: white;
  color: black;
  border: 2px solid black;
  width: 8%;
}

.button3:hover {
  background-color: black;
  color: white;
}

.rfloat {
  margin: 5px;
  text-align: center;
}

.clear {
  clear: both
}

footer {
  background: #aaa;
  color: #fff;
  text-align: center;
  padding: 1rem;
  clear: both;
  /* clearing floating affects from both left,right sides */
}

.footp {
  margin: 0;
  padding: 0;
  margin-left: 20px;
  display: inline-block;
  line-height: 30px;
  vertical-align: top;
}
<div class="wrapper"> <!-- START: Wrap everything in this div -->
  <ul>
    <li><a href="home.html">Home</a></li>
    <li class="dropdown">
      <a class="active dropbtn" href="javascript:void(0)">Capacity Study</a>
      <div class="dropdown-content">
        <a href="mainFrame.html">Conduct Study</a>
        <a href="report.html">Reports</a>
      </div>
    </li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
  <div class="txt">
    <table>
      <tr>
        <td>
          <p2>Choose a Product : </p2>

          <select id="product"> 
 
 <!--Setting the 'NONE' value for the drop down menu list option when user do not want to choose any value. optgroup is used for the subtitles off the main product dept.-->
 <optgroup label="DEFAULT">
 <option value = "NONE">NONE</option>
 </optgroup>
 
 <!--Product List for PCR Legacy-->
 <br><br>
 <!--End of first drop down list-->
 </select>
          <br><br>

          <p2>Choose a Profile : </p2>
          <select id="profile"> 
 
 <optgroup label="DEFAULT">
 <option value = "NONE">NONE</option>
 </optgroup>
 </select>
        </td>
      </tr>
    </table>
    <br><br><br>

    <div class="rfloat">
      <input type="button" value="Back" onclick="goBack()" class="button button3" />
      <input type="submit" id="btngo" value="Go" class="button button2" />
    </div>

    <div class="clear"></div>
    <br><br><br>
  </div>
  <div class="push"></div> <!-- START & END: Push div -->
</div> <!-- END: Wrap everything in this div -->
<div class="footer"> <!-- START: Footer WITH class -->
  <footer>
    <p class="footp">&copy;All rights reserved.</p>
    <p class="footp">|</p>
    <p class="footp">Internal Use Only</p>
    <p class="footp">|</p>
    <p class="footp">Maintained By</p>
  </footer>
</div> <!-- END: Footer WITH class -->
Patrick Mlr
  • 2,955
  • 2
  • 16
  • 25
  • Thank you for the feedback. I tried on my codes and ran the codes as well. It does not seem to work :( – cerberus99 Oct 05 '17 at 06:55
  • Did you wrap your content with `wrapper` which has the `push div` inside and after the `wrapper div` there's the `footer`? I've added some comments to the code. May this help you. – Patrick Mlr Oct 05 '17 at 10:47
  • This method is perfect. So sorry, I guess I missed some lines of codes yesterday. Got it done again today and it works PERFECTLY ! Thanks a bunch, mate :) – cerberus99 Oct 06 '17 at 01:34
-1

Please use following css to make footer stick at bottom:

    footer { 
/*it will allow to scroll page while staying at top incase page is long*/
    position: fixed;
    bottom: 0;
    width: 100%;
    } 

JSFIDDLE

Additionally if you don't want this behavior you do this to make footer stick at bottom always.

footer { 
        position: absolute;
        bottom: 0;
        width: 100%;
        } 
Aamir Shahzad
  • 6,683
  • 8
  • 47
  • 70
  • check the answer under the question mate – zhuravlyov Oct 05 '17 at 03:39
  • It appeared late for me however I provided two methods not just fixed – Aamir Shahzad Oct 05 '17 at 03:41
  • @AamirShahzad Hi Amir. Thank you for the feedback. I encountered that it doesn't seem to work when I add more feature and tend to scroll down the page. When I scroll down, the footer seem to move as well. Fyi, i took the second method of yours,. – cerberus99 Oct 05 '17 at 03:47
  • @cerberus99 I thin k what I perceived from your description your want to remove red background under footer so that footer appears at the end. If so please apply background color to `.txt` instead of `body`. – Aamir Shahzad Oct 05 '17 at 03:55
  • @AamirShahzad Hi. Nope that was not what I meant. What I mean was, when i try your second method in the page where I can scroll up and down, the footer does not seem to stay at the bottom of the page, instead, it overlaps the content when I scroll down or up the page. – cerberus99 Oct 05 '17 at 04:01