I have a section in which is displaying via a flex box. This works great, but when the viewport gets to a 640px or less size, I want to be able to make all three section be shown in a display: block fashion with a width of 100%. I tried changing the #contact-section to display: block, but it went completely out of the format I have with flex.
I am wanting it to appear like this under 640px's.
Does anyone know how I can do it without losing the flex format, or at least making it work in this viewport?
Here is a fiddle which will allow the sections to be seen in a 640 or less viewport.
#contact-section {
display: flex;
justify-content: space-around;
align-items: center;
color: #FFF;
background: #00a16d;
padding: 1em;
}
#contact-section:before {
content: "";
flex: 0 0 1px;
height: 3em;
background: #FFF;
order: 2;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
font-style: italic;
}
#contact-section-right {
background: url("../icons/envelope.png") center / contain no-repeat;
font-size: 2em;
order: 3;
padding: 1em 0;
}
#contact-section-right a {
color: #FFF;
text-decoration: none;
}
/*--------------------------MEDIA QUERY 640------------------------------------*/
#media screen and (max-width:640px) {
#contact-section {
display: flex;
justify-content: space-around;
align-items: center;
padding: 1em 2em;
}
#contact-section:before {
flex: 0 0 1px;
height: 3em;
order: 2;
display: block;
width: 100%;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
display: block;
width: 100%;
}
#contact-section-right {
font-size: 2em;
order: 3;
padding: 1em 0;
display: block;
width: 100%;
}
}
<div id="contact-section">
<div id="contact-section-left">Tell us more about your digital marketing project.</div>
<div id="contact-section-right">Contact us</div>
</div>
I have changed the direction to column, seems that now it works
#contact-section {
display: flex;
justify-content: space-around;
align-items: center;
color: #FFF;
background: #00a16d;
padding: 1em;
}
#contact-section:before {
content: "";
flex: 0 0 1px;
height: 3em;
background: #FFF;
order: 2;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
font-style: italic;
}
#contact-section-right {
background: url("../icons/envelope.png") center / contain no-repeat;
font-size: 2em;
order: 3;
padding: 1em 0;
}
#contact-section-right a {
color: #FFF;
text-decoration: none;
}
/*--------------------------MEDIA QUERY 640------------------------------------*/
#media screen and (max-width: 640px) {
#contact-section {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
padding: 1em 2em;
}
#contact-section:before {
flex: 0 0 10px;
order: 2;
display: block;
width: 100%;
background-color: red;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
display: block;
width: 100%;
}
#contact-section-right {
font-size: 2em;
order: 3;
padding: 1em 0;
display: block;
width: 100%;
text-align: center;
}
}
<div id="contact-section">
<div id="contact-section-left">Tell us more about your digital marketing project.</div>
<div id="contact-section-right">Contact us
</div>
</div>
You could use min-width instead mediaqueries and flex-wrap:wrap and eventually border(s) on the first element to drop the pseudo ::before. See Fiddle test 1 & Fiddle test 2 .
#contact-section {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
color: #FFF;
background: #00a16d;
}
#contact-section:before {} #contact-section-left {
font-size: 1.5em;
font-style: italic;
min-width: 320px;
border-top: 1em solid transparent;
border-bottom: 1em solid transparent;
border-right: 1px solid white;
padding: 1em;
flex: 1;
}
#contact-section-right {
background: url("../icons/envelope.png") center / contain no-repeat;
font-size: 2em;
padding: 1em;
flex: 1;
min-width: 320px;
}
#contact-section-right a {
color: #FFF;
text-decoration: none;
}
<div id="contact-section">
<div id="contact-section-left">Tell us more about your digital marketing project.</div>
<div id="contact-section-right">Contact us
</div>
</div>
edit
if you still want to use a pseudo of 3em height, then you can draw it from the first box https://jsfiddle.net/mq41hgkp/3/
Related
I am trying to make a list with perfect alignment.
I have entered three items in the list but my list of with grey back ground is not appearing as same alignment as in the below picture.
My box width is changing according to the size of the font. I am providing both image in perfect same alignment and my image with two list item with not same width of grey background.
Below is the my css code:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 22px;
}
body {
min-height: 100vh;
font-family: 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.App {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
width: 100%;
max-width: 500px;
border: 1px solid mediumblue;
margin: auto;
}
header {
width: 100%;
padding: 0 0.25em;
background-color: mediumblue;
color: aliceblue;
display: flex;
justify-content: space-between;
align-items: center;
}
main {
width: 100%;
display: flex;
flex-direction: column;
flex-grow: 1;
justify-content: center;
align-items: center;
overflow-y: auto;
}
footer {
width: 100%;
padding: 0.25em;
background-color: mediumblue;
color: aliceblue;
display: grid;
place-content: center;
}
ul {
width: 100%;
list-style: none;
padding: 0 0.25rem 0.25rem;
}
ul li::before {
content: "\200B";
}
.item {
display: flex;
justify-content: flex-start;
align-items: center;
padding: 0.5rem 0 0.5rem 0.5rem;
margin: 0.25rem 0;
background-color: #eee;
}
.item: first-child {
margin: 0;
}
.item input[type="checkbox"] {
text-align: center;
width: 2.5rem;
width: 48px;
min-width: 48px;
height: 2.5rem;
height: 48px;
min-height: 48px;
cursor: pointer;
margin-right: 0.5rem;
}
.item input[type="checkbox"]:focus + label {
text-decoration: underline;
}
.item > label {
font-size: 0.75rem;
flex-grow: 1;
}
.item svg {
width: 48px;
min-width: 48px;
height: 36px;
font-size: 1rem;
color: steelblue;
cursor: pointer;
}
.item svg:focus,
.item svg:hover {
color: red;
outline: none;
}
Please guide me where I am doing mistake and why my grey background boxes are not same width as the below image.
I am currently creating a bit of a fun project. For some reason, my text and check / radio boxes do not align with the text. They seem to be off to one side and higher than the text.
Here is my pen - https://codepen.io/Amnesia180/pen/RwKQOKP
html,
body {
line-height: 1.5;
height: 100%;
margin: 0 auto;
font-family: 'Quicksand', sans-serif;
color: #070707;
}
header {
position: relative;
top: 0;
padding: 0;
background-color: #EFEFEF;
width: 100%;
height: 60px;
}
.material-icons {
color: #505050;
}
#nav-bar {
position: relative;
display: flex;
justify-content: space-between;
padding: 10px;
}
ul {
display: flex;
padding: 0;
list-style: none;
}
li {
padding: 0px 20px;
}
.nav-link-left {
float: left;
text-decoration: none;
color: #070707;
font-weight: 800;
}
.nav-link {
float: right;
text-decoration: none;
color: #070707;
font-weight: 800;
}
.nav-link:hover {
float: right;
color: #5873D9;
border-bottom: 3px solid #5873D9;
padding-bottom: 5px;
}
#intro {
display: flex;
flex-direction: column;
align-items: center;
height: 470px;
margin-top: 50px;
max-width: 90em;
}
h1 {
font-size: 4em;
color: #34D1BF;
}
h2 {
color: #5873D9;
margin-top: 20px;
}
form {
display: flex;
flex-direction: column;
}
label {
font-size: 1.5em;
padding: 10px 0;
}
input {
width: 100%;
height: 30px;
border: 2px solid #34D1BF;
padding: 5px;
}
#submit {
background-color: #34D1BF;
width: 40%;
height: 40px;
margin-top: 15px;
margin-left: 30%;
margin-right: 30%;
border: 2px solid #34D1BF;
color: white;
}
#about,
#promo-image,
#burger {
max-width: 50em;
width: 90vw;
margin: 0 auto;
padding: 5px;
text-align: left;
}
#promoimage {
display: block;
margin: 0 auto;
max-width: 518px;
width: 100%;
}
#burgers {
margin-top: 40px;
flex-direction: column;
align-items: center;
text-align: center;
justify-content: space-around;
}
.box {
border: 2px solid #EFEFEF;
border-radius: 5px;
margin: 2px;
text-align: center;
}
.price {
display: flex;
flex-direction: column;
margin: 0;
padding: 0;
}
.price li {
padding: 30px;
border: 0.5px solid #EFEFEF;
}
.card-header {
background-color: rgba(52, 209, 191, 1);
color: white;
}
footer {
width: 100%;
background-color: #EFEFEF;
height: 80px;
text-align: center;
}
footer p {
padding-top: 20px;
}
.burgerform {
text-align: left;
display: inline;
}
.burgerform label {
font-size: 1.5em;
font-weight: bold;
}
.burgerform legend {
font-weight: bold;
}
#media (min-width: 600px) {
#intro {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-evenly;
}
#burgers {
display: flex;
flex-direction: row;
align-items: center;
text-align: center;
justify-content: space-between;
}
}
<label>Sauces</label>
<p/> Burger Sauce <input type="checkbox" id="burgersauce" name="burgersauce" onclick="calculateTotal()"> Dirty Mayo Sauce
Can anyone advise?
Thanks!
Your inputs have width: 100%; which means it'll occupy entire width. And the "label" is just plain text so they are just flowing into the next line.
If you want to align them then you need proper elements (label>) aligned within 100% of the same line.
That is because you have given your inputs a width of 100%, so now each checkbox and radiobutton spans the whole width of the screen.
input {
width: 100%;
height: 30px;
border: 2px solid #34D1BF;
padding: 5px;
}
You can debug CSS issues using the CSS developer tools of your browser, as in the attached screenshot
Wrap both label (eg. Burger Mayo Sauce) and checkbox within a Flex-box, apply 100% width to it, and justify-content:space-between.
.menu-item{
witdh: 100%;
display:flex;
justify-content:space-between;
}
input[type=checkbox]{
//Whatever styling you want to apply to the checkbox.
}
Do not add the 100% width to the input, flexbox will manage the space for you.
The logo element in this page is not centering vertically within the <header> container. The problem is more pronounced on mobile than on desktop. The second element (#forum-link) is aligning correctly.
The flexbox align-items:center rule seems to work for one child div but not the other. Why is that the case and how do you fix it?
html {
max-width: 780px;
margin: 0 auto;
}
body {
background-image: url('https://img.freepik.com/free-vector/retro-styled-pattern-background_1048-6593.jpg');
background-size: 116px;
background-repeat: repeat-x;
}
header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
height:116px;
}
#logo {
margin-left: 15px;
}
#forum-link {
max-width: 110px;
margin-right: 35px;
}
#forum-link a {
color: white;
text-decoration: none;
font-weight: bold;
font-size: x-large;
}
#media only screen and (orientation: portrait) {
html {
margin: 0;
height: 100%;
}
body {
margin: 0;
height: 100%;
display: flex;
flex-flow: column;
}
header {
display: block;
width: 100%;
position: relative;
height: auto;
margin-bottom: 50px;
}
#logo {
margin: initial;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link {
margin: initial;
max-width: initial;
background: #323232;
height: 27px;
position: absolute;
bottom: -50px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link a {
font-weight: bold;
font-size: .9em;
}
#forum-link a:hover {
text-decoration: underline;
}
<body>
<header>
<div id="logo"><img src="http://placekitten.com/g/354/85" srcset="http://placekitten.com/g/354/85, http://placekitten.com/g/354/85 2x" width="354" height="85"></div>
<div id="forum-link">Join our Forums!</div>
</header>
</body>
EDIT: Clarified the question
Umm, I think this is what you're after: logo and link is vertically centred on the bg? Only updated for non-mobile solution.
Also, as I said in my comment, repeated here for comprehensiveness: your image isn't vertically centring because it's the height of its parents: the #logo and header.
The link has a smaller height than the header, so it's vertically centring.
If you're referring to the 5px or so of space, just throw a display: block on your #logo's image to remove that spacing. It will still be the height of its parents though.
My solution basically gives your body a height, flex it and your header aligns itself vertically centred.
html {
max-width: 780px;
margin: 0 auto;
}
body {
background-image: url('https://img.freepik.com/free-vector/retro-styled-pattern-background_1048-6593.jpg');
background-size: 116px;
background-repeat: repeat-x;
height: 116px;
margin: 0;
display: flex;
}
header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
margin-bottom: 0;
width: 100%;
}
#logo {
margin-left: 15px;
}
#logo img {
display: block;
}
#forum-link {
max-width: 110px;
margin-right: 35px;
}
#forum-link a {
color: white;
text-decoration: none;
font-weight: bold;
font-size: x-large;
}
#media only screen and (orientation: portrait) {
html {
margin: 0;
height: 100%;
}
body {
margin: 0;
height: 100%;
display: flex;
flex-flow: column;
}
header {
display: block;
width: 100%;
position: relative;
height: auto;
margin-bottom: 50px;
}
#logo {
margin: initial;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link {
margin: initial;
max-width: initial;
background: #323232;
height: 27px;
position: absolute;
bottom: -50px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link a {
font-weight: bold;
font-size: .9em;
}
#forum-link a:hover {
text-decoration: underline;
}
<body>
<header>
<div id="logo"><img src="http://placekitten.com/g/354/85" srcset="http://placekitten.com/g/354/85, http://placekitten.com/g/354/85 2x" width="354" height="85"></div>
<div id="forum-link">Join our Forums!</div>
</header>
</body>
Just add margin: 0 in body :
html {
max-width: 780px;
margin: 0 auto;
}
body {
background-image: url('https://img.freepik.com/free-vector/retro-styled-pattern-background_1048-6593.jpg');
background-size: 116px;
background-repeat: repeat-x;
margin: 0;
}
header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
height:116px;
}
#logo {
margin-left: 15px;
}
#forum-link {
max-width: 110px;
margin-right: 35px;
}
#forum-link a {
color: white;
text-decoration: none;
font-weight: bold;
font-size: x-large;
}
#media only screen and (orientation: portrait) {
html {
margin: 0;
height: 100%;
}
body {
margin: 0;
height: 100%;
display: flex;
flex-flow: column;
}
header {
display: block;
width: 100%;
position: relative;
height: auto;
margin-bottom: 50px;
}
#logo {
margin: initial;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link {
margin: initial;
max-width: initial;
background: #323232;
height: 27px;
position: absolute;
bottom: -50px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link a {
font-weight: bold;
font-size: .9em;
}
#forum-link a:hover {
text-decoration: underline;
}
<body>
<header>
<div id="logo"><img src="http://placekitten.com/g/354/85" srcset="http://placekitten.com/g/354/85, http://placekitten.com/g/354/85 2x" width="354" height="85"></div>
<div id="forum-link">Join our Forums!</div>
</header>
</body>
You need to specify the width of your parents for it to center vertically. And then add text-align: center;. Change the styles of your #logo and #forum-link as below.
#logo {
flex: 1;
width: 50%;
text-align: center;
}
#forum-link {
max-width: 110px;
flex: 1;
width: 50%;
text-align: center;
}
I removed your margins because the preview here is very small and you wont notice that the elements were centered vertically. Feel free to put it back in your source code. Check code below
html {
max-width: 780px;
margin: 0 auto;
}
body {
background-image: url('https://img.freepik.com/free-vector/retro-styled-pattern-background_1048-6593.jpg');
background-size: 116px;
background-repeat: repeat-x;
}
header {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
align-items: center;
margin-bottom: 23px;
}
#logo {
flex: 1;
width: 50%;
text-align: center;
}
#forum-link {
max-width: 110px;
flex: 1;
width: 50%;
text-align: center;
}
#forum-link a {
color: white;
text-decoration: none;
font-weight: bold;
font-size: x-large;
}
#media only screen and (orientation: portrait) {
html {
margin: 0;
height: 100%;
}
body {
margin: 0;
height: 100%;
display: flex;
flex-flow: column;
}
header {
display: block;
width: 100%;
position: relative;
height: auto;
margin-bottom: 50px;
}
#logo {
margin: initial;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link {
margin: initial;
max-width: initial;
background: #323232;
height: 27px;
position: absolute;
bottom: -50px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}
#forum-link a {
font-weight: bold;
font-size: .9em;
}
#forum-link a:hover {
text-decoration: underline;
}
<body>
<header>
<div id="logo"><img src="http://placekitten.com/g/354/85" srcset="http://placekitten.com/g/354/85, http://placekitten.com/g/354/85 2x" width="354" height="85"></div>
<div id="forum-link">Join our Forums!</div>
</header>
</body>
When I resize my page, the text from my right column overlaps the image in the left column, like so:
How do I stop this and make the right column stay where it is, or go below the image when the page is resized? I don't want to change the layout of the page when it's fullscreen, but I want it to be responsive.
#import url(https://fonts.googleapis.com/css?family=Raleway);
body {
margin: 0;
font-family: 'Raleway', georgia, arial;
background-color: #e0e0e0;
text-align: center;
}
h1 {
color: #aaaaaa;
text-align: left;
}
.sortFilms {
text-align: left;
display: inline-block;
background-color: #ff6699;
width: 80%;
padding: 20px;
}
header {
text-align: center;
display: inline-block;
border-bottom: 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-style: solid;
border-color: #aaaaaa;
width: 80%;
padding: 20px;
background-color: #e0e0e0;
}
.newFilm {
text-align: left;
display: inline-block;
background-color: #ff6699;
width: 80%;
padding: 20px;
}
label {
font-size: 1em;
padding: 6px;
color: #fff;
font-weight: 700;
display: block;
text-align: left;
}
.form {
margin: auto;
display: flex;
text-align: center;
flex-direction: column;
}
h2 {
font-weight: 700;
font-size: 2em;
width: 50%;
color: #B2365F;
}
#formTitle {
margin-top: 0;
margin-bottom: 0;
}
.row {
margin-left: -20px;
display: grid;
grid-template-columns: 1fr 1fr;
}
.col {
padding: 20px;
}
input,
textarea,
select {
width: 100%;
display: block;
border-radius: 25px;
background-color: #e0e0e0;
padding: 10px;
border: none;
box-sizing: border-box;
}
}
.tagline {
margin: 0;
color: #333333;
font-size: 1em;
font-weight: 700;
}
input::placeholder {
color: #000;
}
textarea::placeholder {
color: #000;
}
#modifyFilmButton {
float: right;
}
#media only screen and (max-width: 700px) {
.row {
grid-template-columns: 1fr;
}
}
#media screen and (max-width:800px) {
table {
border: 0;
}
table caption {
font-size: 1.3em;
}
table thead {
border: none;
clip: rect(0 0 0 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
}
table tr {
border: 2px solid #e0e0e0;
background-color: #e0e0e0;
display: block;
margin-bottom: .625em;
border-radius: 20px;
}
table td {
display: block;
font-weight: bold;
font-size: 1.2em;
text-align: left;
padding: 15px;
}
table td::before {
/*
* aria-label has no advantage, it won't be read inside a table
content: attr(aria-label);
*/
content: attr(data-label);
float: left;
font-weight: bold;
text-transform: uppercase;
}
table td:last-child {
border-bottom: 0;
}
}
.oldFilm {
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
text-align: left;
display: inline-block;
background-color: #AAAAAA;
width: 80%;
padding: 20px;
}
#oldTitle {
margin-top: 0;
margin-bottom: 0;
color: #ff6699;
padding-bottom: 20px;
}
td {
padding: 5px;
font-weight: bold;
}
table {
border-collapse: collapse;
text-align: center;
width: 100%;
}
thead {
background: #ff6699;
}
.reviewImage {
width: 200px;
border-radius: 20px;
}
.filmRow img {
width: 300px;
height: 420px;
margin: 10px;
border-radius: 20px;
}
.filmRow {
-webkit-flex-flow: row wrap;
justify-content: space-around;
}
#filmContainer {
width: 100%;
margin-top: 10px;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-around;
}
#date {
padding: 5px;
text-align: left;
width: 30%;
}
#date input {
width: auto;
}
#date label {
display: -webkit-inline-box;
}
#oldTitle2 {
margin-top: 0;
margin-bottom: 0;
color: #ff6699;
}
.genre {
padding: 5px;
text-align: left;
width: 60%;
}
.genre input {
width: auto;
}
.genre label {
display: -webkit-inline-box;
}
/* third page */
#filmImage {
width: 300px;
height: 420px;
margin: 10px;
border-radius: 20px;
}
#filmTitle {
font-weight: 700;
margin-bottom: 20px;
font-size: 3em;
width: 100%;
color: #B2365F;
}
#leftcol {
width: 25%;
display: flex;
flex-direction: column;
}
#rightcol {
display: flex;
flex-direction: column;
width: 50%;
margin: 5px;
}
#rightcol label {
padding: 0;
}
#rightcol p {
margin-bottom: 10px;
margin-top: 2px;
}
#filmContainer2 {
width: 100%;
margin-top: 10px;
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: center;
}
#indent {
margin: 5px;
}
<header>
<img src="img/rv-logo.png">
<p class="tagline">Want to know whether or not it's worth paying to watch a certain film or not? See what we think first!</p>
</header>
<div class="sortFilms">
<div id="filmContainer2">
<div id="leftcol">
<img id='filmImage' src="https://images-na.ssl-images-amazon.com/images/I/51Gh9OaWVcL.jpg">
</div>
<div id="rightcol">
<p id='filmTitle'>Deadpool</p>
<div id="indent">
<label>Year:</label>
<p id='filmYear'>2016</p>
<label>Genre:</label>
<p id='filmGenre'>Action/Comedy</p>
<label>Rating:</label>
<p id='filmRating'>9/10</p>
<label>Synopsis:</label>
<p id='filmSynopsis'>blah blah blah blah</p>
</div>
<a href='viewFilms.html'>Back to list</a>
</div>
</div>
</div>
The problem is with your image the div containing the image has 25% width, but your image has a width which is larger than 25% of its parent so the image overflows its parent. You should not do like that try to set the image width to 100%.
To fix your problem set the width of the image to 100% and adjust the width of its parent to adjust image size
And one more tip if you're using flexbox use the property flex-wrap:wrap...so the divs inside the flex will automatically shift down according to screen size
To learn more about flex check this link out
https://css-tricks.com/snippets/css/a-guide-to-flexbox/
Here's my issue:
I am trying to create a side-by-side ad where the left side is just an image, and the right side is a background image with an image, text, and 5 responsive flexgrid buttons nested on top of it.
I figured out how to get everything layered on top of the background image, but right now I cannot for the life of me figure out how to get the background image container to scale with the image to its left. I have been tweaking percentages and margins for hours now trying to figure it out.
I managed to get it extremely close on a certain screen size (2560x1440) but as the window is resized the background image container ends up resizing differently than the image. One solution I thought of is just creating like 10 media query breakpoints where I tweak the margins and paddings to make the images the same size, but honestly, I'd rather find a more efficient and cleaner way to do it.
Please don't judge my code, it's incredibly messy I know! I am still learning.
https://jsfiddle.net/y8nz39gL/3/
DESIRED RESULT
.flex-container {
display: -webkit-flex;
display: flex;
-webkit-justify-content: center;
justify-content: center;
max-width: 100%;
background-image: url('https://cdn.shopify.com/s/files/1/1017/0995/files/Luckyleo-Custom-Print-Floral-Background.jpg?13173226259512623367');
background-position: 50 50;
background-repeat: no-repeat;
background-attachment: fixed;
padding: 50px 0px 50px 0px;
}
.flex-container2 {
display: -webkit-flex;
display: flex;
-webkit-justify-content: center;
justify-content: center;
max-width: 100%;
margin-bottom: -100px;
}
/* NEW */
.flexbottommargin {
margin-bottom: -50px;
}
.less-space-bottom {
margin-bottom: -20px !important;
}
/*NEW OVER*/
.flex-container20 {
padding-top: 35px;
padding-bottom: 35px;
display: -webkit-flex;
display: flex;
-webkit-justify-content: center;
justify-content: center;
max-width: 100%;
margin-bottom: -75px;
}
.flex-container21 {
padding-top: 35px;
padding-bottom: 35px;
display: -webkit-flex;
display: flex;
-webkit-justify-content: center;
justify-content: center;
max-width: 100%;
margin-bottom: -75px;
}
.flex-container22 {
display: -webkit-flex;
display: flex;
-webkit-justify-content: center;
justify-content: center;
max-width: 100%;
margin-bottom: -100px;
margin-top: -2px;
}
.flex-container23 {
display: -webkit-flex;
display: flex;
-webkit-justify-content: center;
justify-content: center;
max-width: 100%;
margin-bottom: -100px;
margin-top: -2px;
}
.flex-container-content2 img {
padding-bottom: 15px;
}
.luckyleospacer {
padding-bottom: 20px;
}
.extrabottompadding {
padding-bottom: 12px;
}
.extrabottompadding2 {
padding-bottom: 20px;
}
/* NEW */
.flex-container-content-newyears {
padding-top: 20px;
width: 71%;
/*NEW LINE*/
align-items: center;
align-self: center;
justify-content: center;
padding-bottom: 20px;
text-align: center;
}
.flex-container-content-newyears-banner {
padding-top: 20px;
width: 64%;
align-items: center;
align-self: center;
justify-content: center;
padding-bottom: 20px;
text-align: center;
}
/*NEW OVER*/
.flex-container-content {
padding-top: 35px;
width: 60%;
align-items: center;
align-self: center;
justify-content: center;
padding-bottom: 10px;
}
.flex-container-content2 {
padding-top: 35px;
width: 75%;
align-items: center;
align-self: center;
justify-content: center;
padding-bottom: 35px;
text-align: center;
}
.flex-container-content22 {
padding-top: 35px;
width: 100%;
align-items: center;
align-self: center;
justify-content: center;
}
.flex-container-content23 {
width: 100%;
align-items: center;
align-self: center;
justify-content: center;
}
.flex-container-content23 {
padding-top: 35px;
width: 100%;
align-items: center;
align-self: center;
justify-content: center;
}
.flex-container-content24 {
width: 100%;
align-items: center;
align-self: center;
justify-content: center;
padding-bottom: 55px;
text-align: center;
}
.flex-container-content h1 {
font-family: "Asap", sans-serif;
font-size: 2.4vw;
color: #292929 !important;
text-transform: none !important;
font-weight: 600;
line-height: 1.3em;
letter-spacing: 0px;
padding: 4%;
}
.flexgrid-cell {
margin-bottom: 0px;
}
.flex-container-content h2 {
font-family: "Lavanderia", sans-serif !important;
font-size: 4vw;
color: #292929 !important;
text-transform: none !important;
font-weight: 400;
line-height: 1.4em;
margin-bottom: 35px;
letter-spacing: 0px;
}
.flex-container-content2 h1 {
font-family: "Lavanderia", serif !important;
font-size: 50px;
font-size: 3.5vw;
color: #292929 !important;
text-transform: none !important;
font-weight: 500;
line-height: 1.3em;
letter-spacing: 0px;
}
.flex-container-content2 p {
padding-top: 20px;
color: #292929 !important;
text-transform: none !important;
padding-bottom: 20px;
}
.flex-container {
max-width: 100%;
margin: auto;
//border: 1px solid red;
}
/*Basic flexgrid Styles*/
.flexgrid {
display: flex;
flex-flow: row;
flex-wrap: wrap;
}
.u-textCenter {
text-align: center;
align-items: center;
align-self: center;
justify-content: center;
}
.flexgrid-cell {
width: 100%;
flex: 1;
}
.flexgrid-cell img {
width: 100%;
}
/* Justify per row*/
.flexgrid--right {
justify-content: flex-end;
}
.flexgrid--center {
justify-content: center;
}
/* Alignment per row */
.flexgrid--top {
align-items: flex-start;
}
.flexgrid--bottom {
align-items: flex-end;
}
.flexgrid--center {
align-items: center;
}
/* Alignment per cell */
.flexgrid-cell--top {
align-self: flex-start;
}
.flexgrid-cell--bottom {
align-self: flex-end;
}
.flexgrid-cell--center {
align-self: center;
}
/*===========================================*/
/* Base classes for all media - Mobile first */
.flexgrid--cols-2 > .flexgrid-cell {
flex: 0 0 100%;
}
.flexgrid--cols-3 > .flexgrid-cell {
flex: 0 0 100%;
}
.flexgrid--cols-4 > .flexgrid-cell {
flex: 0 0 100%;
}
.flexgrid--cols-6 > .flexgrid-cell {
flex: 0 0 calc(50% - #{$gutter});
}
.flexgrid--cols-12 > .flexgrid-cell {
flex: 0 0 calc(33.3333% - #{$gutter});
}
/* One of -- columns*/
.flexgrid--1of2 > .flexgrid-cell,
.flexgrid--1of4 > .flexgrid-cell:first-of-type,
.flexgrid--1of3 > .flexgrid-cell:first-of-type {
flex: 0 0 100%;
}
.flexgrid--1of6 > .flexgrid-cell:first-of-type {
flex: 0 0 50%;
}
.flexgrid--fit > .flexgrid-cell {
flex: 1;
}
.flexgrid--full > .flexgrid-cell {
flex: 0 0 100%;
}
/* Tablet (medium) screens */
#media (min-width: 30em) {
.flexgrid--cols-4 > .flexgrid-cell {
flex: 0 0 calc(50% - #{$gutter});
}
.flexgrid--cols-6 > .flexgrid-cell {
flex: 0 0 calc(33.3333% - #{$gutter});
}
.flexgrid--cols-12 > .flexgrid-cell {
flex: 0 0 calc(16.6666% - #{$gutter});
}
.flexgrid--holly-grail {
.aside {
flex: 1 calc(25% - #{$gutter});
}
}
.flexgrid--1of2 > .flexgrid-cell {
flex: 0 0 50%;
}
.flexgrid--1of6 > .flexgrid-cell:first-of-type {
flex: 0 0 30%;
}
.flexgrid--1of4 > .flexgrid-cell:first-of-type {
flex: 0 0 50%;
}
.flexgrid--1of3 > .flexgrid-cell:first-of-type {
flex: 0 0 100%;
}
}
/* Large screens */
#media (min-width: 48em) {
.flexgrid--cols-2 > .flexgrid-cell,
.flexgrid--cols-3 > .flexgrid-cell,
.flexgrid--cols-4 > .flexgrid-cell,
.flexgrid--cols-6 > .flexgrid-cell,
.flexgrid--cols-12 > .flexgrid-cell {
flex: 1;
}
.flexgrid--1of2 > .flexgrid-cell {
flex: 0 0 50%;
}
.flexgrid--1of6 > .flexgrid-cell:first-of-type {
flex: 0 0 16.6666%;
}
.flexgrid--1of4 > .flexgrid-cell:first-of-type {
flex: 0 0 25%;
}
.flexgrid--1of3 > .flexgrid-cell:first-of-type {
flex: 0 0 30%;
}
.flexgrid--gutters.flexgrid--nested {
.flexgrid-cell:first-of-type {
.Demo {
margin-right: 0;
}
}
}
}
/* 2/3rds COLUMN SPLIT */
/* NEW */
.flexgrid--half-l {
flex-basis: 49.1%;
max-width: 49.1%;
margin-right: .6%;
}
.flexgrid--half-r {
flex-basis: 50%;
max-width: 50%;
margin-left: .4%;
}
.flexgrid--1of3 {
flex-basis: 57.188%;
max-width: 57.188;
}
.desktopshowtop {
padding-top: 57px;
}
.desktopshowtopbanner {
padding-top: 57px;
}
/* NEW */
#media only screen and (min-width: 300px) and (max-width: 1024px) {
.flex-container-content h2 {
font-size: 12vw;
}
.flex-container-content h1 {
font-size: 4.2vw;
}
.flex-container-content2 h1,
h2 {
font-size: 40px;
font-size: 6.8vw;
}
}
#media only screen and (min-width: 300px) and (max-width: 419px) {
.flex-container-content2 h1,
h2 {
font-size: 40px;
font-size: 8vw;
}
}
#media only screen and (min-width: 300px) and (max-width: 1267px) {
.whyispaddinghere {
margin-bottom: -115px;
}
.flex-container-content {
width: 90%;
}
.flex-container-content2 {
width: 95%;
}
}
#media only screen and (min-width: 1025px) {
.flex-container21 {
display: none;
}
.flex-container23 {
display: none;
}
}
#media only screen and (min-width: 300px) and (max-width: 1024px) {
.flex-container20 {
display: none;
}
.flex-container22 {
display: none;
}
}
/* NEW LINES - 2018 */
/* With gutters*/
$gutter: 1em;
.flexgrid--gutters {
margin-left: -$gutter;
.flexgrid-cell {
padding-left: $gutter;
}
.flexgrid--nested {
.flexgrid-cell:first-of-type {
margin-right: 1em;
}
}
}
}
.flex-container-content-newyears {
padding-top: 20px;
width: 75%;
/*NEW LINE*/
align-items: center;
align-self: center;
justify-content: center;
padding-bottom: 20px;
text-align: center;
}
.flex-container-newyears {
display: -webkit-flex;
display: flex;
-webkit-justify-content: center;
justify-content: center;
max-width: 100%;
}
.content-1of5:hover {
background-color: #a36871;
}
.content-1of5 {
background-color: #8d5760;
-webkit-border-radius: 4;
-moz-border-radius: 4;
border-radius: 4px;
font-family: "Asap", sans-serif;
align-self: center;
justify-content: center;
align-items: center;
padding-top: 6px;
padding-bottom: 6px;
margin-left: 7px;
margin-right: 7px;
margin-bottom: 7px;
color: #fff;
}
.content-1of5 a {
color: #fff !important;
}
.express-promo-right-side {
background-image: url("https://cdn.shopify.com/s/files/1/2185/4785/files/Express-ShopYourSizebg.jpg?4927879912789524270");
background-position: 0 0;
background-repeat: no-repeat;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
margin: auto;
}
.express-promo-right-side img {
padding-top: 5.4%;
margin-top: 12px;
max-width: 40% !important;
margin-bottom: -5%;
}
.express-buttons-margin-top {
padding: 14.0% 2% 4.0% 2%;
margin-bottom: -9px;
}
.flexgrid--half-r {
margin-bottom: 1%;
margin-top: 1%;
}
.shopsizefrontpage {
padding-top: 10%;
margin-bottom: -10%;
font-size: 5vw !important;
line-height: 1.0em;
font-family: 'Poppins';
color: #fff !important;
font-weight: 800;
}
.shopsizefrontpagered {
color: #8d5760 !important;
}
.Grid--nested {
.Grid-cell:first-of-type {
.Demo {
margin-right: 1em;
}
}
}
}
\
<div class="flex-container-newyears">
<div class="flex-container-content-newyears">
<div class="flexgrid flexgrid--gutters flexgrid--cols-3 u-textCenter">
<div class="flexgrid--half-l flexgrid-cell">
<img src="https://cdn.shopify.com/s/files/1/2185/4785/files/Express-ShopYourSize.jpg?4927879912789524270" alt="Luckyleo How to Customize - Step 1" />
</div>
<div class="flexgrid--half-r flexgrid-cell express-promo-right-side"><img src="https://cdn.shopify.com/s/files/1/2185/4785/files/Express-ShopYourSize2-logo.png?5263606338478632237" />
<div class="flexgrid-cell shopsizefrontpage">SHOP <span class="shopsizefrontpagered"> YOUR SIZE</span></div>
<div class="flexgrid flexgrid--gutters flexgrid--cols-4 u-textCenter express-buttons-margin-top">
<div class="flexgrid-cell">
<a href="https://www.luckyleodancewear.com/collections/luckyleoexpress-extra-extra-small-lucky-leos">
<div class="content-1of5">XXS</div>
</a>
</div>
<div class="flexgrid-cell">
<a href="https://www.luckyleodancewear.com/collections/luckyleoexpress-extra-extra-small-lucky-leos">
<div class="content-1of5">XXS</div>
</a>
</div>
<div class="flexgrid-cell">
<a href="https://www.luckyleodancewear.com/collections/luckyleoexpress-extra-extra-small-lucky-leos">
<div class="content-1of5">XXS</div>
</a>
</div>
<div class="flexgrid-cell">
<a href="https://www.luckyleodancewear.com/collections/luckyleoexpress-extra-extra-small-lucky-leos">
<div class="content-1of5">XXS</div>
</a>
</div>
<div class="flexgrid-cell">
<a href="https://www.luckyleodancewear.com/collections/luckyleoexpress-extra-extra-small-lucky-leos">
<div class="content-1of5">XXS</div>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
Rather than trying to sync behavior of a background-image with an <img>, just use a background-image over the entire element and control the proportion specifying height or min-height at different widths.
Here's a starter. As a side note, I find your markup way too complex for the desired outcome, so I simplified it a bit.
body {
background-color: #f5f5f5;
margin: 0;
font-family: sans-serif;
}
.newyears {
background: url(https://i.stack.imgur.com/oK65C.jpg) no-repeat 50% 50% /cover;
display: flex;
justify-content: flex-end;
min-height: 30vw;
}
.nys-content {
flex: 0 0 50%;
display: flex;
padding: 3rem 0;
flex-direction: column;
align-items: center;
justify-content: center;
border-left: 10px solid white;
}
.nys-content img {
width: 150px;
margin-bottom: 1.5rem;
}
.nys-links {
display: flex;
align-items: center;
justify-content: center;
}
.nys-links a {
background-color: #900;
color: white;
text-decoration: none;
margin: 3px;
padding: .75rem;
flex: 1 .1 20%;
text-align: center;
}
#media (max-width: 768px) {
.nys-links, .nys-links a {
width: 60%;
}
.nys-links {
flex-direction: column;
}
}
#media (max-width: 540px) {
.nys-content {
flex: 1 0 auto;
border-left: none;
}
}
<div class="newyears">
<div class="nys-content">
<img src="https://cdn.shopify.com/s/files/1/2185/4785/files/Express-ShopYourSize2-logo.png?5263606338478632237">
<div class="nys-links">
XXS
XXS
XXS
XXS
XXS
</div>
</div>
</div>
If you prefer jsFiddle, here it is.
Note: This answer does not attempt to sync scaling of background-image with an <img> tag. It's based on comments below the question on how I'd tackle this task. Syncing the two above can be achieved using transforms. Here's an example of how to achieve it.