Skip to content

The responsive layout is incompatible with a Flexbox container #27644

@kkomelin

Description

@kkomelin

What version of Next.js are you using?

11.0.1

What version of Node.js are you using?

14.16.1

What browser are you using?

Chrome

What operating system are you using?

Ubuntu 20.04.2 LTS

How are you deploying your application?

yarn start

Describe the Bug

Images with the responsive layout are not displayed on the page if put inside a flexbox container.

Expected Behavior

Responsive images should be visible.

To Reproduce

  1. Create an app through:
npx create-next-app next-image-flexbox-bug
cd next-image-flexbox-bug
  1. Create a Next page with the following code:
// pages/next-image-flexbox-bug.js
import Image from 'next/image';

export default function NextImageFlexboxBug() {
  return (
    <div style={{display: 'flex'}}>
      <Image
        src="/sunset1.jpg" 
        alt="Sunset" 
        width={600} 
        height={450} 
        layout="responsive"
      />
    </div>
  )
}
  1. Run the server:
yarn dev
  1. Open in Chrome:

http://localhost:3000/next-image-flexbox-bug

  1. Nothing is displayed on the page (the white screen).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions