2

I was trying to remember something I saw on YouTube. The guy was positioning a background image doing something like this:

background-image: url(img/someimg.jpg) 200px 300px;

I think the 200px positions it on the x-axis while the other is the y-axis. I'm not sure & this doesn't work but it was very similar to this. Can I get some help?

Partho63
  • 3,117
  • 2
  • 21
  • 39
Alfred
  • 245
  • 1
  • 2
  • 13
  • 1
    I would guess that they were using the `background` property to handle both the image, position, etc. Check out [CSS background](https://developer.mozilla.org/en-US/docs/Web/CSS/background) – benvc Feb 03 '19 at 03:26
  • check this : https://stackoverflow.com/a/51734530/8620333 – Temani Afif Feb 03 '19 at 08:26
  • First off, you need make a proper research before posting a question, e.g. with stuff like this, start consulting the docs. at e.g. [MDN](https://developer.mozilla.org/en-US/). It will save you a lot of time compared to write up questions for every small detail. – Asons May 04 '19 at 20:38
  • Second, a question need a verifiable sample **within** the question, not to external resources like fiddle etc. only. Now I voted to close and downvoted your last 3 posts. Please reread [ask] so your upcoming posts will comply with SO guidelines. – Asons May 04 '19 at 20:38

1 Answers1

0

There are many background properties like background-image:, background-position:and all of them can be reduced to one property background:. This is useful to save a few bytes and it's faster to write. CSS works exactly the same.

Syntax looks like this:

background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit;

Check this LINK for more informations

Jakub Muda
  • 6,008
  • 10
  • 37
  • 56
  • I know about this but the position value is defined with center, top, bottom etc. I'm looking to move it in pixels so i can set it precisely where I want it – Alfred Feb 03 '19 at 04:34
  • 1
    Position is defined either way. You can use center, right etc or you can use pixels so it would be like that `background: url() 100px 40px/bg-size bg-repeat .......` – Jakub Muda Feb 03 '19 at 04:51
  • Oh I didn't know that was allowed. Thank you:) – Alfred Feb 03 '19 at 21:24