Challenges with displaying full-page images

After implementing the code to create a full-screen background image on my site, I noticed that the image is being shrunk up slightly. It seems to be cutting off about an inch from each side, which is not what I intended.

The code I used is directly from CSS tricks:

html {
background: url(images/bg.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

Below is the complete CSS code I am using:


* {margin: 0; padding: 0;}

/* Header Image Background - Change the URL below to your image path (example: ../images/background.jpg) */
html {
background: url('/images/bg.jpg') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
-o-background-size: cover;
}

#thanks {
position: absolute;
width: 300px;
height: 75px;
z-index: 15;
top: 98%;
left: 50%;
margin: -100px 0 0 -150px;
text-decoration: none;
text-align: center;
font-size: 36px;
background-color: #3a1e49;
color: #edcd05 !important;
font-family: "Times New Roman", Times, serif;
border-radius: 25px;
}

#thanks:hover {
background-color: #edcd05;
color: #3a1e49;
}

#thanks a {
color: #edcd05;
text-decoration: none;
position: relative;
bottom: 10%;
}

#thanks a:hover {
color: #3a1e49;
}

Here is the HTML content:

<!DOCTYPE html>
<html class="full" lang="en">

<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Demo</title>
<link href="css/full.css" rel="stylesheet">
</head>
<body>
<!-- 
    <div id="thanks">
        <p><a href="thanks.php">Share a Memory</a></p>
    </div>

-->     
<script src="js/jquery.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

Answer №1

By setting your image to cover, it will extend beyond the boundaries of the screen.

Ensure that your image is at least the same size as your screen resolution. For example: if your screen resolution is 1366 * 768, then make sure your image's width is at least 1366 and its height is 768.

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

CSS for Responsive Web Development: Adjusting the Height of Mobile Sliders

I've been working on adjusting the height of the slider on my website for mobile screens, but I can't seem to get it right. The website in question is www.msstoreway.com. Despite adding the CSS code below, I was able to adjust the slider height ...

Having difficulty controlling the DOM within an AngularJS template

My website utilizes AngularJS templates, specifically a Single Page Application (SPA). Within one of the templates, I am utilizing a tab control from the AngularUI library named Ui-Tabset. During the rendering process, this control generates a ul element ...

Alter the background color of the navigation link in Jquery when the mouse hovers over

I am looking to modify the background color when I hover over various links in my navigation menu. For example, when hovering over link one, the background should turn red; for link two, blue; and for link three, green. However, I also want the backgroun ...

Is there a way to customize the header bar in photonkit?

I am currently using photonkit.com to develop an application and I have encountered the following issue: https://i.sstatic.net/0GFJK.png As shown in the image, the header bar appears unattractive. I have searched extensively online for examples (without ...

"Discover the power of Jade template engine: A guide to effortlessly setting a stunning background image

Is there a way to add a background-image to my HTML page when using Jade? I would really appreciate any guidance on how to do this. Thank you in advance! ...

Adjust the margin at the top and bottom of a printed HTML document

I am trying to achieve a 75px margin on the top and bottom of each printed page. So far, I have attempted adding the margin to both the body and a wrapper div, but it seems that these methods only apply the margin to the entire document. This results in a ...

Setting !important to every property's value at once

One interesting approach I am using is applying !important to all of the css properties' values like this: .someclass{ color: #f00 !important; background-color: #ff0 !important; margin: 0 !important; padding: 0 !important; width: 100% ! ...

Mastering Kendo UI in Vue: The Ultimate Guide to Managing Child Checkboxes in TreeView

I am currently utilizing Telerik's Vue wrappers for Kendo UI. With the TreeView control, both the jQuery version and MVC wrappers have a feature that allows a property to automatically check child checkboxes when the parent checkbox is checked. ...

Tips for customizing the focus style of a Text Field in Material-UI

My current Search box design is represented in the following image: https://i.sstatic.net/VuKIp.png I am looking for ways to customize the background color, border, and icon of the search box when it is focused. Additionally, I would like to know how to m ...

Dealing with the dilemma of Two AjaxButtons enclosed in individual forms in Wicket

I am trying to incorporate two separate file upload sections on a single page - one for images and another for other types of files. Each section includes a form with an AjaxButton. Initially, I successfully set up the first section, which functioned as in ...

Adjust the source of the HTML5 video tag based on the orientation of an iPad

I am currently coding an HTML5 page specifically for iPad Mobile Safari, which includes a video tag for embedding video files. I have successfully implemented CSS3 media queries to determine the orientation of the iPad. My next challenge is to dynamically ...

What is the method for obtaining the image alt attribute using JavaScript?

I can't seem to retrieve the image alt tag using JavaScript. Is it even possible and if so, how should I go about it? Perhaps something like this: $caption.text( flkty.selectedElement ).attr('alt') (last line of JavaScript) But I'm st ...

Empty the localStorage when terminating the IE process using the Task Manager

Utilizing HTML5 localStorage to keep track of my application session has been a useful feature. Here is a snippet of the code I am currently using: if(typeof(Storage)!=="undefined") { if(sessionStorage.lastname=="Smith") { alert("Your ses ...

The hover effect on <a href element will only activate after clicking or refreshing the page

Having an issue with my website where I'm using HTML and CSS exclusively. The problem arises when I have multiple "a hrefs" that should change their background colors slightly when hovered over. However, whenever I clear the browser cache or go into i ...

Leverage JSON data in JavaScript

Having some trouble figuring out how to incorporate JSON values into my JS script. Any assistance would be greatly appreciated as I am still new to this! Below is the snippet of code where I need the values (lat and lon) to be inserted: var map; functio ...

The functionality of a dynamically created input form remains unchanged when applied to a jquery function

I am encountering an issue with a dynamically growing input form. Below is my HTML code: <div id="div_pos"> <p> <input type=text name="pos_count1" style="width:30px"> <input type=text name="pos_na ...

Combining the navigation bar and carousel in Bootstrap 4

Is it feasible to combine the carousel and navbar in a similar manner as demonstrated here: . I attempted to place the carousel within the nav element, but it didn't appear to work as expected. Here is the HTML code I used: <div class="navb ...

Close the space between the final div and the bottom of the page on Firefox, Opera, and Safari

When designing a web page, I encountered an issue with the layout. I have a large white div followed by a red div. If the white block's height is equal to or greater than the browser window, causing scroll bars to appear, there is a gap between the re ...

The dimensions of my grid object are constantly being altered by my interactive button

Recently, I started delving into vuejs and vuetify to work on a project management app for school. I encountered a simple problem where adding a button distorted the project bar. I tried nesting the button component within the project bar to rectify this i ...

Find the number of nested ng-repeats within the outermost ng-repeat and adjust it automatically based on the value of ng-model

Having three nested ng-repeat to showcase the drives, their respective folders, and files. An example data set is illustrated below Drives=[ { name:'C Drive', folders:[ { name:'personal', ...