0

i got this stylesheet that is inside my tags of a webpage. (not a css-file because this is the only file it will ever be used in).

background-image: url("/assets/img/report/test4.png");

My background-image url doesnt include the port number for the host when using relative url.

Example:

Works:

localhost:8334/assets/img/report/test4.png

Does not work, and is the output of relative url:

localhost/assets/img/report/test4.png

Any idea why its not including the port number?

Christer
  • 1,651
  • 1
  • 17
  • 34
  • You contradict yourself in this question. "background-image does not load when using port numbers in the url." then you say `localhost:8334` works but `localhost` doesn't. – Andy Feb 21 '13 at 10:19
  • Thanks for the input @Andy, i added a hopefully better explanation. – Christer Feb 21 '13 at 10:24

2 Answers2

1

If your 'assets' folder is in the root why are you adding the extra '/' ? I've never used it like this, try editing it out perhaps.

Adam Brown
  • 2,812
  • 4
  • 28
  • 39
0

Try using a relative path rather than an absolute one. Example:

background-image:url('../../assets/img/report/test4.png');

otinanai
  • 3,987
  • 3
  • 25
  • 43
  • I am using a relative path, url("/assets/img/report/test4.png"); Absolute paths are including the host aswell url("localhost:8080/assets/img/report/test4.png") would be a absolute path. – Christer Feb 21 '13 at 10:10
  • My suggestion was to avoid the use of absolute paths. However, your answer may be found here: http://stackoverflow.com/questions/8317059/relative-path-but-for-port. or here: http://stackoverflow.com/questions/6016120/relative-url-to-a-different-port-number-in-a-hyperlink It seems that you cannot avoid the use of js. – otinanai Feb 21 '13 at 10:33