``There seems to be an issue with the functionality of the background-position attribute

I've been following a tutorial on web design from tutsplus. I have completed everything except for one issue with the HTML styling. You can see I have included height:100%, but in the original tutorial, that line was not there. If I remove it, the layout collapses. However, in the original tutorial, it looks perfect. Can anyone explain why?

Currently, with height:100% set, you can scroll to the bottom and notice there is some margin left at the bottom. I want the image to stick right at the bottom of the page.

Please download the images as well so you can try this code. Here are the links:

CodePen = http://codepen.io/joe/full/xruKk

jsFiddle = http://jsfiddle.net/rssatnam/YekQe/embedded/result/

Here is the code :

<html>
<head>
<style type="text/css">
html{
  background:#77d5fb url('bottom_bg.jpg') bottom center no-repeat;
  height:100%;
}
body{
  background:transparent url('top_bg.png') top center no-repeat;
  height:100%;
  width:100%;
  margin:0 0;
}
#container{
  width:900px;
  margin:0 auto;
}
#navBar{
  height:62px;
  background-color:#e5592e;
  margin:3em 0;
  position:relative;
  -webkit-box-shadow:0px 0px 4px rgba(0,0,0,0.55);
  box-shadow:0px 0px 4px rgba(0,0,0,0.55);
  -moz-box-shadow:0px 0px 4px rgba(0,0,0,0.55);
  -o-box-shadow:0px 0px 4px rgba(0,0,0,0.55);
  border-radius:3px;
  z-index:500;
}
#menu li{
  list-style-type:none;
  display:block;
  float:left;
  margin:1em 0.8em;
}
#menu li a{
  display:block;
  text-decoration:none;
  color:#F0F0F0;
  font-size:1.6em;
  margin:0;
  line-height:28px;
  text-shadow:0 2px 1px rgba(0, 0,0, 0.5);
}

#menu li a:hover{
  /*transition:margin-top 0.3s;
  -webkit-transition:margin-top 0.3s;*/
  margin-top:2px;
}
#lt-corner {
  width:0px;
  height:0px;
  border:50px solid;
  border-color:#d9542b transparent transparent;
  position:relative;
  float:left;
  top:1px;
  left:-50px;
}
#lb-corner{ 
  border:50px solid; 
  border-color:transparent transparent #d9542b; 
  width:0px; 
  height:0px; 
  position:relative; 
  float:left; 
  top:-40px; 
  left:-150px; 
}
#rt-corner { 
  width:0px; 
  height:0px; 
  border:50px solid; 
  border-color:#d9542b transparent transparent; 
  position:relative; 
  float:right; 
  top:-107px; 
  right:-45px; 
}
#rb-corner {
  border:50px solid;
  border-color:transparent transparent #d9542b;
  width:0px;
  height:0px;
  position:relative;
  float:right;
  top:-149px;
  right:-145px;
}
</style>
</head>

<body>
    <div id="container">
      <div id="lt-corner"></div>
      <div id="lb-corner"></div>
        <div id="navBar">
            <ul id="menu">
                <li><a href="#">&#10029; Home</a></li>
                <li><a href="#">&#10029; About</a></li>
                <li><a href="#">&#10029; Services</a></li>
                <li><a href="#">&#10029; Contact</a></li>
            </ul>
        </div>
        <div id="rt-corner"></div>
      <div id="rb-corner"></div>
    </div>    
</body>
</html>

Answer №1

Check out this live demonstration: JS Playground. Feel free to tweak and experiment with it.

To reset the default styles, add margin:0 and padding:0 to both the html and body elements. To eliminate extra space at the bottom, simply delete the height:100% property from the body element. Here is a basic CSS template:

html,body{ 
  margin:0;
  padding:0;
}

html{
  background:#8eb2f1 url('http://i.imgur.com/qkfeP.jpg') bottom center no-repeat; 
  height:100%;
  width:100%;
}

body{
  background:transparent url('http://i.imgur.com/9wSUr.png') top center no-repeat; 
  width:100%;
} 

Note: Remember to mark this as the solution if it resolves your issue.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting Problems with display:table and display:table-cell Alignment in Internet Explorer Versions 7 and 9

I have been struggling with the layout of a website that contains multiple columns. After extensive work, I believed I had everything properly aligned. Adobe BrowserLab seemed to confirm this, aside from various issues in IE6 and IE7 which I decided to ove ...

Utilizing React's Conditional Rendering Alongside Bootstrap to Maintain the Layout Intact

I'm currently developing a project using React and Bootstrap that involves incorporating a large bar graph with two smaller boxes, all positioned horizontally together. To visualize how it should appear, please expand the pen window to see them arran ...

Menu with customized hover feature, revealing submenu upon mouse movement

I have implemented my own hover event handler to display a triangle pointer and a horizontally aligned submenu bar. It works well for showing and navigating to the submenu when the top menu item is clicked. However, I am facing an issue where the submenu b ...

Is it possible to achieve wordpress + nginx + https for just a single page?

I am facing a challenge with my WordPress site, which is hosted on Nginx running on Windows Server 2012 R2. I want to enable HTTPS on specific pages like /cart/, /my-account/, and /checkout/, but all the resources are still being loaded over HTTP, resultin ...

Ever thought about harnessing the power of SassDoc to create detailed documentation for your sass

After experimenting with sassdoc for documenting our sass mixins and functions, I realized that there doesn't seem to be a straightforward way to generate documentation for our sass variables. Specifically, I am looking for a solution that can output ...

Issues with playing Html 5 video arise when making an ajax call

My goal is to implement an AJAX call followed by displaying an HTML5 video. The provided code snippet seems to be ineffective. $.ajax({ type: "POST", url: "Videos.aspx/GetBlocs", contentType: "application/json; charse ...

Looking to bookmark Java links or a similar task?

Apologies for the lackluster title, as I am not well-versed in programming language and struggle to articulate my specific request... Allow me to explain: I frequently need to visit a particular website to conduct research (details below). I attempted usi ...

Loading content with AJAX without having to refresh the page

I've been working on implementing a way to load content onto a page without needing to refresh it. While I was able to achieve this, I encountered a problem where the images and CSS files weren't loading properly. Below is the code I used: < ...

The Laravel href link will fail to work when the URL does not include the string 'http'

I am encountering an issue with a particular hyperlink tag <a href="{{ $organization->website }}">Link</a> When the URL in $organization->website does not start with http:// or https://, the link fails to direct me properly. Instead, i ...

How to avoid shadow bleed when using positioned absolute elements?

I'm facing a challenge in developing a dropdown feature. The issue arises when I attempt to display an absolutely positioned container of items upon hovering, as the shadow from this container overlaps with the dropdown itself. Here's a simulatio ...

Select the five previous siblings in reverse order using jQuery's slice method

I have a unique approach to displaying a series of divs where only 5 are shown at a time using the slice() method. To navigate through the items, I include an ellipsis (...) link after every 4th item, which allows users to easily move on to the next set of ...

Complete guide on modifying CSS with Selenium (Includes downloadable Source Code)

I am looking to switch the css styling of a website using Python and Selenium. My initial step was to retrieve the current CSS value. Now, I aim to alter this css value. The Python code output is as follows: 0px 0px 0px 270px How can I change it from 0 ...

Retrieve the href value from a DOM element

I'm currently working on a piece of code that aims to extract only the hrefs from the nav section. Here's what I have so far: componentDidMount(){ $("nav ul li a").each(function(k, j){ console.log(j); }); } So far, I've bee ...

Retrieve the information enclosed by comments using an HTML DOM parser

Looking to extract the plain text content between two comments, but struggling to find a solution without relying on specific HTML tags in the structure. Parse between comments in Simple HTML Dom Wondering if it's achievable with HTML Dom Parser? ...

Build a home page in HTML with full width design

My webpage currently allows scrolling to the right and left in HTML. I would like to change this functionality. What I envision is having my cup and book visible without the need for scrolling, with a background image centered on the page. <div cla ...

Why does my dialog box only open the first time and not the second time?

I have created my own custom dialog box using jQuery and it seems to be working fine initially. However, after closing it once, when I try to open it again nothing appears. Can anyone help me identify what's causing this issue? Below is the source co ...

A comprehensive guide on associating a JavaScript function with an element attribute

I am looking for a way to assign a JavaScript function to an HTML attribute. For example: <li data-ng-repeat="job in jobList" class= dynamicClass(str) data-filter = "dynamicFilter(str)"> The reason I want to do this is because the class name and ...

Table list collapse

I have a list of processes where each row contains a link labeled "Collapse". When this link is clicked, I want it to open a container area where I can add additional content. Here is what I have tried so far: https://i.sstatic.net/mcq2u.png However, th ...

Difficulties when running Python scripts containing HTML on localhost or through the command line

I am encountering an issue with my python file that contains some HTML code. The file is intended to display "Hallo" when executed in the command line, and to show formatted HTML when opened in a browser. However, it only prints out the raw HTML code in ...

Creating a JSON array using looping technique

I am attempting to construct a JSON array using a loop where the input className and value will serve as the JSON obj and key. However, I am facing difficulties in creating one and cannot seem to locate any resources on how to do so. Below is an example sn ...