image in the background being shifted to the right on pages with a narrow width

My page footer is separated from the main content using a background image. This image appears correctly when viewed in a browser window that is wider than the specified min-width of the page. However, if the window is resized to be narrower, the image shifts to the right in relation to the main body.

Appearance in wide browser windows:

Appearance in narrow browser windows:

Is there a way to keep a 30 pixel margin on the left side of the main body content when viewed in a narrow browser window, instead of being pushed up against the window edge?

You can view the live page here if you need to refer to the CSS.

Answer №1

A good practice is to set a min-width for the <body>. I usually find that slightly above 1000 works well for your website, although the exact value may vary depending on the design elements. Aim for a width similar to that of the ribbon.

-update-

If you calculate the ribbon (1000px) plus the border (2 * 1px), you get 1002px in total, which should suffice.

Answer №2

The issue lies in the oversized dimensions of your #footerTop and #footer elements, causing them to react poorly when the window size is reduced. To resolve this, consider setting the background on the #footerContainer instead. By centering it within this element, you can ensure that it remains responsive as #footerContainer does not have a fixed width.

This adjustment will eliminate the unsightly horizontal scroll bar that appears when the browser window is resized to 999px wide. Ultimately, the extent to which you allow the window to shrink depends on your desired outcome.

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

Attempting to position the input field beside the label

I need help aligning the input field box next to my label. Currently, there is a gap between the text (label) and the input field when clicking on Item#1 and Invoice Number. I want the input field to be directly next to the label. Can anyone assist me with ...

The header and sub-navigation are in disarray and require some help

Dear web experts, After six months of learning to code websites, I'm tackling a big project with some challenges. The recent changes to the header and subnav have thrown everything off balance, making it look wonky and not quite right. Specifically, ...

Is it possible to eliminate the border of an HTML element when clicked, while still keeping the border intact when the element is in

I am currently developing a project with an emphasis on Web accessibility. Snippet of Code: function removeBorder(){ li=document.getElementById("link"); li.classList.add(".remove") } body{ background:#dddddd; } p:focus{ border:1px solid red; } li{ ...

Is your webpage displaying unnecessary white space on smaller screens?

https://i.sstatic.net/t7Hyj.png .main { background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); background-size: 400% 400%; animation: gradient 15s ease infinite; height: 100vh; min-width: 100%; width: 100%; overflow-x: hidde ...

How can I choose the first n children up to a certain class using CSS?

Take a look at this HTML : <div class="container"> <a id="1"></a> <a id="2"></a> <a id="3"></a> <a id="4"></a> <a id="5" class="specific"></a> <a id="6"></a ...

Code to achieve smooth scrolling from a hyperlink to a specific div element

<div style="border-radius: 10px; border: 2px solid #a1a1a1; padding: 10px 20px; width: 94%;"> <ul> <li>Listing of course details by country <ul> <li><a href="#bdpindia">India</a></li> <li><a href="#b ...

Adjust Element Width Based on Scroll Position

I'm attempting to achieve a similar effect as seen here: (if it doesn't work in Chrome, try using IE). This is the progress I've made so far: http://jsfiddle.net/yuvalsab/op9sg2L2/ HTML <div class="transition_wrapper"> <div ...

Using absolute positioning on elements can result in the page zooming out

While this answer may seem obvious, I have been unable to find any similar solutions online. The problem lies with my responsive navbar, which functions perfectly on larger screens. However, on mobile devices, the entire website appears zoomed out like thi ...

Preventing Partial Overlap of Two Divs in HTML5

I found a template that caught my eye here: w3schools template My latest project involves using this template to create a basic online shop layout with three main vertical sections: left, middle, and right. The left panel serves as a preview area ...

Switch back to the original CSS when a different button is clicked by the user

I am facing an issue with my jQuery UI accordion where the arrow icons are not behaving as expected. Each header element has a right arrow that changes to a down arrow when clicked to display content, and reverts back to its original form when clicked agai ...

Having difficulty with utilizing the validate() function in jQuery

My HTML code looks like this: <form class="form-filter" id="form-filter-excel" role="form"> <div class="row"> <div class="col-md-4 col-sm-5"> <label>Date range</label> ...

Executing a function when a dropdown in Bootstrap is expanded and closed

How can I use JavaScript to execute a function when clicking on a notification button in a Bootstrap navbar to expand the dropdown, and then close the dropdown when clicking it again? I have tried selecting the dropdown and modifying the click function, b ...

Replace the default MailChimp stylesheet with a different stylesheet

Objective: I want to modify the background color of the "Subscribe" button on a MailChimp embedded sign-up form found on our company's website page. Query: MailChimp provides the CSS hook "input.button" for styling the Subscribe button. How can I uti ...

Revealing a concealed element by sliding it upwards on a single page, then repeating the

Can someone assist me in achieving a specific effect on my website? I have a top banner section with a button at the bottom. When the button is clicked, a form should slide up into view. The form will initially be hidden. I also need the same effect at the ...

Header stabilization on scroll

On my webpage, I have a table header positioned in the middle of the page. However, due to the length of the page, I am looking for a way to make the header stay fixed at the top of the browser as the user scrolls down. My query is: Is there a method to k ...

Utilizing Angular's JSON model to style CSS elements

Recently, I came across some generated code within the application that looks like this: "PHcolour":"rgb(4, 31, 156)","Ctextcolour":"rgb(59, 214, 252)" I have successfully retrieved the data from the model using curly brackets {{CtextColour}}, My goal i ...

Tips for ensuring v-tabs-items and v-tab-item fill height

I found an example that I am trying to follow at the following link: https://vuetifyjs.com/en/components/tabs#content <v-tabs-items v-model="model"> <v-tab-item v-for="i in 3" :key="i" :value="`tab-${i}`" > < ...

Having trouble with applying the height property using Jquery .css to a div element?

I'm currently working on a website project and I'm still new to using jquery. I encountered an issue where the .css() function does not seem to change the height of a specific div, although it works fine for another div on the same page. You can ...

Using Jquery fadeIn along with responsive CSS media queries

Issue at Hand: An issue arises with my navigation bar and text block animations. The fading effect applied on the text element causes inline styles to be added, thus disrupting the media query set to hide the text on smaller screens. If you disable the s ...

Tips for concealing all items except the currently selected branch when clicking on a menu drop-down

I am seeking a solution to open only one node at a time on click, and remove the 'is-active' class from other items. Currently, there is excessive space taken up after opening multiple menu items. I want to ensure that only one node is open at a ...