I want to create a grid list that dynamically works with Angular 6 *ngFor directive. My question/problem is that I have Array of 105 objects in firebase. Structure of object is like:
{src: 'some url', alt: 'title'}
Now I have 2 different type of photos, one horizontal, one vertical. I want to create auto filling section that will fill up empty space, I know that can be do with grid list in css3. But how to connect that with :
<div class="row">
<div class="imageGallery1 " *ngFor="let image of galleryList">
<a [href]="image.src" [title]="image.alt">
<img [src]="image.src" [alt]="image.alt" style="max-width: 300px; max-height: 300px; object-fit: contain; padding-right: 20px;" />
</a>
</div>
styles are only for create temp thumbnails
Is there any way to check what kind of type each photo has? (vertical, horizontal) and later auto sortu out them ? Please point me if there's any other way to do this
I found solution on youtube course of grid css.
https://www.youtube.com/watch?v=t6CBKf8K_Ac
css:
.row {
display: grid;
grid-gap: 5px;
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
grid-template-rows: auto;
grid-auto-flow: dense;
}
.imageGallery1 {
text-align: center;
position: relative;
& img {
width: 100%;
max-height: 510px;
height: 251px;
}
}
.vertical {
grid-row: span 2;
& img {
height: 510px;
}
}
and now each vertical photo has its own class with grid-row: span 2;
Maybe i could help someone
Related
Having a fixed-height, variable width grid of 'oversized' images (simplified: 2 images only, different only by orientation. In reality, these have various sizes and aspect ratios) inside a flex container (simplified: body) yields different results depending on the browser:
body {
display: flex;
}
.grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: 50px;
}
.grid>img {
width: 100%;
max-height: 100%;
border: 1px solid red;
object-fit: cover;
}
<body>
<div class="grid">
<img alt="portrait"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHEAAACWCAMAAADe4ZfYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAALHUExURf/////j4/+ysv+EhP9YWP9DQ/8+Pv9NTf9jY/93d/+Jif+Skv+Zmf+env/m5v+goP9dXf89Pf9XV/+Li/+4uP/l5f/7+/+hof/f3/+Kiv9BQf9SUv+Wlv/b2//9/f/a2v9RUf/z8/9GRv9VVf+qqv/19f9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IVruGmWGzHi1WKsz84k+5WiiWmx3itlXIVpLzM6+sr5t+nPVIrQszFVLOrPPujOTt/QcrT3v2+aDD2PtHnSpQluL9Y9C4GrZx9qqEVbrol1j85G1NTas6mMZVyQRr99aY3X9FvNUSrnajX0SJFsb+CkCH30ttoNsJeVnSHxSaLHPidadrkXSIJVW8yrlyV+w1uov7K7SZR2uL0Vr9X5le01z5JdQYEisVs/XAlaAMxYKDInUWv6NkPXyite3eLUAer8TtLtA2Yvx/Q+C+PGnn5F0+QXfWZ9fNwvbudKEJITyvWL2+fgt7YzTYZaIXVE5+43K2qYuIOMeMsZK99rbcdf5G6JoNnba2J/4O91W653FNRZ3cwb/QKQhJOPeVwUpdworSLmvWqFsvcvYLnTXn3+Zqax9hv42sGf/nwacOYiUf+EghmN/D4KxfwHWVQ8n8y9KWgAAAABJRU5ErkJggg==" />
</div>
</body>
The expected result (both same size, aspect ratio preserved, cover) in Chrome 108.x:
and the result in FF 108.x:
I tried playing with various 'settings' (such as object-fit: cover, aspect-ratio: 1 / 1, nesting the images / the grid in divs with e.g. display: block, using reset.css or normalize.css, ...) but could not find a working solution.
What do I need to do to get the Chrome behaviour in FF?
Since width of 50px seems to matter, use grid-template-columns instead of -rows, and for the image use aspect-ratio: 1; and if you want object-fit: cover; to prevent image distortions
.grid {
display: grid;
grid-template-columns: 50px;
}
.grid>img {
width: 100%;
aspect-ratio: 1;
object-fit: cover;
border: 1px solid red;
}
<div class="grid">
<img alt="width of img > height of row" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkBAMAAACCzIhnAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAADUExURf///6fEG8gAAAAJcEhZcwAADsEAAA7BAbiRa+0AAAAcSURBVFjD7cEBDQAAAMKg909tDwcEAAAAAByoARPsAAFwJuooAAAAAElFTkSuQmCC"
/>
</div>
Let's say there's a scenario where you have a grid with 3 columns and 2 rows, something like this:
<div class="wrapper">
<div class="content"></div>
<div class="info"></div>
</div>
Elements have these simple styles:
.wrapper {
position: relative;
display: grid;
grid-template-columns: 1fr 1fr 400px;
grid-template-rows: 400px auto;
}
.content {
grid-column: 1/4;
grid-row: 1/3;
}
.info {
position: absolute;
top: 0;
right: 0;
width: 400px;
height: 400px;
}
This would fill the contents of .content element to the whole .wrapper available space and the .info element would be positioned absolute over in the right top corner.
Is it possible to display the contents of .content into everything except to top right cell - like this (red is where the content is):
Working with CSS grid layout, my page display a slight overflow in the X axis.I have deleted the grid and then the overflow disappears. When I reset the grid the overflow reappears. So I'm wondering why that occurs ?
I have tried to set the max-width to 100vw or less : doesn't work
I have tried to set margin and padding to zero or less: doesn't work
even overflow-x °as a workaround° doesn't work
I have try to set grid column gutters to 0: doesn't work
I have reset again explicitly for my React Component, the div element with margin and padding to zero : doesn't work.
I have tried to set a grid_container with max-width to 100vw: doesn't work
I have tried to change div in span elements: doesn't work
In fact I have two grids, one on a layout level, another on the layouts elements level.
Here an image of my current situation:
As you can see, seems I have two problems:
a column occupies all the page width space and the secon column on the overflow
a structural overflow due to some weird behaviors.
Here my layout.js :
export default ({children, title = 'title' }) => (
<Provider store={store}>
<div className={style.layout}>
<Head>
<title>{ title }</title>
<meta charSet='utf-8' />
<meta name='viewport' content='initial-scale=1.0, width=device-width' />
</Head>
<HeadComponent/>
<div className={style.signature}>
signature
</div>
<div className={style.social_medias}>
social_medias
</div>
<div className={style.children}>
{children}
</div>
<Footer className={style.footer}/>
</div>
</Provider>
)
here my layout.css :
html, body{
margin : 0;
width: 100vw;
height: 100%;
}
.layout{
width: 100%;
min-height: 100%;
margin:auto;
text-align: justify;
text-justify: inter-word;
display : grid;
grid-template-areas:
"header header"
"signature social_medias"
"children children"
"footer footer" ;
grid-template-rows: 44px 0.5fr 1fr auto ;
grid-template-columns: 1fr 1fr;
}
.centerbar{
width: 100vw;
background-color: orange ;
display: flex;
align-items: center;
justify-content: center;
}
.headbar{
grid-area: header;
display :grid ;
z-index:170;
margin: auto;
width:100vw;
position:fixed;
align-self: center;
justify-self: center;
}
.signature{
grid-area: signature;
}
.logo:hover{
color: black;
}
.social_medias{
grid-area: social_medias;
}
/*** children ***/
.children{
background-color: pink;
grid-area: children;
height: 100%;
}
/*** footer ***/
/*
.footer{
grid-area: footer;
display: grid;
width: 100vw;
margin-top: 10em;
} */
Here my css file :
.footer_grid{
grid-area: footer;
height: 100vh;
max-width: 100vw;
padding:0;
margin-top: 10vh;
overflow-x:hidden;
display:grid;
grid-template-areas:
" let_chat social_medias"
" citations email_form " ;
grid-template-columns: 2.5fr 1fr ;
grid-template-rows: auto auto;
background-color: white;
border-top: solid;
border-width: 1px;
padding-top: 25px;
grid-column-gap: 0;
background-color: rgb(255, 255, 157);
}
.let_chat{
grid-area: let_chat;
font-family: "Moonlight";
font-size: 90pt;
display : flex;
justify-content: center;
align-items: center
}
.social_medias{
grid-area: social_medias;
display : flex;
justify-content: end;
align-items: start;
}
.citations{
grid-area: citations;
}
.email_form{
grid-area: email_form;
}
Here my React.js file:
import React from 'react'
import style from "./Footer.css";
export default () => {
return (
<span className={style.footer_grid}>
<div className={style.let_chat}>
let chat
</div>
<div className={style.social_medias}>
social media
</div>
<div className={style.citations}>
citations
</div>
<div className={style.email_form}>
email form
</div>
</span>
)
}
I'm wondering what is wrong. If someone has any hint, would be great.
Include box-sizing: border-box; in .footer_grid. Basically what it does is that includes the border into the width. Otherwise, your grid will be wider than 100vw, which brings the horizontal scroller.
I'm having some troubles like you with Grids and the horizontal scrollbar that appears. I managed to do this but I dont really know how it works.
I tried to created a one column page for a fullscreen hero image so I use:
main{
display:grid;
grid-template-columns: 100vw;
grid-template-rows:15vh 85vh;
grid-template-areas:
"header"
"hero";
width: 100%;
}
And it create an horizontal scrollbar, but if I use this:
grid-template-columns: minmax(0,100vw);
It dissapears the horizontal scrollbar, somewhere I read that it have to do with the default value of auto somewhere. Hope it help!
I'm trying to create a layout with CSS grid that looks like this (ie: a section on the left that has a fixed width and height, a section at the top which takes up the minimum height possible, and a section underneath that which takes up all the remaining space):
However, what I'm getting is this (where the space at the bottom of the orange section is equal to the grid-row-gap):
I'm wondering why the fr is being calculated like this instead of compensating for the grid gap?
(In my project I can fix this issue by adding a margin to the bottom right element instead of using grid-row-gap, but I'd like to know if there's something I'm misunderstanding about CSS grid)
span {
display: inline-block;
}
.grid {
border: 1px solid black;
display: inline-grid;
grid-template-columns: repeat(2, auto);
grid-template-rows: auto 1fr;
grid-row-gap: 1rem;
}
.left {
background: orange;
height: 120px;
width: 120px;
grid-row: 1/span 2;
}
.right-top {
background: yellow;
height: 20px;
width: 300px;
}
.right-bottom {
background: blue;
}
<div class="grid">
<span class="left"></span>
<span class="right-top"></span>
<span class="right-bottom"></span>
</div>
I'm experimenting with CSS Grids, and this is the layout I'm building:
.grid {
display: grid;
align-items: center;
grid-template-columns: 1fr 4rem 1fr;
grid-template-rows: 1rem 1fr 1rem;
max-width: 900px;
margin: 0 auto;
}
.text {
/*
// Ideally, this should be
grid-area: text
*/
grid-column: 1 / 3;
grid-row: 2 / 3;
/* Fix z-index */
position: relative;
padding: 4rem;
background-color: #fff;
}
.image {
/*
// Ideally, this should be
grid-area: image;
*/
grid-column: 2 / 4;
grid-row: 1 / -1;
background-color: lightgray;
padding: 1rem;
/* Center das image */
display: flex;
justify-content: center;
}
/* Basic body */
body {
background-color: #fafafa;
font-family: sans-serif;
padding: 2rem;
}
img {
max-width: 100%;
height: auto;
}
<div class="grid">
<div class="text">One morning, when bobby woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his leg like back, and if he lifted his head a little he could see his brown belly, slightly domed and divided by arches into
stiff sections.
</div>
<div class="image">
<img src="http://unsplash.it/400/400" />
</div>
</div>
(best to preview in full page...)
What I'd like to avoid:
.text and .image both currently are using grid-column: * / *; syntax, instead I'd like to use grid-area: text and grid-area: image;.
Is it possible to define grid-template-{columns|rows} as overlapping areas? I tried using second way of defining grid areas
, but that didn't seem to work.
Looks like you can't do [a-start] [b-start] [a-end] [b-end] in that syntax, or at least I didn't manage to.
So - Is there any way to create an overlapping grid using named areas?
I'm trying to use the named areas for convenience purely - so that it's easier to reason about the responsive layout code, instead of repeating myself multiple times in media queries.
Edit
Found the answer because of #vals answer below.
This seemed to work just fine, I probably made a syntax error in my previous attempt somewhere:
grid-template-columns: [text-start] 1fr [image-start] 4rem [text-end] 1fr [image-end];
grid-template-rows: [image-start] 1rem [text-start] 1fr [text-end] 1rem [image-end];
At least in a more basic layout, it seems to work for me:
.container {
border: solid 1px green;
height: 180px;
width: 300px;
display: grid;
grid-template-columns: [left-start] 100px [right-start] 100px [left-end] 100px [right-end];
grid-template-rows: [left-start] 60px [right-start] 60px [left-end] 60px [right-end];
}
.left {
grid-area: left;
background-color: red;
}
.right {
grid-area: right;
background-color: lightgray;
opacity: 0.5;
}
<div class="container">
<div class="left">
</div>
<div class="right">
</div>
</div>