0

I am working on a project where I need to set an image on a submit button. Because there is integration with third-party software, the only way to accomplish it is to use the background style in CSS. However, the URL for the image doesn't resolve properly in CSS, so I need to include the tilde that is a part of the folder name in the URL.

Here is the CSS that I currently have set:

input[type=submit] {
  background:url('~images/continue.png');
  border:0;
  color:transparent;
  width:150px;
  height:50px;
 }

I tried escaping with a backslash, ascii, double tilde, and a few others to try and get the CSS to see the tilde in the URL as just another character, but it still is doing standard CSS evaluation and not getting to the correct folder.

Why not just use the full URL? Unfortunately, I have no idea what the URL is going to be since it is dynamic, but I know the URL format to get to the image is roughly:

www.website.com/some unknown text/~images/image name

In the page that I created, I use "images/image name" for regular images that just use a src tag, but the third party software resolves that to "~images/image name" when it pulls them in.

Is there a way to make the CSS use the tilde as part of the folder name instead of assuming it is supposed to go to a different folder? Or is there a way to pull in the current URL directly in the CSS, so it ends up with the full path?

  • Can you not use `/` to resolve to the root site? So it will resolve to `/images/image-name` -> `website.com/images/image-name` – David Nguyen Mar 06 '19 at 18:09
  • No, the folder does not exist at the root site. It must go to the URL format in the original question. It should not go to the root site at all. The tilde needs to be included in the path (which is missing from your comment), not used to redirect the path. – Becky Spann Mar 06 '19 at 18:51
  • Are you referring to the ["home directory"](https://stackoverflow.com/questions/6252471/what-is-the-use-of-tilde-in-url)? – showdev Mar 07 '19 at 10:39
  • Yes and no? I need the tilde in the URL, not being used as a redirect to the home directory. I want the tilde shown to be ignored--I need the standard functionality to not occur. – Becky Spann Mar 07 '19 at 17:47

0 Answers0