Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a 'gatsby-image' processed image as a background for one column only isn't working as expected #10622

Closed
julsmon opened this issue Dec 22, 2018 · 8 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more. status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@julsmon
Copy link

julsmon commented Dec 22, 2018

Description

Hi everyone, after learning how to use the plugin 'gatsby-image' for background images, I'm trying to use a 'gatsby-image' processed image as a background for one column. The layout has two columns next to each other, only the first column should have a fluid image as a background, but the image somehow stretches to cover also the second column.

Steps to reproduce

This is my component code:

import React from 'react'
import Img from 'gatsby-image'
import { StaticQuery, graphql } from 'gatsby'


const SidebarImage = () => (
    <StaticQuery
        query={imgQuery}
        render={data => (
            <Img
                fluid={data.SidebarImgEnt.childImageSharp.fluid}
                style={{
                position: 'absolute',
                left: 0,
                top: 0,
                width: '100%',
                height: '100%',
                }}
            />
        )}
    />

  )

export default SidebarImage

export const imgQuery = graphql`
    query {
        SidebarImgEnt: file(relativePath: {eq: "sidebar.jpg"}) {
            childImageSharp {
                fluid(maxWidth: 1500) {
                    ...GatsbyImageSharpFluid
                }
            }
        }
    }
`

and this is the layout code:

return (
<Layout>
    <div class="columns is-centered">
      <div class="column is-5">
          <SidebarImage />
        <section class="hero is-fullheight-with-navbar">
          <div class="hero-body">
              <div class="container">
                  <h1 class="title is-top">
                      {category}
                  </h1>
              </div>
          </div>
          <div class="hero-foot">

          </div>
        </section>    
      </div>

      <div class="column is-7 is-primary">
      ...
      </div>

`

Expected result

The expected result would be to have the fluid image covering the background of the first column only, adjusting itself to the different width and height that the column reaches on different screens.

Actual result

The actual result is that the image stretches to cover the second column as well, even if the image component is only placed inside the first column.

Environment

This is my environment;

npmPackages:
gatsby: ^2.0.52 => 2.0.52
gatsby-image: ^2.0.20 => 2.0.20
gatsby-plugin-categories: ^1.2.0 => 1.2.0
gatsby-plugin-manifest: ^2.0.9 => 2.0.9
gatsby-plugin-offline: ^2.0.15 => 2.0.15
gatsby-plugin-react-helmet: ^3.0.2 => 3.0.2
gatsby-plugin-sass: ^2.0.4 => 2.0.4
gatsby-plugin-sharp: ^2.0.12 => 2.0.12
gatsby-plugin-styled-components: ^3.0.2 => 3.0.2
gatsby-source-filesystem: ^2.0.8 => 2.0.8
gatsby-transformer-remark: ^2.1.12 => 2.1.12
gatsby-transformer-sharp: ^2.1.8 => 2.1.8

Thank you very much.

@LekoArts
Copy link
Contributor

Can you share your repository or the CSS styles you're using?

@LekoArts LekoArts added the type: question or discussion Issue discussing or asking a question about Gatsby label Dec 22, 2018
@julsmon
Copy link
Author

julsmon commented Dec 22, 2018

Hi @LekoArts, I'm using Bulma CSS framework as it is grid-wise or column-wise (I didn't make any custom grid). So my current css file just lists the import from Bulma, like so:

@import "./node_modules/bulma/sass/grid/columns.sass";

@LekoArts
Copy link
Contributor

Mh, it's difficult to help you without having a reproduction repository. So this is just a shot in the dark:

Add overflow: hidden; to your <div class="column is-5"> column.

@julsmon
Copy link
Author

julsmon commented Dec 22, 2018

Adding overflow doesn't seem to work.
You can find the repository at [https://gitlab.com/giuliacta/intelness] and you can see what's happening with the image in any category page.
Many thanks for your support!

@gurpreet-hanjra
Copy link
Contributor

Hello Julsmon, is it a public repo, would you mind if I have a look on the issue? For some reason, I'm not a able to view the repo.

@sidharthachatterjee sidharthachatterjee added the status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. label Dec 26, 2018
@sidharthachatterjee
Copy link
Contributor

@julsmon https://gitlab.com/giuliacta/intelness appears to be private

Can you please add me or link to a public minimal reproduction repo?

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Feb 9, 2019
@gatsbot
Copy link

gatsbot bot commented Feb 9, 2019

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! 💪💜

@gatsbot
Copy link

gatsbot bot commented Feb 20, 2019

Hey again!

It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

Thanks again for being part of the Gatsby community!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more. status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

4 participants