Jump to content

css-grid FR units function not working?

Go to solution Solved by _Gavin,

Recommended Posts

I am creating a custom  code section on my home page and want to use css-grid to style it. Everything works fine except when I try to use the minmax function with fr units. 

 

This is a common way of having elements stretch evenly across a container but then stack when the window is resized and the min width (250) is reached. However this isn't working for me in Squarespace. Any thoughts on why? I'm using Chrome, so fr units and css-grid is compatible.

grid-template-columns: reapeat(auto-fit, minmax(250px, 1fr);

 

This seems to work, but it's obviously not what I want:

grid-template-columns: reapeat(auto-fit, minmax(250px, 300px);

 

Here is my full code:
 

<div class="home-services-container">
  <div class="service-card service1">
    <h3>
      Creative<br /> Engagement
    </h3>
  </div>
  <div class="service-card service2">
    <h3>
      Ideation + <br />Innovation
    </h3>
  </div>
  <div class="service-card service3">
    <h3>
      Career <br/> Coaching
    </h3>
  </div>
</div>

CSS:

.home-services-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  grid-gap: 16px;
}

.service-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #401025;
  height: 200px;
  width: 1fr;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0px 4px 15px 0px rgba(0, 0, 0, 0.1);
  background-repeat: no-repeat;
  background-position: -150px -80px
}

 

Image 2019-11-13 at 3.59.25 PM.png

Link to comment
  • 4 months later...

Sorry I dont have the answer, but just wanted to notify that I'm getting the same problem. If you inspect the elements on your chrome browser for whatever reason the css changes from `

grid-template-columns: repeat(auto-fit, minmax(250px, 1fr);

to 

 

grid-template-columns: repeat(auto-fit, minmax(250px, 1 fr);

 

there's a space between the 1 and fr in 1fr...NO IDEA WHY THIS HAPPENS and it only seems to happen when using the repeat function.

Link to comment
  • 3 weeks later...
  • 3 months later...
  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.