Scaling background images on hover without overflowing the column

Dear Team,

i have sections with two columns. One contains a background image that i want to scale on hover and also be a link. the other column contains text, a .svg and a button.

I have the following code in the global css for scaling the background image:
.page-id-114 #x-section-3 .x-column:hover:nth-child(1) {
transition: all .5s;
transform: scale(1.1);
}

This works except that the image overflows the column, what i don‘t want.

In the css-style field of the column with the background-image i have the following code:
background-image: url(“http://dev.plusquadrat-projects.de/duhnen/wp-content/uploads/2018/02/Duhnen-Living_Aussen-1.jpg”);
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
vertical-align: middle:

For linking the background image / column i used the following js:
(function($){
$(’’).insertBefore(’.linked-column’);
$(’.linked-column’).prependTo( $(’#column-link’) );
})(jQuery);

But after giving the id and the class to the columns the background images disappeared…

To provide you every code i added for the section with the columns, that is what i use to change the background-color of the text-column on hover:
.page-id-114 #x-section-3 .x-column:hover:nth-child(2) {
transition: background-color 0.3s ease;
background-color: #0a1f2e !important;
}

To clearify what i want to achieve:

  • Background-images should not overflow the normal column-size
  • Background-images / whole columns should be links

I hope you can help me solve this problem…

Thanks a lot in advance and best regards.

Ingo

Hey @ingo,

Regretfully, this is not a feature offered in X and Pro. For this, you will need to use The Grid plugin or follow this custom setup in a Raw Content element.

Thanks.

Hey Christian,

thank you for the reply.

When i use The Grid to integrate an image inside of one of the columns it does not behave responsive as i like.

What can i do to force the grid-item to always fill the height of the column. The image can be cropped on the sides - that is no problem. But as the whole section (consisting of a column with a svg, text and a button and a second column with an image) has a fixed height it is important, that the image is allways “full-height”.

Thanks for your help!

Hi There,

Let’s take a different path and you can work with your customizations from here:

Please add the following code to Cornerstone CSS or Theme Options CSS

/*
// Image Grid.
*/

.x-bnb-image-grid {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-flow: row wrap;
          flex-flow: row wrap;
  -webkit-justify-content: space-between;
          justify-content: space-between;
  -webkit-align-items: stretch;
          align-items: stretch;
  margin: -10px;
}

.x-bnb-image-grid > a {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-flow: column nowrap;
          flex-flow: column nowrap;
  -webkit-justify-content: flex-end;
          justify-content: flex-end;
  -webkit-align-items: flex-start;
          align-items: flex-start;
  -webkit-flex: 1 1 360px;
          flex: 1 1 360px;
  overflow: hidden;
  position: relative;
  z-index: 1;
  margin: 10px;
  min-height: 300px;
  font-size: 2rem;
  box-shadow: 0 0.25em 1.5em rgba(0, 0, 0, 0.35);
}

.x-bnb-image-grid > a:before {
  content: "";
  display: block;
  position: absolute;
  z-index: -1;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  background-color: rgba(21, 21, 21, 0.65);
  transition: background-color 0.5s ease;
}

.x-bnb-image-grid > a:hover:before,
.x-bnb-image-grid > a:focus:before {
  background-color: rgba(21, 21, 21, 0.35);
}

.x-bnb-image-grid > a:hover > .bg,
.x-bnb-image-grid > a:focus > .bg {
  transform: scale(1.1);
}

.x-bnb-image-grid > a:hover > div > small,
.x-bnb-image-grid > a:focus > div > small {
  color: #ffffff;
}

.x-bnb-image-grid > a > .bg {
  display: block;
  position: absolute;
  z-index: -2;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-position: 50% 50%;
  background-size: cover;
  transition: transform 0.5s ease;
}

.x-bnb-image-grid > a > div {
  width: 100%;
  padding: 1em;
  font-size: 1em;
  line-height: 1;
}

.x-bnb-image-grid > a > div > span {
  display: block;
  overflow: hidden;
  font-size: 1em;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff;
}

.x-bnb-image-grid > a > div > small {
  display: block;
  overflow: hidden;
  margin: 0.35em 0 0;
  font-size: 0.575em;
  font-weight: 700;
  letter-spacing: 0.065em;
  line-height: 1.4;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  color: #ffffff;
  transition: color 0.5s ease;
}


/*
// Room Column Intro.
*/

Now, on Cornerstone add Custom Raw Code Element and add the following code :

<div class="x-bnb-image-grid">

  <a href="http://wdbootcamp.com/accommodations/murphy-standard/">
    <span class="bg" style="background-image: url(http://wdbootcamp.com/wp-content/uploads/2018/02/bg-standard.jpg);"></span>
    <div>
      <span>Murphy Standard</span>
      <small>From $149 a Night</small>
    </div>
  </a>
   </div>

You can remove the text if you wish, but I left on the code as it might be useful as well :slight_smile:

Hope it helps

Hey Joao,

thank you so much for the effort.

It works perfectly.

I removed the text-area you added and the transparent background before the hover and at the end of the transition.

If you want to take a look, the link i posted before is still working.

You just made my day!

In general: Your support is spectacular!

All the best.

Ingo

You’re welcome.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.