nuxt / nuxt/image

Provide solution for different sizes in CSS background-img

Open
#592 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.5k
Forks
331
Avg merge
19h 52m
Merged PRs (30d)
9

Description

I have the following Code for providing a CSS background-image:

backgroundStyles() {
  const imgUrl = this.$img("forest-1279x852.jpg", {
    width: 1279,
    format: "webp",
  });
  return {
    backgroundImage: `url(${imgUrl})`,
  };
}

Can you please provide a solution for sizing this image down based on the image screens sizes in the config?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the backgroundStyles() entry point and how this.$img handles the width and format options, then inspect how configured image screen sizes are exposed. Done means a background-image can select an appropriately sized image for the configured screen sizes, with the expected behavior verified for responsive backgrounds.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript, nuxt
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.