skip to Main Content
    

.card--card.gradient, .card__inner.gradient {
        transform: perspective(0);
    }
    .card--card, .card--standard .card__inner {
        position: relative;
        box-sizing: border-box;
    }
    .card__inner {
        width: 100%;
        display: flex;
        flex-direction: column;
        flex: 1 1 50%;
        overflow: hidden;
        --ratio-percent: 99.77064220183487%;
    }
    .ratio {
        display: flex;
        position: relative;
        align-items: stretch;
    }
    .gradient {
        background: #FFFCF2;
        background-attachment: fixed;
    }
    .card {
        text-decoration: none;
        height: 100%;
    }
    .card-wrapper {
        color: inherit;
        height: 100%;
        position: relative;
        text-decoration: none;
    }
    .grid {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 2rem;
        padding: 0;
        list-style: none;
    }
    ul {
        list-style-type: disc;
    }
   
   .ratio::before {
        content: '';
        width: 0;
        height: 0;
        padding-bottom: var(--ratio-percent);
    }
    .card--card:after, .card--standard .card__inner:after {
        content: "";
        position: absolute;
        z-index: -1;
    }
    .card .card__inner .card__media {
        overflow: hidden;
        z-index: 0;
        border-radius: calc(var(--border-radius) - var(--border-width) - var(--image-padding));
    }

    
    .card__media, .card .media {
        bottom: 0;
        position: absolute;
        top: 0;
        overflow: none;
    }
    
    slider-component {
        position: relative;
        display: block;
    }
    @media screen and (min-width: 750px) {
        body {
            font-size: 1.6rem;
        }
    }
    body {
        display: grid;
        grid-template-rows: auto auto 1fr auto;
        grid-template-columns: 100%;
        min-height: 100%;
        margin: 0;
        font-size: 1.5rem;
        letter-spacing: 0.06rem;
    }
    *, *::before, *::after {
        box-sizing: inherit;
    }

    .card--media .card__inner .card__content {
        position: relative;
        padding: calc(var(--image-padding) + 1rem);
    }

    .card__content {
        display: grid;
        grid-template-rows: minmax(0, 1fr) max-content minmax(0, 1fr);
        padding: 1rem;
        width: 100%;
        background-color: #dd6a33;
        flex: 1;
        height: 50%;
    }
    div {
        display: block;
        unicode-bidi: isolate;
    }
    .grid {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 2rem;
        padding: 0;
        list-style: none;
    }
    slider-component {
        position: relative;
        display: block;
    }
    @media screen and (min-width: 750px) {
        body {
            font-size: 1.6rem;
        }
    }
    body {
        display: grid;
        grid-template-rows: auto auto 1fr auto;
        grid-template-columns: 100%;
        min-height: 100%;
        margin: 0;
        font-size: 1.5rem;
        letter-spacing: 0.06rem;
    }    
    html {
        box-sizing: border-box;
        height: 100%;
    }
    <div class="card__inner color-scheme-2 gradient ratio" style="--ratio-percent: 99.77064220183487%;"><div class="card__media">
                <div class="media media--transparent media--hover-effect">
                  
                  <img src="http://www.gettyimages.ca/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg" class="motion-reduce" loading="lazy" width="436" height="435">
                  
    </div>
              </div>
<div class="card__content">
              <div class="card__information">
                <h3 class="card__heading">
                  <a href="<link to other page>" id="StandardCardNoMediaLink-template--15500528386151__featured_collection_6iUf8K-7156043710567" class="full-unstyled-link" aria-labelledby="StandardCardNoMediaLink-template--15500528386151__featured_collection_6iUf8K-7156043710567 NoMediaStandardBadge-template--15500528386151__featured_collection_6iUf8K-7156043710567">
                    Link
                  </a>
                </h3>
              </div>
              <!---->
              <div class="card__badge bottom left"><span id="NoMediaStandardBadge-template--15500528386151__featured_collection_6iUf8K-7156043710567" class="badge badge--bottom-left color-scheme-3 view-product-span">
                    <!--Sold out-->
                   Text
                  </span></div>
            </div>
          </div>

I am trying to make the image container div, the div with the card__media class, and the div with the card__content class. I have been trying to mess with the styling through the inspect tool and look through StackOverflow. I tried to implement the first solution of this post by giving the top div (card__media class) flex: 0 1 auto, and the bottom div flex: 1 1 auto, but that didn’t work. I tried making the height: 100% for the div with the card__content class as that class only took the size of the square area while the card_media div took the full height. A solution would be to make the card__content div take up the remaining area between the photo and the square, but I am stuck. Any help would be appreciated. Thank you. Also, I know the image does not fit the height and width as I just substituted an image I found to generalize the question.

2

Answers


  1. Here is my snippet.

    Check this out.

     .mainDiv {
            height: 100vh;
            border: solid 2px red;
          }
          .gradiendDiv {
            height: 50%;
            border: solid 2px orange;
            background: linear-gradient(red, yellow);;
          }
          .imageDiv {
            height: 50%;
            border: solid 2px green;
            overflow: auto;
          }
    <div class="mainDiv">
          <div class="gradiendDiv"></div>
          <div class="imageDiv">
            <img
              src="http://www.gettyimages.ca/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg"
            />
          </div>
        </div>
    Login or Signup to reply.
  2. Here is the code as per your requirement using Flexbox.

    .card--card.gradient,
    .card__inner.gradient {
        transform: perspective(0);
    }
    
    .card--card,
    .card--standard .card__inner {
        position: relative;
        box-sizing: border-box;
    }
    
    .card__inner {
        width: 100%;
        height: 100vh;
        display: flex;
        flex-direction: column;
        overflow: auto;
    }
    
    .ratio {
        display: flex;
        position: relative;
        align-items: stretch;
    }
    
    .gradient {
        background: #FFFCF2;
        background-attachment: fixed;
    }
    
    div {
        display: block;
        unicode-bidi: isolate;
    }
    
    .card {
        text-decoration: none;
        height: 100%;
    }
    
    .card-wrapper {
        color: inherit;
        height: 100%;
        position: relative;
        text-decoration: none;
    }
    
    .grid {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 2rem;
        padding: 0;
        list-style: none;
    }
    
    ul {
        list-style-type: disc;
    }
    
    slider-component {
        position: relative;
        display: block;
    }
    
    @media screen and (min-width: 750px) {
        body {
            font-size: 1.6rem;
        }
    }
    
    body {
        display: grid;
        grid-template-rows: auto auto 1fr auto;
        grid-template-columns: 100%;
        min-height: 100%;
        margin: 0;
        font-size: 1.5rem;
        letter-spacing: 0.06rem;
    }
    
    style attribute {
        padding-bottom: 60px;
    }
    
    html {
        box-sizing: border-box;
        font-size: calc(var(--font-body-scale)* 62.5%);
        height: 100%;
    }
    
    .ratio::before {
        content: '';
        width: 0;
        height: 0;
        padding-bottom: var(--ratio-percent);
    }
    
    .card--card:after,
    .card--standard .card__inner:after {
        content: "";
        position: absolute;
        z-index: -1;
    }
    
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }
    
    ::selection {
        background-color: rgba(var(--color-foreground), 0.2);
    }
    
    .card .card__inner .card__media {
        overflow: hidden;
        z-index: 0;
        border-radius: calc(var(--border-radius) - var(--border-width) - var(--image-padding));
    }
    
    .card--standard .card__media {
        margin: var(--image-padding);
    }
    
    .card__media {
        flex: 1;
        margin: var(--image-padding);
        width: calc(100% - 2* var(--image-padding));
    }
    
    .card__media .media {
        height: 100%;
    }
    
    .card__media img {
        display: block;
        height: 100%;
    }
    
    body,
    .color-scheme-1,
    .color-scheme-2,
    .color-scheme-3,
    .color-scheme-4,
    .color-scheme-5,
    .color-scheme-28fbd4b2-c38c-45a0-8bb9-ee37c94a3348,
    .color-scheme-6d8c5861-3750-48e6-8cfd-9acdafcb3d39 {
        color: rgba(var(--color-foreground), 0.75);
        background-color: rgb(var(--color-background));
    }
    
    .card {
        text-decoration: none;
        text-align: var(--text-alignment);
        height: 100%;
    }
    
    .card-wrapper {
        color: inherit;
        height: 100%;
        position: relative;
        text-decoration: none;
    }
    
    style attribute {
        --animation-order: 1;
    }
    
    user agent stylesheet li {
        text-align: -webkit-match-parent;
    }
    
    .grid {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 2rem;
        padding: 0;
        list-style: none;
    }
    
    ul {
        list-style-type: disc;
    }
    
    slider-component {
        position: relative;
        display: block;
    }
    
    @media screen and (min-width: 750px) {
        body {
            font-size: 1.6rem;
        }
    }
    
    body {
        display: grid;
        grid-template-rows: auto auto 1fr auto;
        grid-template-columns: 100%;
        min-height: 100%;
        margin: 0;
        font-size: 1.5rem;
        letter-spacing: 0.06rem;
        line-height: calc(1 + 0.8 / var(--font-body-scale));
        font-family: var(--font-body-family);
        font-style: var(--font-body-style);
        font-weight: var(--font-body-weight);
    }
    
    style attribute {
        padding-bottom: 60px;
    }
    
    html {
        box-sizing: border-box;
        font-size: calc(var(--font-body-scale)* 62.5%);
        height: 100%;
    }
    
    *,
    *::before,
    *::after {
        box-sizing: inherit;
    }
    
    ::selection {
        background-color: rgba(var(--color-foreground), 0.2);
    }
    
    .card--media .card__inner .card__content {
        position: relative;
        padding: calc(var(--image-padding) + 1rem);
    }
    
    .card__content {
        padding: 0 1rem;
        width: 100%;
        background-color: #dd6a33;
        flex: 1;
    }
    
    div {
        display: block;
        unicode-bidi: isolate;
    }
    
    .card {
        text-decoration: none;
        text-align: var(--text-alignment);
        height: 100%;
    }
    
    .card-wrapper {
        color: inherit;
        height: 100%;
        position: relative;
        text-decoration: none;
    }
    
    .grid {
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 2rem;
        padding: 0;
        list-style: none;
    }
    
    ul {
        list-style-type: disc;
    }
    
    slider-component {
        position: relative;
        display: block;
    }
    
    @media screen and (min-width: 750px) {
        body {
            font-size: 1.6rem;
        }
    }
    
    body {
        display: grid;
        grid-template-rows: auto auto 1fr auto;
        grid-template-columns: 100%;
        min-height: 100%;
        margin: 0;
        font-size: 1.5rem;
        letter-spacing: 0.06rem;
    }
    
    style attribute {
        padding-bottom: 60px;
    }
    
    html {
        box-sizing: border-box;
        height: 100%;
    }
    
    ::selection {
        background-color: rgba(var(--color-foreground), 0.2);
    }
    <div class="card__inner color-scheme-2 gradient ratio">
        <div class="card__media">
            <div class="media media--transparent media--hover-effect">
                <img src="http://www.gettyimages.ca/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg" class="motion-reduce" loading="lazy" width="600" height="435">
            </div>
        </div>
        <div class="card__content">
            <div class="card__information">
                <h3 class="card__heading">
                    <a href="<link to other page>" id="StandardCardNoMediaLink-template--15500528386151__featured_collection_6iUf8K-7156043710567" class="full-unstyled-link" aria-labelledby="StandardCardNoMediaLink-template--15500528386151__featured_collection_6iUf8K-7156043710567 NoMediaStandardBadge-template--15500528386151__featured_collection_6iUf8K-7156043710567">
                        Link
                    </a>
                </h3>
            </div>
            <!---->
            <div class="card__badge bottom left">
                <span id="NoMediaStandardBadge-template--15500528386151__featured_collection_6iUf8K-7156043710567" class="badge badge--bottom-left color-scheme-3 view-product-span">
                    Text
                </span>
            </div>
        </div>
    </div>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search