Adjustable background image height based on screen size

Situation :

  • There is an existing Wordpress site with an old theme that does not allow changing the header image.
  • To work around this limitation and display a different image on a specific page, I have hidden the header image using CSS and replaced it with a responsive background image.

Task :

  • However, I had to define a height for the area to accommodate the background image at full size by using "padding-top". This setup results in a large space beneath the background image when the window is resized or viewed on mobile devices.
  • Is there a way to make the space below the image shrink as the image shrinks?

URL:

Custom CSS Used:

.singular-page-691 #header img {
    display:none;
}
.singular-page-691 #branding {
padding-top:390px;
  background-image:url(http://www.annareynolds.org/wp-content/uploads/2018/08/love-hobart-crop.jpg);  
  background-repeat: no-repeat;
  background-size: 100%;
background-position:top left;
}

Answer №1

Ensure to utilize percentage-based padding

For example:

.singular-page-691 #branding {
padding-top: 40%;}

Explore the example here

Answer №2

After examining the link you shared and reviewing the responsiveness, I believe I have made the necessary adjustments as per your query.

It appears that the issue causing the extra space is due to the paddding-top:390px in .singular-page-691 #branding. To resolve this, you can modify the value of padding-top for better responsiveness. I tested with padding-top:180px and it seems to work well for me.

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

Bootstrap 3 design with a full screen layout featuring three columns

I'm currently working on developing an administration dashboard for an application, and I require a layout that resembles the following: --------------------------------------------------------------------------------- | ...

Button-operated lightbox image slider

I am currently developing a website on WAMP where users can store images and view them in a lightbox effect. I have successfully implemented the lightbox effect, but I am facing challenges with moving between images within the lightbox. <html> <? ...

Issues with jQuery scroll effect not functioning properly in Firefox due to transformation errors

I've encountered an issue with implementing a scroll effect in Firefox. The code works perfectly fine in Chrome, Safari, and Opera, but for some reason, it's not functioning properly in Firefox. I have carefully reviewed the '-moz-transform& ...

The Font Awesome icon is not displaying on top of the Materialize CSS progress/determinate bar

I am struggling to display a Font Awesome icon on top of a Materialize CSS progress/determinate div. Unfortunately, the icon is not fully visible and part of it gets clipped or hidden. Despite trying various solutions, I have not been successful. .progres ...

Struggling to adjust the width of an <img> tag to fit the screen within a UITextView/HTML using NSAttributedString

When I try to load HTML with images into a UITextView, the images do not want to fit the width of the screen, they appear too large. Setting the width attribute for the IMG tag and using CSS does not seem to help. Here is the code snippet: var content = ...

Styling CSS to automatically center buttons within a div at various screen resolutions

Within a div, I have noticed that when viewed on various screen resolutions, the three buttons are responsive. However, on certain screens, the last button appears below the first two buttons with no margin between them. Is there a method to add this marg ...

radio option block

I would like to create a block for radio buttons. Here is the code I have: <label> Rating <input type="radio">great <input type="radio">wonderful </label> Unfortunately, it is not functioning as expected. ...

Transition effortlessly between web pages with subtle fading effects

I want to implement smooth page transition effects between two web domains: mcpixel.co.uk/new and mcpaper.co.uk. I am the owner of both domains. When a link in the header is clicked, I'd like the page to fade transition to the new page without any whi ...

Fluidity of Containers on Mobile Devices

I currently have a list structured like this: https://i.sstatic.net/ei4Xt.png In order to display more details about each list item, I've added a hidden div that can be toggled open like so: https://i.sstatic.net/61k5Z.png While this works fine on ...

Exclusive bug discovery: figcaption mysteriously disappearing in Safari browser

Having a CSS dilemma on my personal portfolio website that has me stumped. I’ve been using the and tags to switch from an image to a caption/button upon desktop hover or mobile click. It's working smoothly on all browsers except for Safari iOS. W ...

What is the best way to assign a class to every menu item within WordPress?

Recently, I encountered a class in the Menu element of my HTML code. The class called "page-scroll" was present in every li a item, making it appear like this: <li><a class="page-scroll" href="#screenshots">Screenshots</a></li> Thi ...

Keep moving the box back and forth by pressing the left and right buttons continuously

Looking to continuously move the .popup class left and right by clicking buttons for left and right movement. Here is the js fiddle link for reference. This is the HTML code structure: <button class="right">Right</button> <button class="l ...

Tips for concealing a div in JavaScript when other divs are not present

Is there a way to hide the title div if related divs are not present in the HTML structure? This is the main HTML structure: <div class="row parent"> <div id="title-1" class='col-12 prov-title'> <h2 ...

Incorporate the slick-slider functionality smoothly into a WordPress website by utilizing JavaScript

I am fairly new to .js and currently attempting to incorporate a .js slider into my Wordpress site. I have been working on getting Slick-Slider operational on a website. While it functions perfectly fine on my static webpage, the transition to Wordpress ha ...

implementing HtmlSpanner with an appended css stylesheet

Using HtmlSpanner with CSS for TextView I recently discovered a library called HtmlSpanner that claims to assist in adding an HTML string with CSS to a TextView. However, I am struggling to locate any detailed documentation on how to achieve this, except ...

Compatibility of IE with table row spans

My table has rowspans that overlap, but in Internet Explorer it doesn't display correctly. The bottom right cell keeps being pushed so that the second-to-last cell on the right side matches the height of the middle one on the left side. However, Firef ...

Issues with Vue-Router Flexbox causing scrolling problems or no scrolling functionality

Having trouble with a component containing a router-view that displays a flexbox? The issue arises when the flexboxes do not scroll properly, cutting off the last element in the v-for loop. Various solutions have been attempted, but none seem to fully reso ...

What could be causing the progress bar to malfunction?

I have encountered an issue with my basic progress bar. It seems to work fine when I include only one progress element in my HTML page. However, if I add another one, the first one works as expected while the second one does not. You can view my code on C ...

In an environment with Internet Explorer 8, is it possible to use CSS web fonts in the WOFF file format?

Looking to use web fonts on Explorer 8 but having issues with my woff file not being applied as the font for the webpage. Any solutions to this problem? ...

Is it possible to vertically resize just one of three divs to match the size of the window?

I'm facing a challenge in creating a responsive webpage with multiple divs. Here is the structure I am trying to achieve: <div id="container"> maximum width of 1200 and height of 1000 <div id="vertically-static-top">20 pixels high< ...