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.