Carousel code scrolls across screen #media 800px - html

I was wondering how would I get the boxes not to clash with one another in mobileview.
I have included all the code into mobile view, but certain boxes clash with one another how do I get it not to clash? I have how ever tried using just one line of code but it still would clash into one another.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
.scroll-parent {
position: relative;
width: 100vw;
height: 20rem;
overflow-x: hidden;
}
.scroll-element {
width: inherit;
height: inherit;
position: absolute;
left: 0%;
top: 0%;
animation: primary 15s linear infinite;
}
#keyframes primary {
from {
left: 0%;
}
to {
left: -100%;
}
}
.primary {
animation: primary 15s linear infinite;
}
.secondary {
animation: secondary 15s linear infinite;
}
#keyframes primary {
from {
left: 0%;
}
to {
left: -100%;
}
}
#keyframes secondary {
from {
left: 100%;
}
to {
left: 0%;
}
}
.wrapper{
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
.wrapper .carousel{
display: flex;
justify-content: space-between;
padding: 0 30px;
}
.wrapper .card{
background: #e74c3c;
line-height: 250px;
text-align: center;
color: #fff;
font-size: 90px;
width: 280px;
font-weight: 600;
margin: 20px 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0,0,0,.2);
pointer-events: none;
}
.wrapper .card{
display: flex;
justify-content: space-around;
position: relative;
left: 185px;
animation: carousel 5s linear infinite;
}
.carousel .card .cards{
overflow: hidden;
}
.carousel .card.cards-2{
background: #3498db;
}
.carousel .card.cards-3{
background: #16a085;
}
.carousel .card.cards-4{
background: #2c3e50;
}
.carousel .card.cards-5{
background: #630460;
}
#media only screen and (max-width: 800px){
.scroll-parent {
position: relative;
width: 100vw;
height: 20rem;
overflow-x: hidden;
}
.scroll-element {
width: inherit;
height: inherit;
position: absolute;
left: 0%;
top: 0%;
animation: primary 15s linear infinite;
}
#keyframes primary {
from {
left: 0%;
}
to {
left: -100%;
}
}
.primary {
animation: primary 15s linear infinite;
}
.secondary {
animation: secondary 15s linear infinite;
}
#keyframes primary {
from {
left: 0%;
}
to {
left: -100%;
}
}
#keyframes secondary {
from {
left: 100%;
}
to {
left: 0%;
}
}
.wrapper{
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
}
.wrapper .carousel{
display: flex;
justify-content: space-between;
padding: 0 30px;
}
.wrapper .card{
background: #e74c3c;
line-height: 250px;
text-align: center;
color: #fff;
font-size: 90px;
width: 280px;
font-weight: 600;
margin: 20px 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0,0,0,.2);
pointer-events: none;
}
.wrapper .card{
display: flex;
justify-content: space-around;
position: relative;
left: 185px;
animation: carousel 5s linear infinite;
}
.carousel .card .cards{
overflow: hidden;
}
.carousel .card.cards-2{
background: #3498db;
}
.carousel .card.cards-3{
background: #16a085;
}
.carousel .card.cards-4{
background: #2c3e50;
}
.carousel .card.cards-5{
background: #630460;
}
}
<div class="scroll-parent">
<div class="scroll-element primary">
<div class="wrapper">
<div class="carousel">
<div class="card cards-1">A</div>
<div class="card cards-2">B</div>
<div class="card cards-3">C</div>
<div class="card cards-4">D</div>
<div class="card cards-5">E</div>
</div>
</div>
</div>
<div class="scroll-element secondary">
<div class="wrapper">
<div class="carousel">
<div class="card cards-1">A</div>
<div class="card cards-2">B</div>
<div class="card cards-3">C</div>
<div class="card cards-4">D</div>
<div class="card cards-5">E</div>
</div>
</div>
</div>
</div>

Related

How I need to use after style with tailwind?

I'm using tailwind css, but I want to import some cards that I saw in a video. I know that I can use in class the after: attribute by tailwind, but its a waste of time when I already have it on css.
This cards are working perfectly without tailwind, but when I add the tailwind CSS a part of the :after is not working. I tried adding !important to the attributes but it still doesn't work.
How it shows with tailwind:
How it shows without tailwind:
My code:
.container {
position: relative;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
transform: skewY(-10deg);
}
.container .card {
position: relative;
width: 300px;
height: 400px;
background: white;
transition: 0.5s;
}
.container .card:before {
content: "";
position: absolute;
top: -15px;
left: 0;
width: 100%;
height: 15px;
background-color: #ddc700;
transform-origin: bottom;
transform: skewX(45deg);
transition: 0.5s;
}
.container .card:after {
content: "";
position: absolute;
top: -15px;
left: -15px;
width: 15px;
height: 50%;
background-color: #ddc700;
transform-origin: left;
transform: skewY(45deg);
transition: 0.5s;
border-bottom: 200px solid #d9d9d9;
}
.container .card:hover {
transform: translateY(-40px);
}
.container .card .imgBx {
position: relative;
width: 300px;
height: 200px;
background-color: #c6b200;
display: flex;
align-items: center;
flex-direction: column;
}
.container .card .imgBx img {
max-width: 100px;
}
.container .card .imgBx h3 {
position: relative;
color: black;
margin-top: 10px;
}
.container .card .content {
position: relative;
width: 100%;
height: 200px;
padding: 20px;
color: black;
background: white;
text-align: center;
}
.container .card .content:before {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 400px;
background: linear-gradient(transparent, transparent, gray);
transform-origin: bottom;
transform: skewX(45deg);
transition: 0.5s;
z-index: -1;
}
.container .card:hover .content:before {
transform: translateY(40px) skewX(45deg);
filter: blur(5px);
opacity: 0.5;
}
.container .card:nth-child(1) {
z-index: 3;
}
.container .card:nth-child(2) {
z-index: 2;
}
.container .card:nth-child(3) {
z-index: 1;
}
#media (max-width: 414px) {
body {
overflow: auto;
}
.card {
width: 80%;
margin-bottom: 50px;
}
.container {
padding-top: 200px;
position: relative;
left: 15%;
top: 80%;
}
.container .card {
padding-bottom: 40px;
}
.container .card:hover {
transform: translateY(-25px);
}
}
<head>
<!-- Styles -->
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="flex flex-col h-screen bg-black">
<div class="flex justify-center items-center text-center min-h-screen align-middle py-5 mb-3">
<div class="container">
<div class="card">
<div class="imgBx">
<h3>PUMP & DUMP</h3>
<br/>
<img src="https://i.gyazo.com/4f57be20b3be56b44ee2e6f1f13f4bc4.png" alt=""/>
</div>
<div class="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit quidem
cupiditate ullam animi fuga impedit odio dignissimos ab cum?
</div>
</div>
<div class="card">
<div class="imgBx">
<h3>PREVENTAS</h3>
<br/>
<img src="https://i.gyazo.com/4f57be20b3be56b44ee2e6f1f13f4bc4.png" alt=""/>
</div>
<div class="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit quidem
cupiditate ullam animi fuga impedit odio dignissimos ab cum?
</div>
</div>
<div class="card">
<div class="imgBx">
<h3>PASIVOS</h3>
<br/>
<img src="https://i.gyazo.com/4f57be20b3be56b44ee2e6f1f13f4bc4.png" alt=""/>
</div>
<div class="content">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Velit quidem
cupiditate ullam animi fuga impedit odio dignissimos ab cum?
</div>
</div>
</div>
</div>
</body>
</html>
Your problem is the height was only 50%
You need to make it like this
.container .card:after {
content: "";
position: absolute;
top: -15px;
left: -15px;
width: 15px;
height: 100%; /*Should change here from 50% to 100%*/
background-color: #ddc700;
transform-origin: left;
transform: skewY(45deg);
transition: 0.5s;
border-bottom: 200px solid #d9d9d9;
}

CSS not being applied correctly

Still learning, I've tried everything within my knowledge to make this work.
I'm trying to apply the following:
https://codepen.io/tech-lane/pen/XWbqGyx
<div class="codepen" data-height="201" data-theme-id="light" data-default-tab="css,result" data-user="tech-lane" data-slug-hash="XWbqGyx" data-prefill='{"title":"Pure CSS | FadeIn Text with bars | KeyFrames & Scss","tags":[],"head":" <script src=\"https://kit.fontawesome.com/aa09fdd343.js\"></script>\n\n","scripts":[],"stylesheets":[]}'>
<pre data-lang="html"><div class="container">
<div class="box">
<div class="title">
<span class="block"></span>
<h1>Lane Willmore<span></span></h1>
</div>
<!-- here role goes -->
<h4 class="wordCarousel">
<div>
<!-- Use classes 2,3, or 4 to match the number of words -->
<ul class="flip4">
<li>Oh My!</li>
<li>Swoosh</li>
<li>Cool</li>
<li>Awesome</li>
</ul>
</div>
</h4>
</div>
</div>
</pre>
<pre data-lang="scss" >#import url('https://fonts.googleapis.com/css?family=Lato:300,400|Poppins:300,400,800&display=swap');
* {
margin: 0;
padding: 0;
}
body, html {
overflow: hidden;
}
.container {
width: 100%;
height: 100vh;
background: #232323;
display: flex;
justify-content: center;
align-items: center;
.box {
width: 250px;
height: 250px;
position: relative;
display: flex;
justify-content: center;
flex-direction: column;
.title {
width: 100%;
position: relative;
display: flex;
align-items: center;
height: 50px;
.block {
width: 0%;
height: inherit;
background: #ffb510;
position: absolute;
animation: mainBlock 2s cubic-bezier(.74, .06, .4, .92) forwards;
display: flex;
}
h1 {
font-family: 'Poppins';
color: #fff;
font-size: 32px;
-webkit-animation: mainFadeIn 2s forwards;
-o-animation: mainFadeIn 2s forwards;
animation: mainFadeIn 2s forwards;
animation-delay: 1.6s;
opacity: 0;
display: flex;
align-items: baseline;
position: relative;
span {
width:0px;
height: 0px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
background: #ffb510;
-webkit-animation: load 0.6s cubic-bezier(.74, .06, .4, .92) forwards;
animation: popIn 0.8s cubic-bezier(.74, .06, .4, .92) forwards;
animation-delay: 2s;
margin-left: 5px;
margin-top: -10px;
position: absolute;
bottom: 13px;
right: -12px;
}
}
}
.wordCarousel {
font-size: 36px;
font-weight: 100;
color: #939393;
div {
overflow: hidden;
position: relative;
float: left;
height: 45px;
padding-top: 5px;
margin-top: -10px;
li {
font-family: Serif;
color: #ccc;
font-weight: 250;
padding: 0 5px;
height: 45px;
margin-bottom: 45px;
display: block;
}
}
}
}
}
.flip4 { animation: flip4 15s cubic-bezier(1, 1, 0.32, 1.2) infinite; }
#keyframes flip4 {
0% { margin-top: -360px; }
5% { margin-top: -270px; }
25% { margin-top: -270px; }
30% { margin-top: -180px; }
50% { margin-top: -180px; }
55% { margin-top: -90px; }
75% { margin-top: -90px; }
80% { margin-top: 0px; }
99.99% { margin-top: 0px; }
100% { margin-top: -270px; }
}
#keyframes mainBlock {
0% {
width: 0%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0;
left: 100%;
}
}
#keyframes secBlock {
0% {
width: 0%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0;
left: 100%;
}
}
#keyframes mainFadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#keyframes popIn {
0% {
width: 0px;
height: 0px;
background: #e9d856;
border: 0px solid #ddd;
opacity: 0;
}
50% {
width: 10px;
height: 10px;
background: #e9d856;
opacity: 1;
bottom: 45px;
}
65% {
width: 7px;
height: 7px;
bottom: 0px;
width: 15px
}
80% {
width: 10px;
height: 10px;
bottom: 20px
}
100% {
width: 7px;
height: 7px;
background: #e9d856;
border: 0px solid #222;
bottom: 13px;
}
}
#keyframes secFadeIn {
0% {
opacity: 0;
}
100% {
opacity: 0.5;
}
}
footer {
width: 350px;
height: 80px;
background: #ffb510;
position: absolute;
right: 0;
bottom: -80px;
display: flex;
justify-content: center;
align-items: center;
animation: top 0.8s forwards;
animation-delay: 4s;
span {
display: flex;
align-items: center;
justify-content: center;
font-size: 12px;
color: #232323;
font-family: 'Poppins';
i {
margin-right: 25px;
font-size: 22px;
color: #232323;
animation: icon 2s forwards;
animation-delay: 4s;
opacity: 0;
}
}
}
#keyframes top {
0% {
opacity: 0;
bottom: -80px
}
100% {
opacity: 1;
bottom: 0px
}
}
#keyframes icon {
0% {
opacity: 0;
transform: scale(0.0);
}
50% {
opacity: 1;
transform: scale(1.3) rotate(-02deg);
}
100% {
opacity: 1;
bottom: 0px;
}
}</pre>
</div>
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
to my header in the layout found here:
https://www.w3schools.com/howto/tryit.asp?filename=tryhow_make_a_website
When applying it the CSS doesn't style it correctly. I'm hoping someone here can point me in the right direction.
Try this code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Page Title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
box-sizing: border-box;
}
/* Style the body */
body {
font-family: Arial, Helvetica, sans-serif;
margin: 0;
}
/* Header/logo Title */
.header {
padding: 80px;
text-align: center;
background: #1abc9c;
color: white;
}
/* Increase the font size of the heading */
.header h1 {
font-size: 40px;
}
/* Style the top navigation bar */
.navbar {
overflow: hidden;
background-color: #333;
}
/* Style the navigation bar links */
.navbar a {
float: left;
display: block;
color: white;
text-align: center;
padding: 14px 20px;
text-decoration: none;
}
/* Right-aligned link */
.navbar a.right {
float: right;
}
/* Change color on hover */
.navbar a:hover {
background-color: #ddd;
color: black;
}
/* Column container */
.row {
display: -ms-flexbox;
/* IE10 */
display: flex;
-ms-flex-wrap: wrap;
/* IE10 */
flex-wrap: wrap;
}
/* Create two unequal columns that sits next to each other */
/* Sidebar/left column */
.side {
-ms-flex: 30%;
/* IE10 */
flex: 30%;
background-color: #f1f1f1;
padding: 20px;
}
/* Main column */
.main {
-ms-flex: 70%;
/* IE10 */
flex: 70%;
background-color: white;
padding: 20px;
}
/* Fake image, just for this example */
.fakeimg {
background-color: #aaa;
width: 100%;
padding: 20px;
}
/* Footer */
.footer {
padding: 20px;
text-align: center;
background: #ddd;
}
#import url("https://fonts.googleapis.com/css?family=Lato:300,400|Poppins:300,400,800&display=swap");
.container {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.container * {
margin: 0;
padding: 0;
}
.container .box {
width: 250px;
position: relative;
display: flex;
justify-content: center;
flex-direction: column;
}
.container .box .title {
width: 100%;
position: relative;
display: flex;
align-items: center;
height: 50px;
}
.container .box .title .block {
width: 0%;
height: inherit;
background: #ffb510;
position: absolute;
animation: mainBlock 2s cubic-bezier(0.74, 0.06, 0.4, 0.92) forwards;
display: flex;
}
.container .box .title h1 {
font-family: 'Poppins';
color: #fff;
font-size: 32px;
-webkit-animation: mainFadeIn 2s forwards;
-o-animation: mainFadeIn 2s forwards;
animation: mainFadeIn 2s forwards;
animation-delay: 1.6s;
opacity: 0;
display: flex;
align-items: baseline;
position: relative;
}
.container .box .title h1 span {
width: 0px;
height: 0px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
background: #ffb510;
-webkit-animation: load 0.6s cubic-bezier(0.74, 0.06, 0.4, 0.92) forwards;
animation: popIn 0.8s cubic-bezier(0.74, 0.06, 0.4, 0.92) forwards;
animation-delay: 2s;
margin-left: 5px;
margin-top: -10px;
position: absolute;
bottom: 13px;
right: -12px;
}
.container .box .wordCarousel {
font-size: 36px;
font-weight: 100;
color: #939393;
}
.container .box .wordCarousel div {
overflow: hidden;
position: relative;
float: left;
height: 45px;
padding-top: 5px;
margin-top: -10px;
}
.container .box .wordCarousel div li {
font-family: Serif;
color: #ccc;
font-weight: 250;
padding: 0 5px;
height: 45px;
margin-bottom: 45px;
display: block;
}
.flip4 {
animation: flip4 15s cubic-bezier(1, 1, 0.32, 1.2) infinite;
}
#keyframes flip4 {
0% {
margin-top: -360px;
}
5% {
margin-top: -270px;
}
25% {
margin-top: -270px;
}
30% {
margin-top: -180px;
}
50% {
margin-top: -180px;
}
55% {
margin-top: -90px;
}
75% {
margin-top: -90px;
}
80% {
margin-top: 0px;
}
99.99% {
margin-top: 0px;
}
100% {
margin-top: -270px;
}
}
#keyframes mainBlock {
0% {
width: 0%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0;
left: 100%;
}
}
#keyframes secBlock {
0% {
width: 0%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0;
left: 100%;
}
}
#keyframes mainFadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
#keyframes popIn {
0% {
width: 0px;
height: 0px;
background: #e9d856;
border: 0px solid #ddd;
opacity: 0;
}
50% {
width: 10px;
height: 10px;
background: #e9d856;
opacity: 1;
bottom: 45px;
}
65% {
width: 7px;
height: 7px;
bottom: 0px;
width: 15px;
}
80% {
width: 10px;
height: 10px;
bottom: 20px;
}
100% {
width: 7px;
height: 7px;
background: #e9d856;
border: 0px solid #222;
bottom: 13px;
}
}
#keyframes secFadeIn {
0% {
opacity: 0;
}
100% {
opacity: 0.5;
}
}
/* Responsive layout - when the screen is less than 700px wide, make the two columns stack on top of each other instead of next to each other */
#media screen and (max-width: 700px) {
.row {
flex-direction: column;
}
}
/* Responsive layout - when the screen is less than 400px wide, make the navigation links stack on top of each other instead of next to each other */
#media screen and (max-width: 400px) {
.navbar a {
float: none;
width: 100%;
}
}
</style>
</head>
<body>
<div class="header">
<div class="container">
<div class="box">
<div class="title">
<span class="block"></span>
<h1>Lane Willmore<span></span></h1>
</div>
<!-- here role goes -->
<h4 class="wordCarousel">
<div>
<!-- Use classes 2,3, or 4 to match the number of words -->
<ul class="flip4">
<li>word 1</li>
<li>word 2</li>
<li>word 3</li>
<li>word 4</li>
</ul>
</div>
</h4>
</div>
</div>
</div>
<div class="navbar">
Link
Link
Link
Link
</div>
<div class="row">
<div class="side">
<h2>About Me</h2>
<h5>Photo of me:</h5>
<div class="fakeimg" style="height:200px;">Image</div>
<p>Some text about me in culpa qui officia deserunt mollit anim..</p>
<h3>More Text</h3>
<p>Lorem ipsum dolor sit ame.</p>
<div class="fakeimg" style="height:60px;">Image</div><br>
<div class="fakeimg" style="height:60px;">Image</div><br>
<div class="fakeimg" style="height:60px;">Image</div>
</div>
<div class="main">
<h2>TITLE HEADING</h2>
<h5>Title description, Dec 7, 2017</h5>
<div class="fakeimg" style="height:200px;">Image</div>
<p>Some text..</p>
<p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>
<br>
<h2>TITLE HEADING</h2>
<h5>Title description, Sep 2, 2017</h5>
<div class="fakeimg" style="height:200px;">Image</div>
<p>Some text..</p>
<p>Sunt in culpa qui officia deserunt mollit anim id est laborum consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.</p>
</div>
</div>
<div class="footer">
<h2>Footer</h2>
</div>
</body>
</html>

Text overriding the border?

I am trying to have this sort of this effect. I created an image wrapper and then I created a price tag div which is a child of it. I have set the border-left and border-bottom to a certain amount pixels and then I changed the border-left color to transparent. It creates a triangle similar to above, but when I write something inside the price tag div it just overwrites its part.
#accomodation {
min-height: 1000px;
text-align: center;
padding-top: 100px;
}
#accomodation .head-text {
font-size: 40px;
}
#accomodation .hotel-card .image-wrapper {
width: 100%;
/* overflow: hidden; */
position: relative;
}
#accomodation .hotel-card .image-wrapper img {
width: 100%;
}
#accomodation .hotel-card .image-wrapper .price-tag {
position: absolute;
bottom: 0px;
right: 0;
border-left: 150px solid transparent;
border-bottom: 150px solid #d46e4e;
z-index: 90;
opacity: 0.7;
transition: 0.2s;
color: red;
font-size: 30px;
}
#accomodation .hotel-card .image-wrapper:hover .price-tag {
transform: scale(1.1);
transform-origin: bottom right;
}
<section id="accomodation">
<h3 class="head-text">
Luxury Accomodation
</h3>
<p class="caption-text text-muted">
Duis metus sem, aliquet vitae mi eget, vehicula vehicula enim. In consectetur velit <br> lectus sollicitudin.
</p>
<div class="container mt-5">
<div class="row">
<div class="col-sm-6 col-md-4">
<div class="hotel-card">
<div class="image-wrapper">
<img src="../../photos/hotels/1-accomodation.jpg" alt="">
<div class="price-tag">
<span>900</span>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
If you just want to nest the price tag in the triange:
..
<div class="price-tag">
<span class="price-val">900</span>
</div>
..
.price-tag .price-val {
position: relative;
top: 100px;
}
You should try using transform: rotate() property to get the desired result. Try this code.
#accomodation {
min-height: 1000px;
text-align: center;
padding-top: 100px;
}
#accomodation .head-text {
font-size: 40px;
}
#accomodation .hotel-card .image-wrapper {
width: 100%;
position: relative;
overflow: hidden;
}
#accomodation .hotel-card .image-wrapper img {
width: 100%;
display: block;
}
#accomodation .hotel-card .image-wrapper .price-tag {
position: absolute;
bottom: -100px;
right: -100px;
z-index: 90;
opacity: 0.7;
transition: 0.2s;
color: red;
font-size: 30px;
height: 200px;
width: 200px;
transform: rotate(-45deg);
background: #d46e4e;
}
#accomodation .hotel-card .image-wrapper .price-tag span {
transform: rotate(45deg);
display: inline-block;
margin: 20px;
}
#accomodation .hotel-card .image-wrapper:hover .price-tag {
transform: scale(1.1) rotate(-45deg);
}

How to not show text before hover

I've got an image in the background and I've divided the space into four colored sections. How can I get a section to reduce opacity (which would allow for image in background to show), but also show a colored box with text, WITHOUT the <h2> showing before it is hovered?
This is how I'd like it to look like before hover:
This is how it currently looks like when hovered:
What it currently looks like before hover:
This is my current code:
<style>
html, body {
height: 100%;
padding: 0;
margin: 0;
display: block;
height: 100%;
margin: 0 auto;
max-width: 100%;
background-image: url('../images/4.jpg');
background-repeat: no-repeat;
background-position: center center;
background-size: 100% 100%;
}
.container {
max-width: 100%;
max-height: 100%;
}
.homePage div {
width: 50%;
height: 50%;
float: left;
}
#tRight {
top: 0;
left: 50%;
right: 0;
bottom: 50%;
background: rgba(67, 70, 75, 1);
}
#tRight:hover {
background: rgba(67, 70, 75, .3);
}
#bLeft {
top: 50%;
left: 0;
right: 50%;
bottom: 0;
background: rgba(251, 201, 80, 1);
}
#bLeft:hover {
background: rgba(251, 201, 80, .3);
}
#bRight {
top: 50%;
left: 50%;
right: 0;
bottom : 0;
background: rgba(186, 77, 25, 1);
}
#bRight:hover {
background: rgba(186, 77, 25, .3);
}
.logo {
position: absolute;
top: 30%;
left: 44%;
z-index: 10;
display: block;
}
.logo:hover {
}
#tLeft {
top: 0;
left: 0;
right: 50%;
bottom 50%;
background: rgba(10, 95, 107, 1);
display: inline-block;
position: relative;
}
#tLeft:hover .hover h2{
transition: opacity .75s ease-out;
position: absolute;
top: 15%;
bottom: 15%;
left: 0;
right: 0;
background-color: rgba(153,153,153,.9);
padding: 20px;
font-family: 'Roboto Condensed', sans-serif;
font-weight: 800;
font-size: 2em;
color: white;
opacity: 1;
}
</style>
</head>
<body class="homePage">
<header>
<img src="asset/images/LOGO.png" class="logo">
</header>
<div id="tLeft" alt="1">
<div class="hover">
<h2><strong>Graphic Design</strong> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </h2>
</div>
</div>
<div id="tRight" alt="1">
</div>
<div id="bLeft" alt="1">
</div>
<div id="bRight" alt="1">
</div>
</body>
Hi ritchieRitchie,
I'm not sure if I correctly understand Your question but here comes a litle bit modified your code in snipped with solution.
Generally I hid text before container div is hovered and when container is hovered change background opacity like in other three. And also added same sample texts to all 4 sections.
html,
body {
height: 100%;
padding: 0;
margin: 0;
display: block;
height: 100%;
margin: 0 auto;
max-width: 100%;
background-image: url('https://s10.postimg.org/dibczxad5/mallard0.png');
background-repeat: no-repeat;
background-position: center center;
background-size: 100% 100%;
}
.homePage div {
width: 50%;
height: 50%;
float: left;
}
.logo {
position: absolute;
top: 30%;
left: 44%;
z-index: 10;
display: block;
}
.container {
max-width: 100%;
max-height: 100%;
}
#tLeft {
top: 0;
left: 0;
right: 50%;
bottom 50%;
background: rgba(10, 95, 107, 1);
}
#tLeft:hover {
background-color: rgba(10, 95, 107, .3);
}
#tRight {
top: 0;
left: 50%;
right: 0;
bottom: 50%;
background: rgba(67, 70, 75, 1);
}
#tRight:hover {
background: rgba(67, 70, 75, .3);
}
#bLeft {
top: 50%;
left: 0;
right: 50%;
bottom: 0;
background: rgba(251, 201, 80, 1);
}
#bLeft:hover {
background: rgba(251, 201, 80, .3);
}
#bRight {
top: 50%;
left: 50%;
right: 0;
bottom: 0;
background: rgba(186, 77, 25, 1);
}
#bRight:hover {
background: rgba(186, 77, 25, .3);
}
.hover-container {
position: absolute;
}
.hover-container .hover h2 {
visibility: hidden;
}
.hover-container:hover .hover h2 {
visibility: visible;
transition: opacity .75s ease-out;
position: absolute;
top: 15%;
bottom: 15%;
left: 0;
right: 0;
padding: 20px;
font-family: 'Roboto Condensed', sans-serif;
font-weight: 800;
font-size: 1em;
color: white;
background-color: rgba(153, 153, 153, .9);
opacity: 1;
}
<body class="homePage">
<header>
<img src="asset/images/LOGO.png" class="logo">
</header>
<div id="tLeft" class="hover-container" alt="1">
<div class="hover">
<h2><strong>Graphic Design1</strong> Lorem ipsum</h2>
</div>
</div>
<div id="tRight" class="hover-container" alt="1">
<div class="hover">
<h2><strong>Graphic Design2</strong> Lorem ipsum </h2>
</div>
</div>
<div id="bLeft" class="hover-container" alt="1">
<div class="hover">
<h2><strong>Graphic Design3</strong> Lorem ipsum</h2>
</div>
</div>
<div id="bRight" class="hover-container" alt="1">
<div class="hover">
<h2><strong>Graphic Design4</strong> Lorem ipsum</h2>
</div>
</div>
</body>
If You want to hide element and act like it isn't there use display instead of visibility rule:
.hover-container .hover h2 {
display: none;
}
.hover-container:hover .hover h2 {
display: initial;
}
More informations about difference between display and visibility e.g. on W3Schools page.
Cheers

How to stop an element from appearing outside it's parent division?

I have a division with class "centre" inside another division called "parallaxOne". With my css, if I view it in my laptop, it is showing the divisions properly, but if I view it in a mobile phone, the "centre" division is appearing outside the "parallaxOne" division, and in other browsers, it is appearing in front of the text. Why is this happening, and how do I correct it? Here is my code:
.centre {
position: absolute;
top: 75%;
left: 50%;
transform: translateY(-15%);
width: 0;
height: 140px;
border-left: 6px dashed #0079a5;
}
.arrow {
position: absolute;
top: 0;
left: -6px;
height: 40px;
width: 6px;
background: #007;
animation: animate 2s infinite;
}
.arrow:before {
content: '';
position: absolute;
bottom: 0;
left: -10px;
width: 20px;
height: 20px;
border-bottom: 6px solid #007;
border-right: 6px solid #007;
transform: rotate(45deg);
}
#keyframes animate {
0% {
transform: translateY(0);
opacity: 0.5;
}
50% {
transform: translateY(70px);
opacity: 1;
}
100% {
transform: translateY(140px);
opacity: 0;
}
}
.container {
max-width: inherit;
margin: 0 auto;
background-color: white;
font-size: 24px;
padding: 25px;
}
.parallaxOne {
background: /*url(images/parallax3.jpg); This is an image in my computer*/yellow;
text-align: center;
height: 450px;
padding: 2%;
margin: 2% 0;
}
.parallaxOne h6 {
color: black;
font-size: 200%;
margin: 8% 30%;
padding-top: 100px;
z-index: -1;
}
.parallaxTwo {
background: /*url('images/parallax2.jpg') no-repeat center; This is an image in my computer*/green;
background-size: cover;
background-attachment: fixed;
text-align: center;
height: 600px;
padding: 2%;
}
<html>
<head>
<title>My website</title>
</head>
<body>
<header>
<h1>My website</h1>
</header>
<div class="container">
<div class="parallaxOne">
<h3>Welcome to my website!</h3>
<div class="centre">
<div class="arrow"></div>
</div>
</div>
<div class="parallaxTwo">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
</div>
</div>
</body>
</html
I'm sorry for the long code, but I edited it as much as I could to reproduce the same problem.
Use this tag in your head section for responsive scaling your contents
<meta name="viewport" content="width=device-width, initial-scale=1">