简体   繁体   中英

Sticky footer is not so sticky

I have a site with a sticky footer, which is not so sticky and I am having a hard time figuring it out.

This is the html part: html.tpl.php

<?php
?>
<!DOCTYPE html>
 <head>
  <?php $head; ?>
  <title><?php print $head_title='Vit | Kringvarp Føroya'; ?></title>
  <?php if ($default_mobile_metatags): ?>
  <?php endif; ?>
  <meta http-equiv="cleartype" content="on">

  <?php print $styles; ?>
  <?php print $scripts; ?>
  <?php if ($add_html5_shim and !$add_respond_js): ?>
  <?php elseif ($add_html5_shim and $add_respond_js): ?>
  <?php elseif ($add_respond_js): ?>
  <?php endif; ?>
</head>
  <body class="<?php print $classes; ?>" <?php print $attributes;?>>
    <div class="container">
    <?php if ($skip_link_text && $skip_link_anchor): ?>
     <p id="skip-link">
       <a href="#<?php print $skip_link_anchor; ?>" class="element-invisible  
       element-focusable"><?php print $skip_link_text; ?></a>
     </p>
    <?php endif; ?>
    <?php print $page; ?>
 </div>
  <?php print $page_footer; ?>
 </body>
  <?php print $page_bottom; ?>
 </div>
</html>

And page.tpl.php part

<div id="navigation">

   <?php print render($page['navigation']); ?>

</div>


<header class="header" id="header" role="banner">

  <?php $front_page='http://kvf.fo/vit';

     if ($logo): ?>
         <a href="<?php print $front_page; ?>" title="<?php print   
         t('Heim'); ?>"    
         rel="home" class="header__logo" id="logo"><img src="<?php print 
         $logo; ?  
          >" alt="<?php print t('Heim'); ?>" class="header__logo-image" />     
         </a>
      <?php endif; ?>

<?php if ($site_name || $site_slogan): ?>
<div class="header__name-and-slogan" id="name-and-slogan">
<?php if ($site_name): ?>
 <h1 class="header__site-name" id="site-name">
    <a href="<?php print $front_page; ?>" title="<?php print t('Heim'); 
    ?>" class="header__site-link" rel="home"><span><?php print 
    $site_name; ?></span></a>
 </h1>
<?php endif; ?>

<?php if ($site_slogan): ?>
  <div class="header__site-slogan" id="site-slogan"><?php print 
  $site_slogan; ?></div>
<?php endif; ?>
</div>
<?php endif; ?>


<?php print render($page['header']); ?>

</header>

<div id="main">

<?php print render($page['content']); ?>

</div>

<?php print render($page['footer']); ?>
<?php print render($page['bottom']); ?>

The css part.

html {
      position: relative;
      min-height: 100%;
     }

body {
      height: 100%;
     }

.container {
            margin: 0 0 125px;
           }

#footer {
         position: absolute;
         left: 0;
         bottom: 0;
         height: 100px;
         width: 100%;
         }

The page adress is www.kvf.fo/vit , and it seems to be working ok, but on an Ipad, the footer "sinks" halfway under the bottom of the screen, which is a bummer because the main users to the site, are Ipad users :/

Any help is much obliged!

If you want your footer to be sticky so add this property in its css

footer {
  position: fixed;
} 

It seems you're closing the body tag to early:

 </div>
  <?php print $page_footer; ?>
 </body>
  <?php print $page_bottom; ?>
 </div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM