I am trying to make a java applet using the javaFX library, but i have run into an unusual problem. I have CSS formatted toggle buttons that use png images, but when i put the images into an images folder the program is unable to locate them.
The problem line is:
-fx-border-image-source: url("left-btn.png");
// versus
-fx-border-image-source: url("images/left-btn.png");
// or
-fx-border-image-source: url("./images/left-btn.png");
As long as the images are in the same folder as the java class using them, it works fine, but as soon as they are moved into an images folder the classes cannot find them. The CSS file can be moved and still found but the images cannot. The second two lines above as well as any variations of them that I have been able to come up with fail to find the png files.
Any ideas?
in case since its not answered yet:
-fx-border-image-source: url("../images/left-btn.png");
when the imagefolder is on the same level as the folder for your classes
The correct syntax is (when image is 1 level up and inside folder "images"):
.image-background {
-fx-background-image: url("../images/background.jpg");
}
Related
I have downloaded a simple template from the internet and for icons, the developer used Flaticons font. Now I want to put another icon on the website but I can't get Flaticons code for CSS file. On Flaticon site only can be downloaded in PSD, SVG, BASE 64 I don't have code like .flaticon-research:before { content: "\f100"; }. How to get that? Is there any solution to convert SVG file to get that content or how? I don't want to download every single SVG file and from the SVG file get the icon. I want to use the above example method. Any help will be welcome. Thanks all
follow the instruction here https://www.flaticon.com/iconfonts
after downloading the font you will see multiple files show you how to use your icons depending on you using css or scss
I would like to use SVG and not to have to create a PNG fallback every time. Is the an easy solution to this problem? I have looked at these projects but can't tell whether they support it:
http://sie.sourceforge.jp/
http://code.google.com/p/svgweb/
try GruntIcon - http://github.com/filamentgroup/grunticon
grunticon takes a folder of SVG files (typically, icons that you've
drawn in an application like Adobe Illustrator), and outputs them to
CSS in 3 formats: svg data urls, png data urls, and a third fallback
CSS file with references to regular png images, which are also
automatically generated and placed in a folder.
grunticon also generates a small bit of JavaScript and CSS to drop
into your site, which asynchronously loads the appropriate icon CSS
depending on a browser's capabilities, and a preview HTML file with
that loader script in place.
There's quite a number of SVG polyfills:
https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills#svg
Please try them and update your initial question with the results for each.
I am building a meteor application for the first time and have run into some issues. In particular, I'm trying to get a picture viewer to work but the right and left arrows in the navigation buttons seem to be missing. When I attempt to load the images that are supposed to be in the button using google's developer tools, it's being displayed as an empty image. Thus, it's probably a case of me not putting the image file in the appropriate directory and as a result meteor is not able to load it in the css file. I'm not sure if this is the case or it's something else. It's probably not any syntax errors as I'm able to see the arrows in the button when I run the plugin outside of meteor.
Here's the line in my css file:
background: transparent url('themes.gif') no-repeat left top; margin-top: -45px;
So I managed to get it to work. I created a resources directory in the public folder and changed the url in the css file to url("/resources/button"), which seemed to do the trick.
You can leave your CSS as it is and put the themes.gif file in the /public directory of your Meteor app -- then it should be accessible.
Per the docs:
Lastly, the Meteor server will serve any files under the public directory, just like in a Rails or Django project. This is the place for images, favicon.ico, robots.txt, and anything else.
You have to prefix a / in front of your file name.
my web site architecture
body{
background-image: url('image/back1.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
}
Files need put to /public directory and remove "/public" in path from css.
For example:
If Image in path - /public/img/logo.png
Then use below CSS :
background-image('img/logo.png');
This is such a dumb issue, but here we go anyway. Here is my basic structure
/Content/twitter/bootstrap.css
/img/glyphicons-halflings.png
So Content and img are both in my root directory, so to referent the glyph image from my bootstrap.css file I have it like this:
background-image: url("../../img/glyphicons-halflings.png");
Y U NO SHOW?
Is there a .js file I need to check to make sure it is looking in the right directory??
oh and here is a snippet of where I am trying to get the image to render:
<td>
#if (item.Something == true)
{
<i class="icon-ok"></i>
}
else
{
<i class="icon-remove"></i>
}
</td>
UPDATE
There's been a lot of views of this question, so I thought I would share my two cents on it. One note, since posting the question BS 3.0 is now out, so it is possible the structure is different and/or irrelevant, have not looked at it yet. But if you got here, keep in mind this is pre-3.0 Bootstrap.
One thing I have started doing that makes it so I do not really have to mess with anything is bring the entire bootstrap folder into the project, rather than just the css/js/img folders. I typically put it in my root scripts folders with a structure like this:
/scripts
/libs
/boostrap <-- the unzipped folder you get when downloading
/js
/css
/img
This may break some conventions since a 'scripts' folder should really just hold scripts. I justify it since I use the scripts folder for scripts (surprise!) and third party libraries (thus the libs folder). Most third party components you get have at least js and css files with them, and I just got too lazy to can them manually separated since some libraries (like bootstrap) rely on where the other files are.
Anyway, my two cents, take a look at the answers below if you want to alter the file locations. All great tips, thanks SO folks!
Your current code should technically work and there is no need of any js file..
background-image: url("../../img/glyphicons-halflings.png"); is perfectly fine for a directory structure like
/Content/twitter/bootstrap.css
/img/glyphicons-halflings.png
You may try this code below to ensure that things are fine..
<td><i class="icon-ok"></i></td>
If this also fails then double check that glyphicons-halflings.png exists at your said path alongwith sufficient privileges..
try this
background-image: url("/img/glyphicons-halflings.png");
I changed the path from a relative path to an absolute path. By adding the slash at the beginning of the path, it starts from the root of your site.
Let me know if that works for you.
I encountered this same issue and it is not related to the source or location of your glyphicons. This is a race issue. I unfortunately cannot tell you the reason why it behaves like this in tables... but I know in my dataTables this was occuring and my way around it was to add the glyphicons after the page and tables load by appending html. It's not perfect but it works.
This may be an old post but I hope it helps someone else looking for an answer to this problem.
The file I downloaded contains an underscore but the CSS is looking for a file with a dash between glyphicons and halflings. Change one or the other and make sure it is uploaded to the correct folder on your server.
Copy the glyphicons-halflings.png & glyphicons-halflings-white.png From img Folder.
make a sub-folder with name "img" in css folder.
Paste the both glyphicons-halflings.png & glyphicons-halflings-white.png in css->img folder.
Open your bootstrap stylesheet e.g. Let's Say bootstrap.css in text Editor.
Find (Ctrl+F) "icon".
6.You will find the class.
[class^="icon-"],
[class*=" icon-"] {
display: inline-block;
width: 14px;
height: 14px;
margin-top: 1px;
*margin-right: .3em;
line-height: 14px;
vertical-align: text-top;
background-image: url("../img/glyphicons-halflings.png");
background-position: 14px 14px;
background-repeat: no-repeat;
}
change the background image url to
background-image: url("img/glyphicons-halflings.png");
find "glyphicons-halflings-white.png"
Change it's path also.
And Bingo! you are on it.
I encountered this same problem today and it had me confused. As Rishi says above, it should work, but it just didn't. I triple-checked my directory structure. Then eventually I realised that it wasn't hitting my glyphicons file at all. I removed this offending line of css:
<link href="css/font-awesome.min.css" rel="stylesheet"> <!-- remove me -->
And everything was good!
Remember that if you're going to include font-awesome, then it will look for the font files instead of the glyphicons file. So either add the appropriate fonts, or just use plain old bootstrap.
The glyph icons load only when you have the following files in the fonts folder.
glyphicons-halflings-regular.eot, glyphicons-halflings-regular.svg, glyphicons-halflings-regular.ttf and glyphicons-halflings-regular.woff.
Download the theme template or the carousel template of bootstrap, and you'll find these files there.
To know where to place these files in your web folder, just run Link Checker or Xenu's link sleuth and it'll show you where to place those files.
I want to refer to an image in my main stylesheet for a Grails app and I can't get it to work. My image lives in the standard location in my Grails app...
project\web-app\images\outbound-blue.png
In my stylesheet I want to use it as a background image for a class...
.messageimg {
height:17px;
width:16px;
background-image:url(images/outbound-blue.png);
background-repeat:no-repeat;
}
This doesn't work for some reason. My stylesheet is in the normal location too, i.e.
project\web-app\css\main.css
I get a missing image marker when I load the page in the browser. I have checked that I have no typos in names etc. I have also tried fiddling around with the virtual path in the url, but I can't figure out what I need to put in there to make this work in Grails.
I don't want to use GSP and insert an IMG tag into my code because I want to control the image through styles.
So, what am I doing wrong?
A more portable way to specify image locations is to use the resource() function:
.messageimg {
height:17px;
width:16px;
background-image:url('${resource(dir: "images", file: "outbound-blue.png")}');
background-repeat:no-repeat;
}
Try adding "../" at the beginning of the URI. For example:
../images/outbound-blue.png
The "../" at the start of the URI tells the browser to go up one level to the parent directory then look in the images directory. Currently you have it set up to look for a subdirectory called images in the directory containing stylesheets.
Be aware though. Using $resource{... does not work within a referenced .css file. You need to add a style element.
Typically you would reference a resource in a style sheet as a relative url. The url of your image should be relative to the CSS file's location. So ../images/outbound-blue.png from /appName/css/main.css will be referencing /appName/images/outbound-blue.png
If you are still having issues, You can debug this by using a tool like firebug to inspect the page and verify each step in your style.
Verify that:
The item that you think is being styled is picking up the styles.
The image that you are referencing can be accessed both manually, and via firebug.
The css file that you are loading isn't cached and is actually refreshed by the browser.
So the problem seemed to be that the browser was looking into
http://localhost:8080/<app-name>/assets/images/<background-image-name>
which seems correct but if you inspect other images on the page, they render from the path
http://localhost:8080/<app-name>/assets/background-image-name
So, just by excluding images in your path-name should fix the issue. However, this is just a work around which I am sure would have a better explaination and a solution. Cheers.