slide does not comply with grid measurements - html

The id c4 is occupying row 2 / span 1, and the slider should only be taking those row also because its measurements are going from row 2 / span 1, how would I put it into the div slidecourse correctly?
#c4{
background: white;
z-index: 0;
min-height: 200vh;
min-width: 100vw;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
grid-template-rows: 20vh 60vh 5vh 15vh 15vh 85vh;
}
#c4 h1{
grid-column: 1 / -1;
grid-row: 1 / span 1;
text-align: center;
align-self: center;
font-size: 2em;
}
#c4 .textoscurso{
grid-column: 3 / span 3;
grid-row: 2 / span 1;
align-self: center;
}
#c4 .textoscurso p{
align-self: center;
}
#c4 .slidecurso{
grid-column: 7 / -1;
grid-row: 2 / span 1;
}
#c4 .slidecurso slider{
display: inline-block;
width: 100%;
height: 100%;
background: #0ff;
overflow: hidden;
position: absolute;
}
slider > *{
position: absolute;
display: block;
width: 100%;
height: 100%;
background: #0ff;
animation: slide 12s infinite;
overflow: hidden;
}
slide:nth-child(1){
left: 0;
animation-delay: -1s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide:nth-child(2){
animation-delay: 2s;
background-image: url(../img/curso.jpeg);
background-size: cover;
background-position: center;
}
slide:nth-child(3){
animation-delay: 5s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide:nth-child(4){
left: 0;
animation-delay: 8s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide p{
font-family: Comfortaa;
font-size: 70px;
text-align: center;
display: inline-block;
width: 100%;
margin-top: 100px;
color: #fff;
}
#keyframes slide{
0%{left: 100%; width: 100%;}
5%{left: 0%;}
25%{left: 0%;}
30%{left: -100%; width: 100%;}
30.0001%{left: -100%; width: 0%;}
100%{left: 100%; width: 0%;}
}
#c4 .motivos{
background: lightgray;
grid-row: 4 / span 2;
z-index: 10;
}
#c4 .moti-1{
grid-column: 2 / span 2;
}
#c4 .moti-2{
grid-column: 5 / span 2;
}
#c4 .moti-3{
grid-column: 8 / span 2;
}
#c4 .c4-2{
grid-row: 5 / -1;
grid-column: 1 / -1;
background: black;
}
<content id="c4">
<h1>Venha aprender com a gente</h1>
<div class="textoscurso">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus egestas posuere purus malesuada mattis.</div>
<div class="slidecurso">
<slider>
<slide><p>Slide 1</p></slide>
<slide><p>Slide 2</p></slide>
<slide><p>Slide 3</p></slide>
<slide><p>Slide 4</p></slide>
</slider>
</div>
<div class="motivos moti-1"></div>
<div class="motivos moti-2"></div>
<div class="motivos moti-3"></div>
<div class="c4-2"></div>
</content>
The blue slide is not correctly sized as it should and then it goes beyond the limited heigth.
I need it to be exactly inside row 2 / apan 1. Please

You need to add position:relative to the slide element since the child are set to position:absolute. In this case the width/height will be relative to that element and you won't have overflow:
I have also removed some useless properties that may create issues (min-width:100vw for example):
body {
margin:0;
}
#c4 {
background: white;
min-height: 200vh;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
grid-template-rows: 20vh 60vh 5vh 15vh 15vh 85vh;
}
#c4 h1 {
grid-column: 1 / -1;
grid-row: 1 / span 1;
text-align: center;
align-self: center;
font-size: 2em;
}
#c4 .textoscurso {
grid-column: 3 / span 3;
grid-row: 2 / span 1;
align-self: center;
}
#c4 .textoscurso p {
align-self: center;
}
#c4 .slidecurso {
grid-column: 7 / -1;
grid-row: 2 / span 1;
position: relative;
}
#c4 .slidecurso slider {
width: 100%;
height: 100%;
background: #0ff;
overflow: hidden;
position: absolute;
}
slider>* {
position: absolute;
display: block;
width: 100%;
height: 100%;
background: #0ff;
animation: slide 12s infinite;
overflow: hidden;
}
slide:nth-child(1) {
left: 0;
animation-delay: -1s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide:nth-child(2) {
animation-delay: 2s;
background-image: url(../img/curso.jpeg);
background-size: cover;
background-position: center;
}
slide:nth-child(3) {
animation-delay: 5s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide:nth-child(4) {
left: 0;
animation-delay: 8s;
background-image: url(../img/curso.jpg);
background-size: cover;
background-position: center;
}
slide p {
font-family: Comfortaa;
font-size: 70px;
text-align: center;
display: inline-block;
width: 100%;
margin-top: 100px;
color: #fff;
}
#keyframes slide {
0% {
left: 100%;
width: 100%;
}
5% {
left: 0%;
}
25% {
left: 0%;
}
30% {
left: -100%;
width: 100%;
}
30.0001% {
left: -100%;
width: 0%;
}
100% {
left: 100%;
width: 0%;
}
}
#c4 .motivos {
background: lightgray;
grid-row: 4 / span 2;
z-index: 10;
}
#c4 .moti-1 {
grid-column: 2 / span 2;
}
#c4 .moti-2 {
grid-column: 5 / span 2;
}
#c4 .moti-3 {
grid-column: 8 / span 2;
}
#c4 .c4-2 {
grid-row: 5 / -1;
grid-column: 1 / -1;
background: black;
}
<content id="c4">
<h1>Venha aprender com a gente</h1>
<div class="textoscurso">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus egestas posuere purus malesuada mattis.</div>
<div class="slidecurso">
<slider>
<slide>
<p>Slide 1</p>
</slide>
<slide>
<p>Slide 2</p>
</slide>
<slide>
<p>Slide 3</p>
</slide>
<slide>
<p>Slide 4</p>
</slide>
</slider>
</div>
<div class="motivos moti-1"></div>
<div class="motivos moti-2"></div>
<div class="motivos moti-3"></div>
<div class="c4-2"></div>
</content>

Related

How to separate overlays on a hexagon grid

I have a hexagon grid and have added an overlay but the issue is all of hexagons show the same overlay. Want to see about how to separate so each hexagon will have its own overlay and I can place different words/phrases on each one. My end goal is for each hexagon to not only say something different but link to different pages. Thank ya!!!
CSS:
img {
width: 100%;
height: auto;
display: block;
object-fit: cover;
}
.hexagon-gallery {
margin: auto;
margin-top: 50px;
max-width: 1000px;
display: grid;
grid-template-columns: repeat(8, 1fr);
grid-auto-rows: 200px;
grid-gap: 14px;
padding-bottom: 50px;
}
.hex {
display: flex;
position: relative;
width: 240px;
height: 265px;
background-color: #424242;
-webkit-clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}
.hex:first-child {
grid-row-start: 1;
grid-column: 2 / span 2;
}
.hex:nth-child(2) {
grid-row-start: 1;
grid-column: 4 / span 2;
}
.hex:nth-child(3) {
grid-row-start: 1;
grid-column: 6 / span 2;
}
.hex:nth-child(4) {
grid-row-start: 2;
grid-column: 1 / span 2;
}
.hex:nth-child(5) {
grid-row-start: 2;
grid-column: 3 / span 2;
}
.hex:nth-child(6) {
grid-row-start: 2;
grid-column: 5 / span 2;
}
.hex:nth-child(7) {
grid-row-start: 2;
grid-column: 7 / span 2;
}
.hex:nth-child(8) {
grid-row-start: 3;
grid-column: 2 / span 2;
}
.hex:nth-child(9) {
grid-row-start: 3;
grid-column: 4 / span 2;
}
.hex:nth-child(10) {
grid-row-start: 3;
grid-column: 6 / span 2;
}
.container {
position: absolute;
width: 50%;
}
.overlay {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
height: 100%;
width: 100%;
opacity: 0;
transition: .5s ease;
background-color: #008CBA;
}
.container:hover .overlay {
opacity: 1;
}
.text {
color: white;
font-size: 20px;
position: absolute;
top: 15%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
text-align: center;
}
a:link, a:visited {
background-color: #f44336;
color: white;
padding: 15px 25px;
text-align: center;
text-decoration: none;
display: inline-block;
position: absolute;
right: 60px;
top:130px;
}
a:hover, a:active {
background-color: red;
}
<div class="container">
<section class="hexagon-gallery">
<div class="hex"><img src="img/hiw.png"> <div class="overlay">
<div class="text">Hello World</div>
This is a link
</div></div>
<div class="hex"><img src="img/wc.png"></div> <div class="overlay">
<div class="text">Hello World</div>
This is a link
</div>
<div class="hex"><img src="img/sc.png"> <div class="overlay">
<div class="text">Hello World</div>
This is a link
</div></div>
<div class="hex"><img src="img/ew.png"> <div class="overlay">
<div class="text">Hello World</div>
This is a link
</div></div>
</section>
</div>

Margin-bottom not working for image elements

The divs inside mini_projects_11 are all attached to each other, but I am providing margin-bottom. I've tried attaching margin to 'a' and also assigning 'a' display:block, but still isn't working.
style.scss
#mini_projects {
background-color: rgba(0,0,0,.85);
grid-column: 1/4;
grid-row: 1/7;
height: 100vh;
width: 100vw;
&1{
display: grid;
height: 100vh;
width: 100vw;
grid-template-columns: 20% 60% 20%;
grid-template-rows: 20% 60% 20%;
background-color: $mainDOrange;
clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
&1{
grid-column: 2/3;
grid-row: 2/3;
overflow-x: hidden;
overflow-y: scroll;
display: grid;
grid-template-columns: 50% 50%;
grid-template-rows: 40% 40%;
grid-auto-rows: 40%;
div{
justify-self: center;
height: 100%;
width: 90%;
margin-bottom:5rem; (NOT WORKING)
text-align: center;
a{
text-decoration: none;
display: block;
img{
width: 100%;
height: 100%;
border-radius: 50%;
}
span{
z-index: 1;
display: block;
color: white;
font-size: 2.5rem;
transform: translate(0rem,5rem);
}
}
}
}
}
}
#mini_projects {
background-color: rgba(0, 0, 0, .85);
grid-column: 0.25;
grid-row: 0.1428571429;
height: 100vh;
width: 100vw;
}
#mini_projects1 {
display: grid;
height: 100vh;
width: 100vw;
grid-template-columns: 20% 60% 20%;
grid-template-rows: 20% 60% 20%;
background-color: orange;
clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
}
#mini_projects11 {
grid-column: 0.6666666667;
grid-row: 0.6666666667;
overflow-x: hidden;
overflow-y: scroll;
display: grid;
grid-template-columns: 50% 50%;
grid-template-rows: 40% 40%;
grid-auto-rows: 40%;
}
#mini_projects11 div {
justify-self: center;
height: 100%;
width: 90%;
margin-bottom: 5rem;
/* (NOT WORKING) */
text-align: center;
}
#mini_projects11 div a {
text-decoration: none;
display: block;
}
#mini_projects11 div a img {
width: 100%;
height: 100%;
border-radius: 50%;
}
#mini_projects11 div a span {
z-index: 1;
display: block;
color: white;
font-size: 2.5rem;
transform: translate(0rem, 5rem);
}
<div id="mini_projects">
<div id="mini_projects1">
<div id="mini_projects11">
<div id="omnifood"><span>Omnifood</span><img src="img/omnifood.png" alt=""></div>
<div id="natours"><span>Natours</span><img src="img/natours.png" alt=""></div>
<div id="nexter"><span>Nexter</span><img src="img/nexter.png" alt=""></div>
<div id="trillo"><span>Trillo</span><img src="img/trillo.png" alt=""></div>
</div>
</div>
nevermind, I just fixed it with row-gap in #main_projects_11 .
row-gap:2rem;

Change the width of black block

.box {
width: 300px;
height: 30px;
display: flex;
justify-content: center;
flex-direction: column;
}
.block1 {
width: 10%;
height: inherit;
background: black;
position: absolute;
animation: boxincrease 2s cubic-bezier(0.74, 0.86, 0.4, 0.92) forwards;
}
#keyframes boxincrease {
0% {
width: 10%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0%;
left: 100%;
}
}
<div class="nameintro">
<div class="box">
<div class="block1"></div>
<h1>XYZ<span>.</span></h1>
</div>
<div class="role">
<div class="block2"></div>
<p>AMATEUR ARTIST</p>
</div>
</div>
I want to change the width of the black block as it is covering the whole width of the page i want it to cover only the part where xyz written.
I want to make something like this without using scss.
https://www.youtube.com/watch?v=7d2XsPSjjjI
You need to set the "box" width to fit content so that it doesn't exceed the text and set the position relative to it.
.box {
width: fit-content;
height: 30px;
display: flex;
justify-content: center;
flex-direction: column;
position: relative;
}
.block1 {
height: inherit;
background: black;
position: absolute;
animation: boxincrease 2s cubic-bezier(0.74, 0.86, 0.4, 0.92) forwards;
}
#keyframes boxincrease {
0% {
width: 10%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0%;
left: 100%;
}
}
<div class="nameintro">
<div class="box">
<div class="block1"></div>
<h1>XYZ<span>.</span></h1>
</div>
<div class="role">
<div class="block2"></div>
<p>AMATEUR ARTIST</p>
</div>
</div>
Adjust the values in your keyframe,
.box {
width: 300px;
height: 30px;
display: flex;
justify-content: center;
flex-direction: column;
}
.block1 {
width: 10%;
height: inherit;
background: black;
position: absolute;
animation: boxincrease 0.8s cubic-bezier(0.74, 0.86, 0.4, 0.92) forwards;
}
#keyframes boxincrease {
0% {
width: 10%;
left: 0;
}
50% {
width: 15%;
left: 0;
}
100% {
width: 0%;
left: 15%;
}
}
<div class="nameintro">
<div class="box">
<div class="block1"></div>
<h1>XYZ<span>.</span></h1>
</div>
<div class="role">
<div class="block2"></div>
<p>AMATEUR ARTIST</p>
</div>
</div>
I would use a grid and put the blocks in the same grid column example;
.nameintro {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-auto-rows: minmax(30px, auto);
}
.box {
display: grid;
justify-content: center;
grid-template-columns: 300px;
grid-auto-rows: minmax(30px, auto);
}
.one {
grid-column: 1 / 1;
grid-row: 1;
}
.two {
grid-column: 1 / 1;
grid-row: 1;
align-self: center;
justify-self: center;
}
.role {
grid-column: 2 / 2
}
.block1 {
background-color: black;
animation: boxincrease 2s cubic-bezier(0.74, 0.86, 0.4, 0.92) forwards;
}
#keyframes boxincrease {
0% {
width: 10%;
left: 0;
}
50% {
width: 100%;
left: 0;
}
100% {
width: 0%;
left: 100%;
}
}
<div class="nameintro">
<div class="box">
<div class="one block1"></div>
<h1 class="two">XYZ<span>.</span></h1>
</div>
<div class="role">
<div class="block2"></div>
<p>AMATEUR ARTIST</p>
</div>
</div>

Without text these div elements are fine but when i put text in the boxes it changes the box [duplicate]

This question already has answers here:
CSS vertical alignment of inline/inline-block elements
(4 answers)
Closed 2 years ago.
So I have this:
Then I add text:
.front {
background: #e0e0e0;
width: 100%;
height: 200px;
border: 5px solid black;
}
#keyframes animateonload {
0% {
top: 0;
left: 200px;
background: #80ed9d;
}
25% {
top: 200px;
left: 200px;
background: #9f80ed;
}
50% {
top: -101px;
left: -900px;
background: #eda380;
}
75% {
top: 900px;
left: 200px;
background: #3e6b66;
}
100% {
top: 450px;
left: 100px;
background: #ccfa8c;
}
}
body {
animation-name: animateonload;
animation-duration: 5s;
animation-iteration-count: 1;
position: relative;
width: 100%;
height: auto;
}
.divver3 {
width: 33%;
height: 600px;
background: #faa68c;
font-size: 20px;
display: inline-block;
grid-column: 3;
grid-row: 1;
}
.divver2 {
width: 33%;
height: 600px;
background: #faa68c;
font-size: 20px;
display: inline-block;
grid-column: 2;
grid-row: 1;
}
.divver1 {
width: 33%;
height: 600px;
background: #faa68c;
font-size: 20px;
display: inline-block;
grid-column: 1;
grid-row: 1;
}
.div {
width: 100%;
height: auto;
}
.divver1 h1 {
text-align: center;
margin: 0;
}
<div class="div">
<div class="divver1">
<h1> Price option 1 </h1>
</div>
<div class="divver2">
</div>
<div class="divver3">
</div>
</div>
</div>
So why does my thing do this when I add text to the box? I have no answer, and how can this do this?
Is this just a flaw in my code in the .divver?
The code contains the full grid layout, and correct <div> positioning so why hasn't this worked?
Is it that I need padding/margins? Or does the width need to vary each box? Please help me.
Thank you,
Ring Games
display: inline-block will, by default, vertically align elements according to their baseline.
When they're empty, the baseline is just the bottom of the element.
But when you add some text, the baseline is the baseline of that text. Notice how the bottom of the text is now aligned to the bottom of the other elements.
In this case you may be better off with display: grid;, display: flex; or maybe even column-count: 3; to achieve your layout, but if you're stuck with what you've got then adding vertical-align: top; should do the trick.
Try making your position absolute like this:
.front {
background: #e0e0e0;
width: 100%;
height: 200px;
border: 5px solid black;
}
#keyframes animateonload {
0% {top: 0; left: 200px; background: #80ed9d;}
25% {top: 200px; left: 200px; background: #9f80ed;}
50% {top: -101px; left: -900px; background: #eda380;}
75% {top: 900px; left: 200px; background: #3e6b66;}
100% {top: 450px; left: 100px; background: #ccfa8c;}
}
body {
animation-name: animateonload;
animation-duration: 5s;
animation-iteration-count: 1;
position: relative;
width: 100%;
height: auto;
}
.divver3 {
width: 33%;
height: 600px;
background: #faa68c;
font-size: 20px;
display: inline-block;
grid-column: 3;
grid-row: 1;
}
.divver2 {
width: 33%;
height: 600px;
background: #faa68c;
font-size: 20px;
display: inline-block;
grid-column: 2;
grid-row: 1;
}
.divver1 {
width: 33%;
height: 600px;
background: #faa68c;
font-size: 20px;
display: inline-block;
grid-column: 1;
grid-row: 1;
position: absolute;
}
.div {
width: 100%;
height: auto;
}
.divver1 h1 {
text-align: center;
margin: 0;
}
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title> Ring Games - Official Site</title>
</head>
<body>
<div class="div">
<div class="divver1">
<h1>this is some text</h1>
</div>
<div class="divver2">
</div>
<div class="divver3">
</div>
</div>
</body>
</html>

Is it possible to put divs in this way?

One color on image symbolizes one div. Is it possible to put first div under second, second under third, third under fourth, and fourth under first?
Is it possible to do with pure CSS (without SVG/image etc.)?
You can also play with transform:rotate
div {
position: relative;
transform-style: preserve-3d;
perspective: 1000px;
display: grid;
grid-template-columns: 300px 300px;
grid-template-rows: 200px 200px;
}
div p {
margin: 2em;
}
div :nth-child(1),
div :nth-child(2) {
background: lightblue;
margin: 0 3em;
grid-column: 2;
grid-row: 1 / span 2;
}
div :nth-child(1) {
background: black;
grid-column: 1;
color: white;
}
div :nth-child(3),
div :nth-child(4) {
background: yellow;
margin: 2em 1em;
grid-column: 1 / span 2;
grid-row: 1;
}
div :nth-child(4) {
background: lightgreen;
grid-row: 2;
}
div :nth-child(1) {
transform: rotateX(1deg)
}
div :nth-child(2) {
transform: rotateX(-1deg)
}
<div>
<p>one</p>
<p>two</p>
<p>three</p>
<p>four</p>
</div>
Nope - tis is impossible (at least by using z-index layers) - however you can use some trick to get this effect e.g use 5 div-s:
.boxA {
position: absolute;
width: 97px;
height: 175px;
background: black;
left: 17px;
z-index: 2;
}
.boxB {
position: absolute;
width: 248px;
height: 60px;
background: yellow;
top: 32px;
z-index: 3;
}
.boxC {
position: absolute;
width: 248px;
height: 60px;
background: #00ff7b;
top: 112px;
z-index: 1;
}
.boxD {
position: absolute;
width: 62px;
height: 175px;
background: cyan;
left: 157px;
z-index: 0;
}
.boxE {
position: absolute;
width: 62px;
height: 100px;
background: cyan;
left: 157px;
z-index: 4;
}
<div class="boxA"></div>
<div class="boxB"></div>
<div class="boxC"></div>
<div class="boxD"></div>
<div class="boxE"></div>