How to transition grid-column property - css

I want to transition the column when I change his position by grid-column property I try but it doesn't work.
Now I have 16 columns I choose one and write a word inside it "Catch me" then I will change the column's position from grid-column: 1; to grid-column: 3; the column will move from 1 to 3 but too fast so how to control that move by transition, I tried to use transition but it is not working with grid-column: 1;
`
.item.position-1-2 {
grid-row: 2;
grid-column: 1;
`
I made many classes for positions when I change the class the position will change in the grid but too fast
I change the class by javascript very well but it is moving too fast and this is bad.
/* The parent */
.container {
gap: 12px;
display: grid;
justify-items: center;
grid-template-rows: repeat(4, 100px);
grid-template-columns: repeat(4, 107px);
transition: 0.25s;
}
/* The child */
.item {
width: 107px;
height: 100px;
line-height: 100px;
transition: 0.25s;
}
/* The positions */
.tile.tile-position-1-1 {
grid-row: 1;
grid-column: 1;
}
.tile.tile-position-1-2 {
grid-row: 2;
grid-column: 1;
}
.tile.tile-position-1-3 {
grid-row: 3;
grid-column: 1;
}
.tile.tile-position-1-4 {
grid-row: 4;
grid-column: 1;
}
.tile.tile-position-2-1 {
grid-row: 1;
grid-column: 2;
}
.tile.tile-position-2-2 {
grid-row: 2;
grid-column: 2;
}
.tile.tile-position-2-3 {
grid-row: 3;
grid-column: 2;
}
.tile.tile-position-2-4 {
grid-row: 4;
grid-column: 2;
}
.tile.tile-position-3-1 {
grid-row: 1;
grid-column: 3;
}
.tile.tile-position-3-2 {
grid-row: 2;
grid-column: 3;
}
.tile.tile-position-3-3 {
grid-row: 3;
grid-column: 3;
}
.tile.tile-position-3-4 {
grid-row: 4;
grid-column: 3;
}
.tile.tile-position-4-1 {
grid-row: 1;
grid-column: 4;
}
.tile.tile-position-4-2 {
grid-row: 2;
grid-column: 4;
}
.tile.tile-position-4-3 {
grid-row: 3;
grid-column: 4;
}
.tile.tile-position-4-4 {
grid-row: 4;
grid-column: 4;
}

Related

CSS Grid items not overlapping when I want them to overlap

I've created a CSS Grid with three rows and two elements on the grid. Both elements will have auto (varying) height. I'd like them to overlap 12% of their total height, but it isn't working. Check it out in the inspector...the image stays in the first row even though I explicitly tell it to go into the second row in my CSS.
Here's my code:
.fancy-slider__slide-grid {
position: relative;
display: -ms-grid;
display: grid;
overflow: visible;
width: 100%;
padding-bottom: 10px;
padding-left: 10px;
grid-auto-columns: 1fr;
grid-column-gap: 0px;
grid-row-gap: 0px;
-ms-grid-columns: minmax(0px, 10%) auto minmax(0px, 18%);
grid-template-columns: minmax(0px, 10%) auto minmax(0px, 18%);
-ms-grid-rows: auto minmax(0px, 12%) auto;
grid-template-rows: auto minmax(0px, 12%) auto;
}
#w-node-a3fb2c4d-077e-feb0-9b26-3d675a06e06a-401c64e4 {
-ms-grid-column: 2;
grid-column-start: 2;
-ms-grid-column-span: 2;
grid-column-end: 4;
-ms-grid-row: 1;
grid-row-start: 1;
-ms-grid-row-span: 2;
grid-row-end: 3;
}
#w-node-_2fd297ea-f918-8546-85bc-4586e222abd8-401c64e4 {
-ms-grid-column: 1;
grid-column-start: 1;
-ms-grid-column-span: 2;
grid-column-end: 3;
-ms-grid-row: 2;
grid-row-start: 2;
-ms-grid-row-span: 2;
grid-row-end: 4;
-ms-grid-row-align: stretch;
align-self: stretch;
}
.card.is--no-move.z-2.is--p-tight {
padding: 30px 35px;
}
.card.is--no-move.z-2 {
position: relative;
z-index: 2;
}
.card {
overflow: hidden;
padding: 45px 10% 40px;
border-radius: 25px;
background-color: #efefef;
box-shadow: 2px 2px 9px 0 rgb(0 0 0 / 20%);
-webkit-transform: translate(0px, 0px);
-ms-transform: translate(0px, 0px);
transform: translate(0px, 0px);
-webkit-transition: all 350ms ease;
transition: all 350ms ease;
}
.img-rounded {
border-radius: 25px;
}
._w-100 {
width: 100%;
}
img {
max-width: 100%;
vertical-align: middle;
display: inline-block;
}
<div class="fancy-slider__slide-grid">
<img src="https://assets.website-files.com/62f407793ac3ad18dd179fd6/6303c9f10f427f8359d47566_ta-guy-1%403x.png" loading="lazy" id="w-node-a3fb2c4d-077e-feb0-9b26-3d675a06e06a-401c64e4" srcset="https://assets.website-files.com/62f407793ac3ad18dd179fd6/6303c9f10f427f8359d47566_ta-guy-1%403x-p-500.png 500w, https://assets.website-files.com/62f407793ac3ad18dd179fd6/6303c9f10f427f8359d47566_ta-guy-1%403x-p-800.png 800w, https://assets.website-files.com/62f407793ac3ad18dd179fd6/6303c9f10f427f8359d47566_ta-guy-1%403x.png 1249w" sizes="(max-width: 479px) 21.421875px, 4vw" alt="" class="img-rounded _w-100">
<div id="w-node-_2fd297ea-f918-8546-85bc-4586e222abd8-401c64e4" class="card is--no-move z-2 is--p-tight">
<p class="mb-3">“Effective psychotherapy can only occur when a client has trust in their therapist on many levels. They must trust the therapist's judgment, their wisdom, their expertise, their compassion, their constancy, and above all their willingness to maintain privacy.”</p>
<div class="fancy-slider__card-footer">
<h5 class="mb-custom-1 small-text">Dr. Bill Whitehead</h5>
<div class="small-text">Founder</div>
</div>
</div>
</div>
Is there any way to achieve what I'm trying to do using CSS Grid? Two elements with unknown height with a 12% overlap of their total combined height? I know I could do this a bunch of other ways (like negative margin, etc.) but I'm really just curious as to why this isn't working so I can understand CSS Grid better.

Grid Layout - Square Photo Wall

I tried to rebuild this Square Grid: how-to-create-a-flexible-square-grid-with-css-grid-layout
It works until I put images into the grid elements: Photo wall
.square-container {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
grid-auto-rows: 1fr;
grid-auto-flow: dense;
}
.square-container::before {
content: '';
width: 100%;
height: 0;
padding-bottom: 100%;
grid-row: 1 / 2;
grid-column: 1 / 1;
}
.square-container > *:first-child {
grid-row: 1 / 1;
grid-column: 1 / 1;
}
/* Just to make the grid visible */
.square-container > * {
background: rgba(0,0,0,0.1);
border: 1px solid grey;
opacity: 0.75;
}
.square-container > *:focus,
.square-container > *:hover {
border: 1px solid blue;
opacity: 1;
}
.square-container img
{ object-fit: contain; width:100%; height:auto; padding:0; margin:0; }
How can I fit the img-elements into the whole size of the grid-element?
.square-container img {
object-fit: cover;
width:100%;
height:100%;
}
creates a rectangle. A fixed grid-auto-rows: 15rem creates a near-square but then I can abstain from the pseudo element.

how do I make an image ocupy the entire grid tile

**[![model image][1]][1]
[1]: https://i.stack.imgur.com/0PfBI.jpg
Here, is my code, I don´t know how to make them look like in the image, I tried with the templates. but it´s in vain, I don't know how to do it. I tried changing the sizes, nothing, I'm stuck
thank you for your help, btw
.heromain-imgs {
display: grid;
grid-gap: 0;
grid-template-columns: 30% % 10% 12% 12% 12% 12% 12%;
grid-template-rows: repeat(3, 1fr)
}
.picture {
width: 100%;
height: 100%;
position: relative;
}
.picasia {
grid-column-start: 1;
grid-column-end: 3;
grid-row-start: 1;
grid-row-end: 4;
}
/* Picture of Asia */
.picture img {
width: 100%;
max-height: 100%;
}
.picture p {
position: absolute;
color: red;
z-index: 10;
left: 50%;
top: 50%;
}
/* */
.picsuda {
grid-column-start: 1;
grid-column-end: 3;
grid-row-start: 3;
grid-row-end: 4;
}
.picafrica {
grid-column-start: 7;
grid-column-end: 8;
grid-row-start: 2;
grid-row-end: 3;
}**
enter image description here

How to create fixed header within css grid

How can I keep the css grid template for a fixed header? When I add position: fixed; to my header div the elements within dont stay in their positions
https://codepen.io/anon/pen/MLwBpW
.container {
display: grid;
margin: 20px;
}
#header {
position: fixed;
width: 100%;
grid-column-start: 1;
}
h1 {
font-size: 2em;
margin: 0;
}
h2 {
margin: 5px;
grid-column-start: 2;
grid-column-end: 3;
}
p{
grid-column-start: 3;
grid-column-end: 3;
font-size: 1.2em;
width: 600px;
}

CSS grid layout: Tag not working on IE 11

i to search my website on IE Browser to see…
<style>
body {
margin: 5px;
display: -ms-grid;
display: grid;
width: 100%;
-ms-grid-columns: 9% 73% 17%;
-ms-grid-rows: 90px 105px 103px 140px 110px 70px;
background-color: #ebf5d7;
}
body > header {
-ms-grid-column: 1;
-ms-grid-column-span: 3;
-ms-grid-row: 1;
-ms-grid-row-span: 2;
background-image: url("/Bilder/f409784856.png");
background-repeat: no-repeat;
padding: 20px;
}
body > nav {
-ms-grid-column: 1;
-ms-grid-column-span: 3;
-ms-grid-row: 2;
margin-top: 30px;
background-color: #d2f5c4;
}
body > #externalLinks {
-ms-grid-column: 1;
-ms-grid-row: 3;
-ms-grid-row-span: 3;
margin-top: 5px;
margin-bottom: 5px;
background-color: #d2f3c6;
}
body > main {
-ms-grid-column: 2;
-ms-grid-column-span: 2;
-ms-grid-row: 4;
background-color: #eaf6e5;
}
body > #furtherInformation {
-ms-grid-column: 3;
-ms-grid-row: 3;
-ms-grid-row-span: 3;
background-color: #d2f3c6;
margin-top: 5px;
margin-bottom: 5px;
}
body > footer {
-ms-grid-column: 1;
-ms-grid-column-span: 6;
-ms-grid-row: 6;
background-color: #99ee7a;
}
how the screenshot to show , all is OK , but when write on my main Tag anything, it to show on the Top corner , not to my main Tag … i don't know because it not to show .
Can Please anyone help me , Thanks !
I "solve" the problem...people help me , to found the answer...
with display: block; on body > main{
body > main {
margin: 5px;
grid-area: main;
display: block;
}

Resources