The background positioning feature is experiencing some technical issues

Using Jekyll, I have code where the inline background-position changes based on the front-matter position I define:

* {
  box-sizing: border-box;
}

body{
  padding: 0;
  margin: 0;
}

.page__hero--overlay {
  position: relative;
  margin-bottom: 2em;
  padding: 3em 0;
  clear: both;
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;
  -webkit-animation: intro 0.3s both;
  animation: intro 0.3s both;
    animation-delay: 0s;
  -webkit-animation-delay: 0.25s;
  animation-delay: 0.25s;
}

@media (min-width: 80em)
.page__hero--overlay .wrapper {
  max-width: 1280px;
}

.page__hero--overlay .wrapper {
  padding-left: 1em;
  padding-right: 1em;
}

.wrapper {
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.page__hero--overlay .wrapper {
  padding-left: 1em;
  padding-right: 1em;
}

.parallax {
  background-attachment: fixed;
}

.page__hero--overlay .page__title {
  font-size: 1.953em;
  color: #fff;
  text-shadow: 1px 1px 4px rgba(0,0,0,0.5);
}

.page__title {
  margin-top: 0;
  line-height: 1;
}

h1, h2 {
  -webkit-transition: all 0.2s ease-in-out;
  transition: all 0.2s ease-in-out;
}

h1 {
  margin-top: 0;
  font-size: 1.563em;
}

h1, h2, h3, h4, h5, h6 {
  margin: 2em 0 0.5em;
    margin-top: 2em;
  line-height: 1.2;
  font-family: -apple-system,BlinkMacSystemFont,"Roboto","Segoe UI","Helvetica Neue","Lucida Grande",Arial,sans-serif;
  font-weight: bold;
}

p {
  margin-bottom: 1.3em;
}

.page__hero--overlay .page__lead {
  max-width: 768px;
  color: #fff;
  text-shadow: 1px 1px 4px rgba(0,0,0,0.5);
}

.page__lead {
  font-family: -apple-system,BlinkMacSystemFont,"Roboto","Segoe UI","Helvetica Neue","Lucida Grande",Arial,sans-serif;
  font-size: 1.25em;
}
<div class="page__hero--overlay parallax" style=" background-image: url('https://images.unsplash.com/photo-1514496959998-c01c40915c5f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1740&q=80'); background-position: 25% 90%;">
  <div class="wrapper">
    <h1 id="page-title" class="page__title" itemprop="headline">Title</h1>  
    <div style="margin-top: 130px;"></div>
    <p class="page__lead">Something<br>Something</p>
  </div>
</div>

However, when on desktop (width:1500px height:600+) I struggle to adjust the image positioning without setting background-position: 25% 1000%, and on mobile devices (width:<500- height:900) it doesn't seem to have any effect at all, which is perplexing.

Calc(100% - 200px) somewhat works on smaller screens but becomes problematic for my desired image display on larger screens. What could be causing this issue?

I am looking for an in-line resolution since variables cannot be passed to SASS with Jekyll in mind.

Answer №1

.page__header--overlay {
background-image: url('https://images.unsplash.com/photo-1514496959998-c01c40915c5f');
    width: 100%;
    height: 60vh;
    max-height: 650px;
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}

Implement this CSS in your style sheet to enable automatic responsiveness and also add a media query to adjust the max-height according to your needs.

I hope this solution works for you. If it doesn't, I apologize.

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

Problem occurring with Bulma CDN version 0.8.0 failing to identify the spacing helper

Recently revisited an older project I had started some time ago using the Bulma framework. However, for some reason, the 0.8.0 CDN is not being imported or recognized correctly by the spacing classes. Here's the code snippet I had initially: <link ...

JQuery integration resulting in disappearance of Input-group-btn element

Allow me to explain my current project. I am in the process of developing a Modal that enables users to input a password There will be an option to toggle between showing or hiding the text in the password field using a button positioned on the right sid ...

Adjust Text to Perfectly Fit Button

I am developing a quiz using bootstrap and javascript. One issue I encountered is that the text in the buttons can sometimes be longer than the button itself. This results in the text not fitting properly within the button, making it unreadable on mobile ...

What causes materialui styles to vanish upon refreshing in nextjs?

After consulting the materialui documentation (https://material-ui.com/guides/server-rendering/), I was able to find a solution, but I am still unsure of the underlying reason. Why does the style work initially during rendering but disappear upon subs ...

Creating a rotating circle in CSS with ion-slides: A step-by-step guide

Hello, I am attempting to develop a circular object that will rotate in the direction it is dragged. Within this circle, there are elements positioned along the border so that these elements also spin accordingly. To illustrate, below are the specific elem ...

Transform or retrieve information from input into unformatted text

I'm working on a JavaScript function that can convert input values to text. However, I am facing an issue as I only want to convert data from one specific row into plain text. Each row in my table has 5 cells along with a button for saving the data. I ...

Connect two radio buttons across separate forms

I am encountering an issue with two radio buttons that I am trying to link together. The problem arises because they are located in two separate form elements, causing them not to function as intended. It is important for the forms to be utilized in Bootst ...

What is the best way to make my input tags move downwards when resizing the screen?

I need help with a grid layout. My goal is to have the input tags (marked in blue) shift below when resizing the browser or viewing on a mobile or tablet device, while keeping the other three tags on the same line. I attempted to position the small box to ...

What is the best way to resize a Drawable to fit the width of a TextView?

When trying to render HTML with image tags within a TextView, I encountered issues with scaling the images using the getDrawable() code. Here is an example snippet of the code: myTextView.setText(Html.fromHtml(htmlSource, this, this)); @Override public Dr ...

Transforming HTML produced by an outdated ASP system to generate modern ASP.NET 2.0 web pages

I have a friend who is currently working on developing a solution to convert aspx pages from html pages generated by an older asp application. The plan involves running the legacy app, capturing the html output, cleaning the html with a tool like HtmlTidy ...

JQuery does not recognize $(this) after the HTML has been altered

I manage a website that includes several href links and 2 buttons that have the ability to modify those links dynamically. <div class="links"> <p class="hlCategory">Classical Mechanics</p> <ul> <li><a cl ...

What is the reason behind the jQuery only functioning properly on Internet Explorer 8 on this particular page and no other browsers?

I recently created a webpage utilizing jQuery: The functionality on the page should change music images to represent different key signatures when switching from 'Higher Key' to 'Lower Key' in the combo box. While this works perfectly ...

Unable to view Bootstrap modal upon click

Whenever I attempt to display a modal using Bootstrap, it mysteriously appears upon page refresh but fails to show up when the button is clicked. Ideally, I want the modal to only appear when the user clicks on the button. The structure of my html file lo ...

Create and dispatch a JSON POST request to a remote domain without direct server access

My current hurdle involves attempting a POST request in JSON to an external domain without having access to the server's files for modification. However, upon making the request, I encounter the following error: XMLHttpRequest cannot load . No & ...

Issue with Datepicker in Angular Bootstrap: format identifier not being utilized

Check out this Plunk for reference. This is how my controller is set up: app.controller("myController", [ "$scope", function($scope){ $scope.DateFormat = "DD/MM/YYYY"; $scope.From = '15/01/2015'; // DD/MM/YYYY ...

Creating a 3D slider on Owl-carousel 2: A Step-by-Step Guide

I am trying to create a slider using Owl-carousel, but I'm having trouble implementing it. I came across this example https://codepen.io/Webevasion/pen/EPMGQe https://i.stack.imgur.com/KnnaN.jpg However, the code from this example doesn't seem ...

Functionality fails to load correctly post completion of AJAX request

After successfully implementing an API call to OS Maps (UK map builder) as per their documentation, I encountered a problem when trying to display a map based on a custom field name using ACF (Advanced Custom Fields) in WordPress. The issue arises because ...

Using absolute elements within a div that is positioned relative in HTML code

In the layout below: <div style="margin-top:0%" class="postcell"> <div id="postspantitle" > <span class="texts"><?php echo __('Başlık :', 'goldmem');?></span> </div> & ...

"Create a notification pop-up in CSS that appears when a link is clicked, similar to

I am looking to create a model page that functions similarly to the inbox popup on Stack Overflow. When we click on the inbox icon, a small box appears with a tiny loader indicating messages or comments. The box then expands depending on the content inside ...

Is it possible to implement smooth scrolling in HTML without using anchor animation?

Is it feasible to implement a more seamless scrolling experience for a website? I'm referring to the smooth scrolling effect seen in MS Word 2013, but I haven't come across any other instances of this. I've heard that AJAX can make such th ...