multiple widths css grid - css

So I'm attempting to create a grid like this
Where I have the top and bottom posts the same size and have one post in the middle slim down and auto-fill the remaining space.
Here is my code
<section class="posts-grid">
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post long-post">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
</section>
css
.posts-grid {
grid-template-areas:
"post post"
"long-post post"
"post post";
grid-template-columns: 15% 1fr;
grid-template-rows: 80px 1fr;
grid-auto-rows: 385px;
grid-column-gap: 23px;
grid-row-gap: 20px;
height: 100vh;
display: grid;
}
.post { grid-area: post; }
.post.long-post { grid-area: long-post !important; }
I have created a codepen https://codepen.io/ben_bagley/pen/30272c1f61b4f20c080040f5359bd5f1 but as you can see it it's ignoring a good like so
Any help in getting the desired effect is appreciated.

this is the best I could do, I hope it helps.
HTML:
<section class="posts-grid">
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?
width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design
much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?
width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="long-post">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
<article class="post">
<img src="https://blog.flyingsaucer.nyc/hs-fs/hubfs/blog/pitchadri.png?width=1464&name=pitchadri.png" alt="">
<div class="blog-listing-info">
<a href="#">
<h2 class="blog-listing-title">13 things to make your US and UI design much better</h2>
</a>
<p class="blog-listing-tag">Design - 11 min read</p>
</div>
</article>
</section>
The SCSS:
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
}
.posts-grid {
padding: 10px;
display: grid;
grid-gap: 10px;
grid-template-columns: repeat(5, 1fr);
grid-template-rows: auto;
.post, .long-post {
padding: 10px;
border-radius: 6px;
}
.post:first-child, .long-post + .post {
background: greenyellow;
grid-column-end: span 3;
}
.post + .post + .post {
grid-column-end: span 1;
}
.post {
background: lightblue;
grid-column-start: auto;
grid-column-end: span 2;
}
.long-post {
background: red;
grid-column-end: span 4;
}
img {
width: 100%;
height: auto;
}
}
And here is the JsFiddle:
https://jsfiddle.net/cisco336/ebt0zfvr/

Related

how can i wrap grid making it responsive?

I've been trying to do the last project of the FCC certificate, my problem is the mid section with the grid part, i managed to do something by trial and error, something at the end did come out, the problem is now i've been following other posts about using minmax, auto-fill and auto-fit after the repeat tag but it doesnt seem to work for me, it ruins the images blocks and they go wild if i touch something.
this is the whole code
https://jsfiddle.net/8k7ne9so/9/
.works {
height: 100vh;
width: 100%;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
grid-template-rows: repeat(auto-fit, minmax(320px, 1fr));
grid-column-gap: 18px;
grid-row-gap: 24px;
grid-area: auto;
}
.projects1 {
grid-area: 2 / 2 / 3 / 3;
}
.projects2 {
grid-area: 2 / 3 / 3 / 4;
}
.projects3 {
grid-area: 2 / 4 / 3 / 5;
}
.projects4 {
grid-area: 3 / 2 / 4 / 3;
}
.projects5 {
grid-area: 3 / 3 / 4 / 4;
}
.projects6 {
grid-area: 3 / 4 / 4 / 5;
}
<section>
<div class="presentation" id="presentation">
<h1>Hi, I'm Marwan</h1>
<p>Junior Web Developer</p>
</div>
</section>
<!-- lavori -->
<section>
<div id="works">
<h2 class="text">These are all my works so far</h2>
<div class="works">
<a id="projects" class="projects1" href="#">
<img class="images" src="http://placekitten.com/200/300" alt="">
<p class="pj-title"><span class="code"><</span> prova <span class="code">/></span></p>
</a>
<a id="projects" class="projects2" href="#">
<img class="images" src="http://placekitten.com/200/300" alt="">
<p class="pj-title"><span class="code"><</span> prova <span class="code">/></span></p>
</a>
<a id="projects" class="projects3" href="#">
<img class="images" src="http://placekitten.com/200/300" alt="">
<p class="pj-title"><span class="code"><</span> prova <span class="code">/></span></p>
</a>
<a id="projects" class="projects4" href="#">
<img class="images" src="http://placekitten.com/200/300" alt="">
<p class="pj-title"><span class="code"><</span> prova <span class="code">/></span></p>
</a>
<a id="projects" class="projects5" href="#">
<img class="images" src="http://placekitten.com/200/300" alt="">
<p class="pj-title"><span class="code"><</span> prova <span class="code">/></span></p>
</a>
<a id="projects" class="projects6" href="#">
<img class="images" src="http://placekitten.com/200/300" alt="">
<p class="pj-title"><span class="code"><</span> prova <span class="code">/></span></p>
</a>
</div>
</div>
</section>
as I said I'm trying everything but I can't manage to make them wrap and center do the center page

Bootstrap carousel with different size cards

I have a carousel faq, there are some boxes with different questions and answers, so the boxes are not the same size as you can see above:
My code is this one:
<section id="faq" class="shadow-lg">
<div class="container text-center">
<h3 class="font-weight-light">Faq</h3>
<div class="row mx-auto my-auto">
<div id="recipeCarousel" class="col carousel slide w-100" data-ride="carousel">
<div class="row carousel-inner w-100" role="listbox">
<div class="carousel-item active">
<div class="col-md-4">
<div class="card card-body">
<h4 class="card-title">pergunta</h4>
<p class="card-text">resposta</p>
</div>
</div>
</div>
<div class="carousel-item">
<div class="col-md-4">
<div class="card card-body">
<h4 class="card-title">pergunta</h4>
<p class="card-text">resposta</p>
</div>
</div>
</div>
</div>
<a class="carousel-control-prev w-auto" href="#recipeCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon bg-dark border border-dark rounded-circle"
aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next w-auto" href="#recipeCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon bg-dark border border-dark rounded-circle"
aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
</div>
</section>
css:
.carousel-inner .carousel-item.active,
.carousel-inner .carousel-item-next,
.carousel-inner .carousel-item-prev {
display: flex;
}
#faq{
padding-bottom: 80px;
}
#faq h3{
padding-top: 50px;
padding-bottom: 50px;
}
#faq .card{
border-color: #216869;
min-height: 400px;
}
#infos, #contato, #faq, #planos{
font-family: Montserrat-Regular;
font-size: 14px;
line-height: 1.7;
color: #666666;
margin: 0px;
}
I want the boxes to be at the same height, regardless of the size of the questions. Basically, I want all the boxes to be the same height as the largest.

How can I make the height of two separate unordered list items the same height?

For context, here's what it looks like. In the second unordered list, I would like the items to have the same height as the items in the first unordered list even though they don't have sections 2 or 3. Is this possible using flexbox or any other type of css? I'm trying to avoid calculating heights using JS. In the snippet below, I'm using pure css, but in my actual code, I'm using less.
EDIT: I can't hard-code the height because the sections are dynamic and generated by data retrieved from an API. Additionally, I can't make them vertically scrollable.
Code:
<html>
<head>
<style>
.module {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.module .container_wrapper {
border: solid 1px;
}
.module .panes-2 {
flex: 0 0 49%;
}
.module .card {
display: inline-block;
border: solid 1px;
}
</style>
</head>
<body>
<section class="module">
<div class="container_wrapper panes-2">
<ul>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
<p>section 2</p>
<p>section 3</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
<p>section 2</p>
<p>section 3</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
<p>section 2</p>
<p>section 3</p>
</li>
</ul>
</div>
<div class="container_wrapper panes-2">
<ul>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
</li>
<li class="card">
<img src="https://i.picsum.photos/id/132/200/200.jpg?hmac=meVrCoOURNB7iKK3Mv-yuRrvxvXgv4h2vIRLM4sKwK4"
alt="">
<p>section 1</p>
</li>
</ul>
</div>
</section>
</body>
</html>
I did a little research.
Not sure if this is what you are looking for, but using bootstrap could help:
<div class="container-fluid content-row">
<div class="row">
<div class="col-sm-12 col-lg-6">
<div class="card h-100">
… content card …
</div>
</div>
… all the other cards …
</div>
</div>
.card {
height: 500px;
overflow-y: scroll;
}
Also you can use overflow-y: auto;

align bottom images different size on bootsrap4 or css

I use css align-xxxx:bottom not working, i want images different height align bottom all
.width-book{
width: 100px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-4 text-center">
<a href="">
<figcaption class="figure-caption color-primary">A caption for image</figcaption>
<img class="a width-book" src="http://shakespeareandcompany.com/files/isbn/9780007448036.jpg" data-holder-rendered="true">
</a>
</div>
<div class="col-xs-4 text-center">
<a href="">
<figcaption class="figure-caption color-primary">A caption for image</figcaption>
<img class="a width-book" src="http://prodimage.images-bn.com/pimages/9780553805444_p0_v5_s1200x630.jpg" data-holder-rendered="true">
</a>
</div>
<div class="col-xs-4 text-center">
<a href="">
<figcaption class="figure-caption color-primary">A caption for image</figcaption>
<img class="a width-book" src="http://shakespeareandcompany.com/files/isbn/9780007448036.jpg" data-holder-rendered="true">
</a>
</div>
</div>
</div>
I want to result
image
Use flex css:
.wrapper {
position: relative;
height: 500px;
width: 1000px;
display: flex;
align-items: flex-end;
}
Example there: https://codepen.io/Czeran/pen/yPeGwO
Give your own class in col-xs-4 and give this css
.book{
align-self:end;
}
.width-book{
width: 100px;
}
.book{
align-self:end;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="row">
<div class="col-xs-4 text-center book">
<a href="">
<figcaption class="figure-caption color-primary">A caption for image</figcaption>
<img class="a width-book" src="http://shakespeareandcompany.com/files/isbn/9780007448036.jpg" data-holder-rendered="true">
</a>
</div>
<div class="col-xs-4 text-center book">
<a href="">
<figcaption class="figure-caption color-primary">A caption for image</figcaption>
<img class="a width-book" src="http://prodimage.images-bn.com/pimages/9780553805444_p0_v5_s1200x630.jpg" data-holder-rendered="true">
</a>
</div>
<div class="col-xs-4 text-center book">
<a href="">
<figcaption class="figure-caption color-primary">A caption for image</figcaption>
<img class="a width-book" src="http://shakespeareandcompany.com/files/isbn/9780007448036.jpg" data-holder-rendered="true">
</a>
</div>
</div>
</div>
The problem is that your content is wrapped in an "a" element. This is the one you actually need to style.
One simple way is to add the class "book" to each "a" element and this to your css:
a.book {
display: flex;
justify-content: space-between;
flex-direction: column;
height: 100%;
align-items: center;
}
That will give you exactly the result you're looking for.

Bootstrap 75% / 25% with 4 image thumbs (how to resolve)

Folks,
I'm trying to build with bootstrap. Following this basic markup:
<div class="container">
<header class="row">
</header>
<div class="row">
<div role="main" class="col-md-8">
</div>
<aside role="complementary" class="col-md-4">
</aside>
</div>
<footer class="row">
</footer>
</div>
I created the following page:
http://clubedebeneficiosunilife.com.br/thumbs-promocoes-logadoTest2.php
The problem that the thumbs were 'stretched' occupying all available space. I wish it were that displayed:
http://clubedebeneficiosunilife.com.br/main-col-side-bar.png
That is, the 'main' column in a notebook or desktop occupying 75% of the screen and 'terras' column containing the sidebar should occupy 25% of the width.
Only within the column 'main' I need to be displayed 4 thumbs (as print). I've tried everything
I'm already on my knees asking for help. Does anyone know how to solve?
Thank you in advance.
before thumbnail class just add class col-md-3 class then it will give you the exact result
.thumbnail {
background-color: #fff;
border: 1px solid #ddd;
border-radius: 4px;
display: block;
line-height: 1.42857;
margin-bottom: 20px;
min-height: 165px;
padding: 4px;
transition: all 0.2s ease-in-out 0s;
}
<div class=" col-md-3">
<a class="thumbnail" href="http://clubedebeneficiosunilife.com.br/detalhes-da-oferta/?idOferta=67">
<img class="img-responsive" src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thsnc_1853y1yw.png" alt="Teste" title="Teste">
<!--<img src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thsnc_1853y1yw.png" alt="Teste" title="Teste">-->
</a>
</div>
add this style to your website
.thumbnail {
display: inline-block;
margin-right: 20px;
width: 22%;
}
Try This
CSS
.thumbnail{
border:0;
}
.thumbnail img{
border:1px solid gray;
}
HTML
<div class"container-fluid">
<div class="row">
<aside role="complementary" class="col-md-4">
</aside>
</div>
<!--<div role="main" class="col-md-8 thumb">-->
<div role="main" class="col-md-8 col-lg-4 thumb">
<a class="thumbnail col-sm-3" href="http://clubedebeneficiosunilife.com.br/detalhes-da-oferta/?idOferta=67">
<img class="img-responsive" src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thsnc_1853y1yw.png"
alt="Teste" title="Teste">
<!--<img src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thsnc_1853y1yw.png"
alt="Teste" title="Teste">-->
</a>
<a class="thumbnail col-sm-3" href="http://clubedebeneficiosunilife.com.br/detalhes-da-oferta/?idOferta=66">
<img class="img-responsive" src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thnetbabys_ern9kwfl.png"
alt="Teste" title="Teste">
<!--<img src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thnetbabys_ern9kwfl.png"
alt="Teste" title="Teste">-->
</a>
<a class="thumbnail col-sm-3" href="http://clubedebeneficiosunilife.com.br/detalhes-da-oferta/?idOferta=64">
<img class="img-responsive" src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thLOGO
MARCA CCAA_2f0q5l9z.jpg" alt="Teste" title="Teste">
<!--<img src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thLOGO
MARCA CCAA_2f0q5l9z.jpg" alt="Teste" title="Teste">-->
</a>
<a class="thumbnail col-sm-3" href="http://clubedebeneficiosunilife.com.br/detalhes-da-oferta/?idOferta=63">
<img class="img-responsive" src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thelectrolux_esvrbxh0.png"
alt="Teste" title="Teste">
<!--<img src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thelectrolux_esvrbxh0.png"
alt="Teste" title="Teste">-->
</a>
<a class="thumbnail col-sm-3" href="http://clubedebeneficiosunilife.com.br/detalhes-da-oferta/?idOferta=67">
<img class="img-responsive" src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thsnc_1853y1yw.png"
alt="Teste" title="Teste">
<!--<img src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thsnc_1853y1yw.png"
alt="Teste" title="Teste">-->
</a>
<a class="thumbnail col-sm-3" href="http://clubedebeneficiosunilife.com.br/detalhes-da-oferta/?idOferta=66">
<img class="img-responsive" src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thnetbabys_ern9kwfl.png"
alt="Teste" title="Teste">
<!--<img src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thnetbabys_ern9kwfl.png"
alt="Teste" title="Teste">-->
</a>
<a class="thumbnail col-sm-3" href="http://clubedebeneficiosunilife.com.br/detalhes-da-oferta/?idOferta=64">
<img class="img-responsive" src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thLOGO
MARCA CCAA_2f0q5l9z.jpg" alt="Teste" title="Teste">
<!--<img src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thLOGO
MARCA CCAA_2f0q5l9z.jpg" alt="Teste" title="Teste">-->
</a>
<a class="thumbnail col-sm-3" href="http://clubedebeneficiosunilife.com.br/detalhes-da-oferta/?idOferta=63">
<img class="img-responsive" src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thelectrolux_esvrbxh0.png"
alt="Teste" title="Teste">
<!--<img src="http://www.clubedebeneficiosunilife.com.br/dados_admin/arquivos/thelectrolux_esvrbxh0.png"
alt="Teste" title="Teste">-->
</a>
</div>
<!--<div class="col-lg-12 col-md-12 col-xs-12 thumb">-->
<aside role="complementary" class="col-md-4">
<div class="arrowlistmenu"> <h3 class="headerbar">Categorias</h3>
<ul> <li class="arrowlistmenu">Academias</li>
<li><a
href="http://clubedebeneficiosunilife.com.br/bemvindo/?idCat=2">Artigos
Esportivos</a></li> <li>Automotivo</li>
<li>Alimentação</li>
<li>Compras</li>
<li>Beleza</li>
<li><a
href="http://clubedebeneficiosunilife.com.br/bemvindo/?idCat=7">Educação
e Cultura</a></li> <li>Informática</li>
<li><a
href="http://clubedebeneficiosunilife.com.br/bemvindo/?idCat=9">Lazer
e Entretenimento</a></li> <li>Medicina e Saúde</li> <li><a
href="http://clubedebeneficiosunilife.com.br/bemvindo/?idCat=11">Móveis
e Decoração</a></li> <li>Serviços</li>
<li><a
href="http://clubedebeneficiosunilife.com.br/bemvindo/?idCat=13">Viagem
e Turismo</a></li> </ul>
</div> </aside>
<!--</div>-->
</div>
</div>

Resources