Hide Footer On Mobile & Tablet

6.2k views Asked by At

I am wanting to hide my footer on mobile and tablet devices. I have looked all over google for some help but haven't found anything. The HTML code for my footer is,

<!-- Footer -->
    <footer class="footer" role="contentinfo">
        <div class="container<?php echo ($params->get('fluidContainer') ? '-fluid' : ''); ?>">
            <jdoc:include type="modules" name="footer" style="none" />
          <div class="footer">
&copy; <?php echo date('Y'); ?> <?php echo $sitename; ?>
            </div>

CSS code for my footer is,

.footer {
  background-color: #F6861F;
  color: #fff;
  padding: 20px 0;
  margin-bottom: 0
  text-align: center;
  overflow: hidden;
  width: 100%;
}
6

There are 6 answers

0
Alex On

After the mobile first strategy you should first hide the footer and then display it for desktops only.

.footer {
  display: none;
}

@media (min-width: 992px) {
  .footer {
    display: block;
    background-color: #F6861F;
    color: #fff;
    padding: 20px 0;
    margin-bottom: 0
    text-align: center;
    overflow: hidden;
    width: 100%;
  }
}
2
Mike Furlender On

Something like this should work:

@media screen and (max-width: 600px) {
  .footer{
    visibility: hidden;
    display: none;
  }
}
0
pregunta On

Check this jsfiddle http://jsfiddle.net/ks1q8nkt/

@media screen and (max-width: 600px) {
  .footer{
    display: none;
  }
}

The code means that every class, id and element which is defined in the block will respond for all devices which have a max width of 600 pixels.

0
sonam gupta On

You have to write @media for that in css for your mobile width.

@media screen and (max-width: 360px) {
 .footer{
     visibility: hidden;
     display: none;
 }
}

For small mobile and you can change the width according to yours.

0
Rodney On

Use the CSS from other people. Alternately if you are using the Bootstrap framework (baked into most Joomla templates) just add the appropriate column visibility classes:

<!-- Footer -->
<footer class="footer" role="contentinfo">
    <div class="hidden-xs hidden-sm container<?php echo ($params->get('fluidContainer') ? '-fluid' : ''); ?>">
        <jdoc:include type="modules" name="footer" style="none" />
        <div class="footer">
            &copy; <?php echo date('Y'); ?> <?php echo $sitename; ?>
        </div>
    </div>
</footer>

I added hidden-xs and hidden-sm to the div class list in front of the container. See here: Bootstrap Responsive Utilities

NOTE: those two classes are for the most recent version of Bootstrap. For version 2.3.2 you need to read here: Bootstrap v2.3.2 Responsive Utilities

0
TechsBucket On

You should try this CSS code.

@media only screen and (max-width: 767px) {
  .footer {
    display: none;
  }
}