Bundling and minifying the font awesome css. in mvc 4 - css

I am trying to minify the font awesome.css but when i minimize it shows the different junk characters for content like :
{ content: "\f048"; }
above are content icons like up arrow etc....
What are the option to overcome this problem?
Thanks

Maybe I'm mis-understanding what you're asking, but those aren't junk characters. Those are the Unicode code points that Font Awesome uses (specifically the Private Use Area). They absolutely should be in your minified CSS. Or you can use the minified CSS that comes with Font Awesome.

I've run into this before. When you minify you need to specify a charset.
In your project's config set the xml's encoding to:
<?xml version="1.0" encoding="utf-8"?>
If you're uncomfortable messing with the config or don't have access you can modify the CSS.
#charset "UTF-8";
In both cases it must be the first line of the file. If you are concatenating it needs to be only in the first file.

I solved it using YUI Bundle Transformer
Installed it via NuGet Packages
Code looks like this:
var cssBundle = (new StyleBundle("~/bundles/css").Include(
"~/Content/css/font-awesome.css");
cssBundle.Transforms.Add(new CssTransformer(new YuiCssMinifier()));
bundles.Add(cssBundle);

Try to register via CssRewriteUrlTransform.
For example:
bundles
.Add(new StyleBundle("~/Content/utilities")
.Include("~/Content/font-awesome.min.css", new CssRewriteUrlTransform()));

Related

Random custom.css file took over my scss code

My scss code stopped working. I identified the problem - two css files: custom.css.css and custom.css.css.map. I'm not using bootstrap, just ror. How do I make ruby ignore them? Or shouldn't I? The layout looks exactly the same, the code is easier to read (but not neat enough for my liking).
.map files are called source maps and they are used by browsers to display css files. I guess you are using SASS or LESS as you having a .map file generated. You may need to enable source maps in browsers to display the styles correctly. I hope following urls might help you.
Sass source files in Google Chrome
Sass Source Maps + Chrome = Magic

GWT, there is a way to ignore the CSS ID's generated when the code is compiled?

I'm using GWT in a new project that I'm working on and I'm facing a problem. Some of the CSS rules were defined into the XML file and not into a CSS file.
The problem is that when GWT compiles the code, my name classes defined into my XML file are changed to a new random ID.
Stuffs like GKA-VPPBPE or GKA-VPPBLE
Is there is a way to keep the original name instead of the generated ones?
The generation of obfuscated css classnames is a feature.
GWT has enabled CSS obfuscation activated by default. This will help reduce the download size and also reduce collision of css-classnames.
You can disable this in general:
<set-configuration-property name="CssResource.style" value="pretty"/>
Or for some classes only:
#external .myClassName
Look here for some more information
https://vcfvct.wordpress.com/2013/10/04/disable-obfuscation-in-gwt-css-resources/

Navigate to SASS class instead of CSS from HTML in PhpStorm?

Is there any way to make JetBrains PhpStortm (v8) to navigate to the SASS file when I Ctrl+cilck on a CSS class/id in the HTML source, insted of the default (to the CSS file class/id) setting? It would be great, and I cant find a soloution. Thanks in advance!
It's not really supported:
https://youtrack.jetbrains.com/issue/WEB-6737
https://youtrack.jetbrains.com/issue/WEB-8190
Please star/vote/comment to get notified on progress.
Although I have to say that in LESS it's kind of works for simple classes/ids (not made from parts via & or multi-level ones): it asks to which declaration to go and offers me 2 files: file.css or file.less.
I found a half-solution!
If I link the scss file in the head, then I can select the SASS declaration. Yay! :D
<link href="/css/sass/main.scss">
Thats work for me.
For PhpStorm I solved this with:
In the project browser, right click on the .css file that you'd
like to ignore.
Go to "Override file type".
Select "Plain text".
Now when you command click a style it will navigate directly to the .scss file and NOT the .css file. The .css file will be read by the browser but ignored by PhpStorm.

Bootstrap 3 unable to display glyphicon properly

I am migrating from bootstrap 2.3 to bootstrap 3 and everything works well. But when I tried to add some icons, the icon font doesn't displayed properly. I tried to look over here http://bootply.com/61521 and only '.glyphicon-envelope' was being displayed properly. Others have displayed like 'E001' and so on.
How can I be able to solve this problem?
For other browsers, glyphicons are displayed properly, only firefox was unables to display it properly.
Did you choose the customized version of Bootstrap? There is an issue that the font files included in the customized package are broken (see https://github.com/twbs/bootstrap/issues/9925). If you do not want to use the CDN, you have to download them manually and replace your own fonts with the downloaded ones:
https://netdna.bootstrapcdn.com/bootstrap/3.0.0/fonts/glyphicons-halflings-regular.svg
https://netdna.bootstrapcdn.com/bootstrap/3.0.0/fonts/glyphicons-halflings-regular.woff
https://netdna.bootstrapcdn.com/bootstrap/3.0.0/fonts/glyphicons-halflings-regular.ttf
https://netdna.bootstrapcdn.com/bootstrap/3.0.0/fonts/glyphicons-halflings-regular.eot
After that try a strong reload (CTRL + F5), hope it helps.
the icons and the css are now seperated out from bootstrap. here is a fiddle that is from another stackoverflow answer
#import url("//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc2/css/bootstrap-glyphicons.css");
http://jsfiddle.net/aQrPd/1/
Bootstrap 3 Glyphicons CDN
OK, my problem was not answered by the above. I had the fonts folder at the same location as the bootstrap css and js folders (eg /theme/bootstrap3/..), but it was looking for the font folder in the root (eg /fonts/glyph.. .woff)
The solution for me was to set the #icon-font-path variable to the correct relative path:
Eg #icon-font-path: "fonts/";
Here's the fix that worked for me. Firefox has a file origin policy that causes this. To fix do the following steps:
open about:config in firefox
Find security.fileuri.strict_origin_policy property and change it from ‘true’ to ‘false.’
Voial! you are good to go!
Details:
http://stuffandnonsense.co.uk/blog/about/firefoxs_file_uri_origin_policy_and_web_fonts
You will only see this issue when accessing a file using file:/// protocol
I had the same problem using a local apache server. This solved my problem:
http://www.ifusio.com/blog/firefox-issue-with-twitter-bootstrap-glyphicons
For Amazon s3 you need to edit your CORS configuration:
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<MaxAgeSeconds>3000</MaxAgeSeconds>
<AllowedHeader>Authorization</AllowedHeader>
</CORSRule>
</CORSConfiguration>
First of all, I try to install the glyphicons fonts by the "oficial" way, with the zip file. I could not do it.
This is my step-by-step solution:
Go to the web page of Bootstrap and then to the "Components"
section.
Open the browser console. In Chrome, Ctrl+Shift+C.
In section Resources, inside Frames/getbootstrap.com/Fonts you will
find the font that actually is running the glyphicons. It's
recommended to use the private mode to evade cache.
With URL of
the font file (right-click on the file showed on resources list),
copy it in a new tab, and press ENTER. This will download the font
file.
Copy another time the URL in a tab and change the font
extension to eot, ttf, svg or woff, ass you like.
However, for a more easy acces, this is the link of the woff file.
http://getbootstrap.com/dist/fonts/glyphicons-halflings-regular.woff
I ended up switching to Font-Awesome Icons. They are just as good if not better, and all you need to do is link in the font, happy days.
make sure the name of the folder that contains the font name is "fonts" not "font"
you can use tag like this:
<i class="fa fa-edit"></i>
Just in case :
For example, I just tryed <span class="icones glyphicon glyphicon-pen">
and after one hour i realized that this icon was not included in the bootstrap pack !! While the enveloppe icon was working fine..
Hope this helps
As others have noted, there are some issues with the customizer.
I was having troubles with the glyphicons not showing either, as well as issues with the navbar layout.
I used the suggestion and uploaded the fonts from the full zip/overwrote the ones from the customized version and that fixed the icons issues.
I also pulled in the CDN CSS and javascript instead of my local copy from the CDN. This fixed my navbar issues.
So I recommend until you get the hang of Bootstrap, not to use the customized version since you might get some frustrating, unwanted results.
For me placing my fonts folder as per location specified in bootstrap.css solved the problem
Mostly its fonts folder should be in parent directory of bootstrap.css file .
I faced this problem , and researching many answers , if anyone still in 2015 faces this problem then its either a CSS problem , or location mismatch for files .
The bug has already been solved by bootstrap
This is the official documentation supporting the above answers.
Changing the icon font location
Bootstrap assumes icon font files will be located in the ../fonts/ directory, relative to the compiled CSS files. Moving or renaming those font files means updating the CSS in one of three ways:
Change the #icon-font-path and/or #icon-font-name variables in the source Less files.
Utilize the relative URLs option provided by the Less compiler.
Change the url() paths in the compiled CSS.
Use whatever option best suits your specific development setup.
Other than this one mistake the new users would do is, after downloading the bootstrap zip from the official website. They would tend to skip the fonts folder for copying in their dev setup. So missing fonts folder can also lead to this problem
Try using CDN
Try setting Access-Control-Allow-Origin HTTP Header

Twitter Bootstrap LESS css

I am wondering why I cant set variables within twitter bootstrap using LESS. I am using ruby on rails which has a bootstrap_and_overrides.css.less file. it has the following statement
// Your custom LESS stylesheets goes here
//
// Since bootstrap was imported above you have access to its mixins which
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/less.html for their names and documentation
//
// Example:
// #linkColor: #ff0000;
So my understanding is that i can set my variables within here. So i set
#black: #333;
and then tried using it in my application.css calling #black file but it does not work? i.e. doesn’t render #333.
Am i understanding this incorrectly?, do all my variables and css styling go within the bootstrap and override file?
Any advice appreciated
Follow the instructions at http://lesscss.org/#usage to make sure your updated less is used, if you are using it client side.
OR
Compile your updated less into CSS and then copy over the updated CSS.
Here's a list of tools that can do the compile. http://bootstrap.lesscss.ru/less.html#compiling
For suggestions on how to organize your bootstrap modifications see the SO question Twitter Bootstrap Customization Best Practices
As an aside, I wouldn't recommend changing #black. Changing it would alter many, many things, including some you might not expect.
If I understood you correctly, you are modifying your bootstrap_and_overrides.css.less file, but the one being used is the application.css file.
If that was the case, of course it's is just natural not to reflect the changes you've made. You must compile your .less file first to .css. to reflect that changes to your .css file.
For a try, use LESS via the client-side and setup your environment like so:
For instance, in your index.html file, put
<link rel="stylesheet/less" type="text/css" href="application.less" />
in the document head. and below it add
<script src="less.js" type="text/javascript"></script>
Download the less.js file from here. and put it inside your root directory, or you may of course customize the location and make the necessary path in the href attrib.
After doing the above, you're ready to modify your application.less file (not the application.css). You may copy you're existing custom styles from the application.css file.
application.less is where you should put your variables.
You may rename your bootstrap_and_overrides.css.less file into application.less and make sure it is the one linked to in the header tag.
For more info about LESS CSS checkout the wiki.

Resources