Building a carousel in React - css

I am trying to build a carousel from scratch in React. I want the active card to be in the middle and the others to show a portion of them on the side. When I put overflow hidden, it hides the portions.
How do I make it so that the side portions appear but I still maintain the background image blur?
here is my jsx code:
import React from 'react'
import './Header.css'
import {images} from '../../constants'
import Blur from 'react-blur'
const Header = () => {
return (
<Blur className="app__header" img={images.bgcake} blurRadius={35} style={{height: "100vh"}} >
<div className="app__header-carousel">
<div className="app__header-carousel-1">
<img className="app__header-carousel-img" alt="pink cake" src={images.carousel01} />
<div className="app__header-carousel-content">
<h3 className="app__header-h3">Fresh Baked | Fathers Day</h3>
<h1 className="app__header-h1">MORNING BERRY</h1>
<p className="app__header-p">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque, omnis odit similique dolor ab maiores quae aliquam beatae ad deleniti porro ducimus eum provident fuga quo doloremque animi impedit unde.</p>
<button type="button" className="app__explore-button">Order</button>
<button type="button" className="app__order-button">Explore</button>
</div>
</div>
<div className="app__header-carousel-1">
<img className="app__header-carousel-img" alt="red velvet" src={images.redVelvet} />
<div className="app__header-carousel-content">
<h3 className="app__header-h3">Fresh Baked | Fathers Day</h3>
<h1 className="app__header-h1">RED VELVET</h1>
<p className="app__header-p">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque, omnis odit similique dolor ab maiores quae aliquam beatae ad deleniti porro ducimus eum provident fuga quo doloremque animi impedit unde.</p>
<button type="button" className="app__explore-button">Order</button>
<button type="button" className="app__order-button">Explore</button>
</div>
</div>
<div className="app__header-carousel-1">
<img className="app__header-carousel-img" alt="pink cupcake" src={images.carousel03} />
<div className="app__header-carousel-content">
<h3 className="app__header-h3">Fresh Baked | Fathers Day</h3>
<h1 className="app__header-h1">CUP CAKES</h1>
<p className="app__header-p">Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque, omnis odit similique dolor ab maiores quae aliquam beatae ad deleniti porro ducimus eum provident fuga quo doloremque animi impedit unde.</p>
<button type="button" className="app__explore-button">Order</button>
<button type="button" className="app__order-button">Explore</button>
</div>
</div>
</div>
</Blur>
)
}
export default Header
here is my css code:
.app__header-carousel{
display: flex;
position: absolute;
top: 10%;
right: 10%;
left: 10%;
overflow: hidden;
}
.app__header-carousel-1{
display: flex;
justify-content: space-between;
height: 80vh;
width: 100%;
margin-right: 3em;
}
.app__header-carousel-img-1{
width: 80%;
}
.app__header-carousel-content{
background: #FDFFD5;
padding: 4rem 10rem 5rem 5rem;
}
.app__header-h3{
color: #76D9D2;
margin-bottom: 0.65rem;
}
.app__header-h1{
color: #F397B0;
font-size: 4rem;
margin-bottom: 0.65rem;
}
.app__header-p{
margin-bottom: 5rem;
}
.app__explore-button{
background: #2D2D2D;
color: beige;
width: 8rem;
margin-right: 0.5rem;
padding: 5px;
border: none;
border-radius: 5px;
cursor: pointer;
}
.app__order-button{
background: #F397B0;
color: #2D2D2D;
width: 8rem;
margin-right: 0.5rem;
padding: 5px;
border: none;
border-radius: 5px;
cursor: pointer;
}
How do I make it appear how I want it to?

Related

css overflow messes with screen width

I'm making a modal where the show modal button when clicked will display the modal right in the middle of the screen and has the exact same width as the main page. but the modal is not as right in the middle as I expected. I think it's because of the overflow style which adds scroll on the right side. how do I solve this?
<body>
<main>
<h1>THIS IS MAIN PAGE</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Beatae
mollitia, repellendus, ratione modi saepe iste ea id qui quia autem nisi
distinctio maxime! Repellat, consequatur. Possimus delectus perferendis,
illo vero perspiciatis tenetur debitis provident itaque rem laborum sint
esse temporibus officia reprehenderit nesciunt laudantium, aspernatur
consectetur quia sapiente exercitationem odit. Molestiae necessitatibus,
dolorem illum expedita minus obcaecati dicta distinctio minima?
</p>
<button>show modal</button>
</main>
<div class="modal-container">
<div class="modal-wrapper">
<h2>THIS IS MODAL PAGE</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Excepturi
nobis nulla iure consequuntur provident? Laborum, suscipit. Aut
similique dolor unde tempora laborum voluptates at cupiditate,
deserunt voluptate illum cum explicabo magnam quibusdam quam facere
consectetur aspernatur adipisci. Magnam, inventore harum.
</p>
</div>
</div>
<script>
document.querySelector("button").addEventListener("click", ()=> document.querySelector(".modal-container").classList.add("show"));
</script>
<script src="script.js"></script>
</body>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
main {
width: min(calc(100% - 3.125rem), 45.625rem);
height: 200vh;
position: relative;
left: 50%;
transform: translate(-50%, -5%);
background-color: aqua;
}
.modal-container {
position: fixed;
inset: 0;
padding: 20vh 0;
background: rgba(0, 0, 0, 0.6);
opacity: 0;
overflow: scroll;
pointer-events: none;
transition: 200ms;
}
.modal-container.show {
opacity: 1;
}
.modal-wrapper {
width: min(calc(100% - 3.125rem), 45.625rem);
height: 150vh;
margin: auto;
padding: 1.75rem 1.25rem;
pointer-events: none;
transition: 200ms;
border-radius: 0.5rem;
background-color: aquamarine;
}
Here is a revised example (scroll and centered).
We didn't have the JS 'close' script so that part is left as provided.
There are a few CSS lines we turned off to resolve the issue, and a few of those lines can be switched back on if needed for you main content. Non-scrollable text in popup will need minor further CSS changes.
document.querySelector("button").addEventListener("click", ()=> document.querySelector(".modal-container").classList.add("show"));
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
main {
/*-- xwidth: min(calc(100% - 0.1rem), 45.625rem); --*/
height: 80vh;
position: relative;
/*-- xleft: 25%; --*/
/*-- xtransform: translate(-0%, -0%); --*/
background-color: aqua;
}
.modal-container {
position: fixed;
/*-- xinset: 0; --*/
/*-- xpadding: 20vh 0; --*/
background: rgba(0, 0, 0, 0.6);
opacity: 0;
/*-- xoverflow: scroll; --*/
pointer-events: none;
transition: 200ms;
/*--add all below--*/
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
}
.modal-container.show {
opacity: 1;
}
.modal-wrapper {
/*-- width: min(calc(100% - 3.125rem), 45.625rem); --*/
/*-- height: 150vh; --*/
margin: auto;
padding: 1.75rem 1.25rem;
pointer-events: auto;
transition: 200ms;
border-radius: 0.5rem;
background-color: aquamarine;
/*--add all below--*/
height: 50%;
width: 50%;
overflow: auto;
position: absolute;
top: 0; left: 0; bottom: 0; right: 0;
}
<main>
<h1>THIS IS MAIN PAGE</h1>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Beatae
mollitia, repellendus, ratione modi saepe iste ea id qui quia autem nisi
distinctio maxime! Repellat, consequatur. Possimus delectus perferendis,
illo vero perspiciatis tenetur debitis provident itaque rem laborum sint
esse temporibus officia reprehenderit nesciunt laudantium, aspernatur
consectetur quia sapiente exercitationem odit. Molestiae necessitatibus,
dolorem illum expedita minus obcaecati dicta distinctio minima?
</p>
<p> </p>
<button>show modal centered</button>
<p> </p>
<button id="myBtn">W3 Open Modal</button>
</main>
<div class="modal-container">
<div class="modal-wrapper">
<h2>THIS IS MODAL PAGE</h2>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Excepturi
nobis nulla iure consequuntur provident? Laborum, suscipit. Aut
similique dolor unde tempora laborum voluptates at cupiditate,
deserunt voluptate illum cum explicabo magnam quibusdam quam facere
consectetur aspernatur adipisci. Magnam, inventore harum.
</p>
</div>
</div>
Here's a good explanation and examples of an absolute centered modal:
codepen

Footer CSS Overflow issue

I'm new to css I created this footer, I have one problem here.
when I try to shrink it the tables disappear and bypass the screen borber and I want it to stay within the screen desired size, would love to know what I did wrong, Thank you.
note: I'm not trying to make it responsive yet I just want to be able to see all the content inside the screen borber.
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>footer trial</title>
</head>
<body>
<footer>
<div class="footer">
<div class="table1 tables">
<h2 class="table-title">ABOUT</h2>
<p class="about">Lorem ipsum dolor sit amet consectetur adipisicing elit.<br> Odit impedit molestiae amet ab maxime saepe qui est<br>, temporibus voluptatibus eaque nihil, ut, omnis sit fugiat cupiditate explicabo. Repellat totam nisi incidunt.<br> Nulla nisi officiis ex, facilis delectus modi, dolor numquam consequuntur aspernatur,<br> harum autem perferendis iure ab! Praesentium, ea corrupti!</p>
</div>
<ul>
<div class="table2 tables">
<h2 class="table-title">INFORMATION</h2>
<nav class="table-links">
<li>table-link1</li>
<li>table-link2</li>
<li>table-link3</li>
</nav>
</div>
<div class="table3 tables">
<h2 class="table-title">CATALOGS</h2>
<nav class="table-links">
<li>table-link1</li>
<li>table-link2</li>
<li>table-link3</li>
</nav>
</div>
<div class="table4 tables">
<h2 class="table-title">SITEMAP</h2>
<nav class="table-links">
<li>table-link1</li>
<li>table-link2</li>
<li>table-link3</li>
</nav>
</div>
<div class="table5 tables">
<h2 class="table-title">CONTACT</h2>
<p class="about">Lorem ipsum dolor sit amet consectetur adipisicing elit.<br> Odit impedit molestiae amet ab maxime saepe qui est<br>, temporibus voluptatibus eaque nihil, ut, omnis sit fugiat cupiditate explicabo. Repellat totam nisi incidunt.<br> Nulla nisi officiis ex, facilis delectus modi, dolor numquam consequuntur aspernatur,<br> harum autem perferendis iure ab! Praesentium, ea corrupti!</p>
</div>
</ul>
</div>
</footer>
<div>
all rights reserved 2022
</div>
</body>
</html>
CSS :
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#300;400;600&display=swap');
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
text-decoration: none;
list-style: none;
}
body {
position: fixed;
width: 100%;
left: 0px;
bottom: 0px;
}
.footer {
background-color: rgb(4, 97, 97);
color: #fff;
gap: 15rem;
padding: 20px;
width: 100%;
display: flex;
justify-content:flex-start;
margin-left: auto;
margin-right: auto;
}
ul {
gap: 7rem;
display: flex;
justify-content:space-evenly;
}
.about {
width: 400px;
text-align: justify;
margin-left: auto;
}
.table1 {
margin-left: 5rem;
margin-bottom: 2rem;
}
.table-title {
color: rgb(4, 224, 151);
line-height: 3rem;
margin-bottom: 1rem;
}
.table-links {
text-align: center;
line-height: 2rem;
font-weight: 400;
}
.table-link {
color: #fff;
text-align: center;
}
.copyright {
background-color: rgb(5, 120, 124);
color: #fff;
padding: 10px;
width: 100%;
display: flex;
justify-content:center;
word-spacing: 0.24rem;
}
Try this if it solve your problem, let me know if anything needed:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
text-decoration: none;
list-style: none;
}
body {
position: fixed;
width: 100%;
left: 0px;
bottom: 0px;
}
.footer {
background-color: rgb(4, 97, 97);
color: #fff;
padding: 20px;
display: flex;
justify-content: space-between;
}
.about {
width: 400px;
text-align: justify;
margin-left: auto;
}
.table1 {
margin-left: 5rem;
margin-bottom: 2rem;
}
.table-title {
color: rgb(4, 224, 151);
line-height: 3rem;
margin-bottom: 1rem;
}
.table-links {
text-align: center;
line-height: 2rem;
font-weight: 400;
}
.table-link {
color: #fff;
text-align: center;
}
.copyright {
background-color: rgb(5, 120, 124);
color: #fff;
padding: 10px;
width: 100%;
display: flex;
justify-content: center;
word-spacing: 0.24rem;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>footer trial</title>
</head>
<body>
<footer>
<div class="footer">
<div class="table1 tables">
<h2 class="table-title">ABOUT</h2>
<p class="about">
Lorem ipsum dolor sit amet consectetur adipisicing elit. <br> Odit impedit molestiae amet ab maxime
saepe qui est <br>, temporibus voluptatibus eaque nihil, ut, omnis sit fugiat cupiditate explicabo.
Repellat totam nisi incidunt.<br> Nulla nisi officiis ex, facilis delectusmodi, dolor numquam
consequuntur aspernatur,<br> harum autem perferendis iure ab! Praesentium, eacorrupti!
</p>
</div>
<div class="table2 tables">
<h2 class="table-title">INFORMATION</h2>
<nav class="table-links">
<li>table-link1</li>
<li>table-link2</li>
<li>table-link3</li>
</nav>
</div>
<div class="table3 tables">
<h2 class="table-title">CATALOGS</h2>
<nav class="table-links">
<li>table-link1</li>
<li>table-link2</li>
<li>table-link3</li>
</nav>
</div>
<div class="table4 tables">
<h2 class="table-title">SITEMAP</h2>
<nav class="table-links">
<li>table-link1</li>
<li>table-link2</li>
<li>table-link3</li>
</nav>
</div>
<div class="table5 tables">
<h2 class="table-title">CONTACT</h2>
<p class="about">Lorem ipsum dolor sit amet consectetur adipisicing elit.<br> Odit impedit molestiae
amet ab maxime saepe qui est<br>, temporibus voluptatibus eaque nihil, ut, omnis sit fugiat
cupiditate explicabo. Repellat totam nisi incidunt.<br> Nulla nisi officiis ex, facilis delectus
modi, dolor numquam consequuntur aspernatur,<br> harum autem perferendis iure ab! Praesentium,
ea corrupti!</p>
</div>
</div>
</footer>
<div>
all rights reserved 2022
</div>
</body>
</html>

when I hover over a div I want it to change the element next to it depending on the number of the nth child that is hovered over

The white line is a <ul>, the boxes are div's inside li's, the circles are created using li:after
I have a ul inside of it are multiple li's and inside of every li a div.
After every li there is a circle created using :after.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
color: white;
}
body {
background: #37a08e;
overflow-x: hidden;
}
.line > ul {
padding-top: 50px;
}
.line ul li {
list-style: none;
position: relative;
width: 6px;
margin: 0 auto;
padding: 50px 0;
background: white;
}
.line ul li:after{
content: '';
position: absolute;
left: 50%;
width: 35px;
height: 35px;
background: #49c1a2;
transform: translateX(-50%);
border-radius: 50%;
transition: background 0.5s ease-in-out, border-radius 0.5s ease-in-out;
}
.line ul li div {
background: #49c1a2;
position: relative;
width: 400px;
padding: 1rem;
border-radius: 10px;
position: relative;
transition: all 0.5s ease-in-out, background-color 0.25s ease-in-out;
}
.line ul li div:hover {
background: #49c1a396;
}
.line ul li div a {
font-size: 1.3rem;
text-decoration: none;
}
.line ul li:nth-child(odd) div {
left: 40px;
}
.line ul li:nth-child(even) div {
right: 434px;
}
<div class="line">
<ul>
<li>
<div>
...........
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nobis
aliquid quaerat quam est officia qui enim nulla quibusdam? Hic
nemo minus nisi doloremque, ducimus inventore eum quisquam aliquam
libero magnam.
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Voluptatibus magni perspiciatis quaerat dolorum laudantium iste
sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Voluptatibus magni perspiciatis quaerat dolorum laudantium iste
sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Voluptatibus magni perspiciatis quaerat dolorum laudantium iste
sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Voluptatibus magni perspiciatis quaerat dolorum laudantium iste
sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Voluptatibus magni perspiciatis quaerat dolorum laudantium iste
sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Voluptatibus magni perspiciatis quaerat dolorum laudantium iste
sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Voluptatibus magni perspiciatis quaerat dolorum laudantium iste
sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
</ul>
</div>
What I want to do is:
When I hover over any of the div's the circle border-radius changes according to its nth number, if it is odd the top right corner border-radius changes if it is even the top left border-radius changes.
I think it should should be something like this:
.line ul li:nth-child(odd) div:hover /* I don't know what to write here */ {
border-radius: 50% 0 50% 50%;
}
.line ul li:nth-child(even) div:hover + /* I don't know what to write here */ {
border-radius: 0 50% 50% 50%;
}
I changed your code a little bit to move the circle from the li to the div, because CSS does not offer a way of traveling back to an ancestor from a descendant. A couple of tweaks to the positioning made it look the same(ish).
Adding the code to change the circle on :hover was therefore easy; just add :hover.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: Arial, Helvetica, sans-serif;
color: white;
}
body {
background: #37a08e;
overflow-x: hidden;
}
.line>ul {
padding-top: 50px;
}
.line ul li {
list-style: none;
position: relative;
width: 6px;
margin: 0 auto;
padding: 50px 0;
background: white;
}
.line ul li div::after {
content: '';
position: absolute;
left: 50%;
width: 35px;
height: 35px;
background: #49c1a2;
transform: translateX(-50%);
border-radius: 50%;
transition: background 0.5s ease-in-out, border-radius 0.5s ease-in-out;
}
.line ul li div {
background: #49c1a2;
position: relative;
width: 400px;
padding: 1rem;
border-radius: 10px;
position: relative;
transition: all 0.5s ease-in-out, background-color 0.25s ease-in-out;
}
.line ul li div:hover {
background: #49c1a396;
}
.line ul li div a {
font-size: 1.3rem;
text-decoration: none;
}
.line ul li:nth-child(odd) div {
left: 40px;
}
.line ul li:nth-child(odd) div::after {
left: -37px;
}
.line ul li:nth-child(even) div {
right: 434px;
}
.line ul li:nth-child(even) div::after {
left: 437px;
}
.line ul li:nth-child(odd) div:hover::after {
border-top-right-radius: 0;
}
.line ul li:nth-child(even) div:hover::after {
border-top-left-radius: 0;
}
<div class="line">
<ul>
<li>
<div>
...........
<p>
Lorem, ipsum dolor sit amet consectetur adipisicing elit. Nobis aliquid quaerat quam est officia qui enim nulla quibusdam? Hic nemo minus nisi doloremque, ducimus inventore eum quisquam aliquam libero magnam.
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus magni perspiciatis quaerat dolorum laudantium iste sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus magni perspiciatis quaerat dolorum laudantium iste sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus magni perspiciatis quaerat dolorum laudantium iste sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus magni perspiciatis quaerat dolorum laudantium iste sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus magni perspiciatis quaerat dolorum laudantium iste sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus magni perspiciatis quaerat dolorum laudantium iste sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
<li>
<div>
<a href="#">
Coming Soon
</a>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptatibus magni perspiciatis quaerat dolorum laudantium iste sit, maiores molestiae doloremque assumenda?
</p>
</div>
</li>
</ul>
</div>

images and text of a flexbox item overlapping absolute positioned div (tooltip)

I'm using display: flex to create panels for my upgrade items. The code looks something like this, I tried to re-create it as best as I could: fidle
. Now I don't understand why are the images overlapping into the tooltip (hover over elements for tooltip to appear). This is very strange, I thought it was because of display: flex, so I tried doing the same thing using grid, no luck. The tooltip has to be position: absolute, especially because I'm planning on adding some javascript so the tooltip box follows the cursor. What is causing this kind of behavior? I'm thinking there's something to do with flexbox/grid and absolute positioning, but I'm not very good at css
Add a z-index value to the .tooltip class.
*
{
margin: 0;
padding: 0;
box-sizing: border-box;
}
p
{
font-size: 24px;
line-height: normal;
}
img
{
border: 1px solid grey;
vertical-align: middle;
}
/* Upgrade wrapper & body */
#upgrades {
height:100%;
box-shadow:0 0 16px 4px rgb(0, 0, 0);
}
.upgrade {
display: flex;
width: 320px;
height: auto;
margin: 1em;
position: relative;
box-shadow: 0 0 8px 2px rgb(0, 0, 0);
}
.upgrade-img {
width: 64px;
height: 64px;
}
.upgrade-body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex-basis: 100%;
padding: 0.5em;
}
/* Upgrade Hover Effects */
.upgrade:hover {box-shadow: 0 0 8px 2px rgb(0, 204, 255);}
.upgrade:hover .tooltip {display: initial;}
/* Tooltip */
.tooltip {
display: none;
width: 256px;
height: auto;
padding: 1em;
position: absolute;
top: 64px;
left: 0;
z-index: 100; /* <------- ADDED Z-INDEX */
background-color: rgb(0, 0, 0);
color: rgb(255, 255, 255);
box-shadow: 0 0 4px 1px rgb(0, 0, 0);
}
<div class="upgrade">
<div class="upgrade-img">
<img src="https://source.unsplash.com/random/64x64">
<div class="tooltip">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam ea sequi recusandae commodi necessitatibus voluptatum, labore libero quasi quos veniam eveniet laborum aspernatur harum iusto, provident itaque hic laboriosam unde!
</div>
</div>
<div class="upgrade-body">
<p>
<img src="https://source.unsplash.com/random/24x24">
100 (dmg)
</p>
<p>
<img src="https://source.unsplash.com/random/24x24">
500 (cost)
</p>
</div>
</div><div class="upgrade">
<div class="image">
<img src="https://source.unsplash.com/random/64x64">
<div class="tooltip">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam ea sequi recusandae commodi necessitatibus voluptatum, labore libero quasi quos veniam eveniet laborum aspernatur harum iusto, provident itaque hic laboriosam unde!
</div>
</div>
<div class="body">
<p>
<img src="https://source.unsplash.com/random/24x24">
100 (dmg)
</p>
<p>
<img src="https://source.unsplash.com/random/24x24">
500 (cost)
</p>
</div>
</div><div class="upgrade">
<div class="image">
<img src="https://source.unsplash.com/random/64x64">
<div class="tooltip">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsam ea sequi recusandae commodi necessitatibus voluptatum, labore libero quasi quos veniam eveniet laborum aspernatur harum iusto, provident itaque hic laboriosam unde!
</div>
</div>
<div class="body">
<p>
<img src="https://source.unsplash.com/random/24x24">
100 (dmg)
</p>
<p>
<img src="https://source.unsplash.com/random/24x24">
500 (cost)
</p>
</div>
</div>

Parallax effect with pseudo elements

I'm building a layout for a clients custom cms system, all the content is built in bootstrap rows which gets printed in a container. The client wanted to be able to make colored rows, i managed this with pseudo elements like this:
.full-row:before {
position: absolute;
top: 0;
left: 50%;
display: block;
width: 100vw;
height: 100%;
background-color: inherit;
content: '';
-moz-transform: translateX(-50%);
-webkit-transform: translateX(-50%);
-o-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
I wanted to take the same approach to make the client able to make parallax rows as well, but I can't get the background image to fill the entire width of the row, or can't seem to position it the right way.
I have made a codepen to see an example where the colored rows work but the parallax effect sucks. Any suggestions on how to fix this?
Here's the code pen
One solution would be to use left: -9999px; right: -9999px; instead of width but by using this method image will stretch. the problem with you HTML structure is you used .row with in container and use position:relative; on it. If you take row out of container your current code will work fine
h3 {
text-transform: uppercase;
color: #fff;
}
header {
padding-top: 80px;
width: 100%;
height: 50vh;
color: #fff;
background-position: center;
background-image: url(http://i68.tinypic.com/2upfuk2.jpg);
background-size: cover;
}
header h1 {
text-transform: uppercase;
}
header .sub-headline {
font-size: 20px;
font-family: cursive;
}
.big-ass-icons {
text-align: center;
}
.big-ass-icons .fa {
font-size: 30px;
}
.big-ass-icons p {
display: block;
margin: 0 auto;
width: 80%;
}
.dummie-col {
height: 800px;
}
/* Helper classes */
.mar-b-30 {
margin-bottom: 30px;
}
.mar-b-40 {
margin-bottom: 40px;
}
.mar-b-50 {
margin-bottom: 50px;
}
.mar-b-60 {
margin-bottom: 60px;
}
.mar-b-70 {
margin-bottom: 70px;
}
.pad-30 {
padding: 30px 0;
}
.pad-40 {
padding: 40px 0;
}
.pad-50 {
padding: 50px 0;
}
.pad-60 {
padding: 60px 0;
}
.pad-70 {
padding: 70px 0;
}
.bg-gray {
background-color: #f9f9f3;
}
/* Row handeling */
.full-row,
.parallax-row {
position: relative;
}
.full-row:before {
position: absolute;
top: 0;
left: 50%;
display: block;
width: 100vw;
height: 100%;
background-color: inherit;
content: '';
-moz-transform: translateX(-50%);
-webkit-transform: translateX(-50%);
-o-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
.parallax-row:before {
position: absolute;
top: 0;
bottom: 0;
left: -9999px;
right: -9999px;
display: block !important;
min-height: 100%;
background-color: rgba(0, 0, 0, .7);
background-repeat: no-repeat;
background-attachment: fixed;
background-size: 100%;
content: '';
}
/* More images to be added */
.image1:before {
background-image: url(http://i68.tinypic.com/2z5m1hh.png);
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"><script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<header class="mar-b-50">
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1>Big A** Image</h1>
<div class="sub-headline">How interesting</div>
</div>
</div>
</div>
</header>
<section class="container">
<div class="row big-ass-icons mar-b-40">
<div class="col-sm-4">
<span class="fa fa-pencil"></span>
<h4>Highly editable</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="col-sm-4">
<span class="fa fa-pencil"></span>
<h4>Highly editable</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
<div class="col-sm-4">
<span class="fa fa-pencil"></span>
<h4>Highly editable</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</div>
</div>
<div class="row bg-gray full-row pad-40">
<div class="col-xs-12">
<h2>This is a colored row</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Incidunt at quos tenetur assumenda laudantium voluptatum laboriosam placeat rem earum, recusandae similique, et vero, doloremque possimus, fugit aliquam magni nulla! Sunt?</p>
</div>
</div>
<div class="row pad-30">
<div class="col-xs-12 text-center">
<h2>This is just a white row</h2>
<p>But it have two columns!</p>
</div>
<div class="col-sm-6">
<p class="text-justify">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis illo sequi consectetur neque dignissimos animi eligendi, ab soluta laudantium minus autem non dolorem ut sint necessitatibus possimus sapiente pariatur voluptatibus. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod dolores perspiciatis doloribus voluptatem libero itaque, sapiente veniam error, autem, aliquid voluptatibus optio dolorum eaque eos quis facere voluptatum sed provident!</p>
</div>
<div class="col-sm-6">
<p class="text-justify">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perspiciatis illo sequi consectetur neque dignissimos animi eligendi, ab soluta laudantium minus autem non dolorem ut sint necessitatibus possimus sapiente pariatur voluptatibus. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quod dolores perspiciatis doloribus voluptatem libero itaque, sapiente veniam error, autem, aliquid voluptatibus optio dolorum eaque eos quis facere voluptatum sed provident!</p>
</div>
</div>
<div class="row parallax-row image1 pad-70">
<div class="col-xs-12 text-center">
<h3>Wuhuuuu, awesome parallax!</h3>
</div>
</div>
<div class="row">
<div class="col-xs-12 dummie-col">
<h2>This is just to make the page long, for the parallax effect</h2>
</div>
</div>
</section>
Maybe a dick move, but im going to answer my own question.
The problem was the background-position units. I used vw to make the size so the positioning should be in the same units.
I added:
background-position: 50vw 0;
I also updated the pen

Resources