Skip to content

background-offset-x & background-offset-y : Background image position offset properties #1780

Closed

Description

@d2fong

Issue type

Feature request

Description of new feature

Add properties:

  • background-offset-x : The x offset of the background image, measured in percent (e.g. 50%) or pixels (e.g. 10px).
  • background-offset-y : The y offset of the background image, measured in percent (e.g. 50%) or pixels (e.g. 10px).

Note that these properties accept arrays of values, like other background image properties, to allow per-image configuration.

Motivation for new feature

This allows for better control of the image position by combining the background position with the background offset. For example, the position can be specified in percent while the offset can be specified in pixels in order to create more precise positioning.

This allows for cases, like the following, where the position is combined with the offset to put a decoration just outside of the node body:

  cy.stylesheet()
     .selector('node')
        .css({
          'label': 'data(id)',
          'background-image': 'images/gnu.svg',
          'background-clip': 'none',
          'background-width': 5,
          'background-height': 5,
          'background-position-x': '50%',
          'background-position-y': '100%',
          'background-offset-x': 0,
          'background-offset-y': 5,
          'bounds-expansion': 5
        })

screen shot 2019-01-25 at 4 31 37 pm

Note that this example uses bounds-expansion #1782.

Activity

  1. added this to the milestone on Apr 13, 2017
  2. modified the milestones: , 3.4.0 on Jan 24, 2019
  3. self-assigned this
    on Jan 24, 2019
  4. deleted a comment from d2fong on Jan 25, 2019
  5. changed the title [-]Background image position offset[/-] [+]`background-offset-x` & `background-offset-y` : Background image position offset properties[/+] on Jan 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions