Glyphicon Pro in Bootstrap 3 - css

I would like to use Glyphicons Pro (Social and Filetypes as well). But bootstrap has a different way for icons.
In bootstrap: glyphicon glyphicon-ok
In glyphicon: glyphicon ok
IMHO the last option is better.
My question is: how can I use glyphicons pro in bootstrap, as the glyphicon class is already reserved by halflings.
My ideas:
remove halflings from bootstrap, and use the one provided by glyphicon
integrate the pro icons into bootstrap, but the mentioned question needs to be answered first
There are many similar questions on stackoverflow, and they are either about replacing halflings or not properly answered.

You should compile a Bootstrap version without the gylphicons component here.
Just uncheck Glyphicons under components, then go to the bottom and click "Compile and download".
After that you can include Glyphicons Pro without conflict in class names.

The following approach worked for me as of Bootstrap 3.3.6:
Download and extract Bootstrap source locally.
you#home:~$ mkdir bs3_src && cd bs3_src/
you#home:~bs3_src/$ git clone https://github.com/twbs/bootstrap.git .
Extract Glyphicons Pro package and navigate to the "Glyphicons Regular" family glyphicons.less file under (src)/glyphicons_pro/glyphicons/web/html_css/less. Replace bootstrap/less/glyphicons.less with this one. Replace all of the halfling font files with their glyphicons-regular.* counterparts from the PRO source into bootstrap/fonts/. If you desire the .social and .filetype fonts, add glyphicons-filetypes.less and glyphicons-social.lessfrom their respective subfolders into bootstrap/less/ (don't forget to push their font files to bootstrap/fonts/ as well).
Open bootstrap/less/bootstrap.less for editing. You are looking for the early import declarations:
...
#import "glyphicons.less";
// Extras go here:
#import "glyphicons-filetypes.less";
#import "glyphicons-social.less";
...
Install node/npm and grunt if you haven't done so yet as per Bootstrap's "Getting Started" section's instructions. Proceed:
you#home:~/bs3_src$ npm install
you#home:~/bs3_src$ grunt dist
By now your bootstrap/dist/ folder should have a glorious set of combined *.css, *.min.css and *.map files with the appropriate font families, along with all of the other PRO add-on goodies. Copy it's sub-folders into your project's assets and link accordingly.
The good thing about this approach is that it can be automated as a workflow (check this related post) to incorporate periodic updates from Bootstrap or Glyphicons, not to mention any custom .less that needs to be compiled.
As far as overriding the class schemes, i.e. "glyphicons glyphicons-ok" => "gi gi-ok": Any regex or repl type operation on the source less files before compiling would quickly achieve this. You'll simply have to be vigilant to make sure any of your other third-party apps aren't affected adversely.

Related

Font Awesome icons not being shown

I'm struggling with webpack to manage my assets right now.
I've installed font-awesome with yarn, and imported the .css files in my web page.
My problem is that, even though my html recognises the classes from font-awesome.css, the icons im trying to use are shown ass squares filled with four numbers (which identify the icon)
My webpack code is:
// webpack.config.js
var Encore = require('#symfony/webpack-encore');
const HandlebarsPrecompiler = require('webpack-handlebars-precompiler');
Encore
// the project directory where all compiled assets will be stored
.setOutputPath('web/build/')
// .addEntry('fs', 'empty')
// the public path used by the web server to access the previous directory
.setPublicPath('/build')
.addEntry('fonts/glyphicons-halflings-regular.ttf', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf')
.addEntry('fonts/glyphicons-halflings-regular.eot', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.eot')
.addEntry('fonts/glyphicons-halflings-regular.svg', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.svg')
.addEntry('fonts/glyphicons-halflings-regular.woff', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff')
.addEntry('fonts/glyphicons-halflings-regular.woff2', './node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2')
.addEntry('fonts/font-awesome', './node_modules/components-font-awesome/css/fontawesome.css')
.addEntry('fonts/fontawesome-webfont.eot', './node_modules/font-awesome/fonts/fontawesome-webfont.eot')
.addEntry('fonts/fontawesome-webfont.svg', './node_modules/font-awesome/fonts/fontawesome-webfont.svg')
.addEntry('fonts/fontawesome-webfont.ttf', './node_modules/font-awesome/fonts/fontawesome-webfont.ttf')
.addEntry('fonts/fontawesome-webfont.woff', './node_modules/font-awesome/fonts/fontawesome-webfont.woff')
.addEntry('fonts/fontawesome-webfont.woff2', './node_modules/font-awesome/fonts/fontawesome-webfont.woff2')
.addEntry('css/bootstrap', './node_modules/bootstrap/dist/css/bootstrap.css')
.addEntry('css/bootstrap-theme', './node_modules/bootstrap/dist/css/bootstrap-theme.css')
.addEntry('css/bootstrap-datepicker', './node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.css')
.addEntry('css/app', './src/SgbBundle/Resources/public/css/app.css')
// export the final configuration
module.exports = Encore.getWebpackConfig();
The thing is that in the inspector, when I see the rules being used in some html content like
<i class="fa fa-graduation-cap fa-4x" aria-hidden="true" id="icon"></i>
recognises the 'fa' class, the 'fa-4x' class but no the 'fa-graduation-cap' class. And the icon is shown as an empty square.
Thanks.
I've found the answer.
I've installed two versions of font-awesome via Yarn add.
One is components-font-awesome and the other one just font-awesome.
If you check on my webpack configuration, Im adding files from this two dependencies.
.addEntry('fonts/font-awesome', './node_modules/components-font-awesome/css/fontawesome.css')
.addEntry('fonts/fontawesome-webfont.eot', './node_modules/font-awesome/fonts/fontawesome-webfont.eot')
I solved my issue by just using font-awesome
.addEntry('fonts/font-awesome', './node_modules/font-awesome/css/fontawesome.css')
.addEntry('fonts/fontawesome-webfont.eot', './node_modules/font-awesome/fonts/fontawesome-webfont.eot')
And deleting 'components-font-awesome'.
To sum up, I was trying to use files from two same but different packages.
fa-graduation-cap is a new icon class in Font Awesome 5.0.0. The equivalent icon class in version 4 was fa-mortar-board.
So you'd need to make sure that you're loading Font Awesome 5 and not 4 if you want to use that v4 name. It's not evident from your code listing above which version of Font Awesome you're loading.
You can find a reference on upgrading from version 4 to version 5, including the full list of icon classes that changed from v4 to v5 here.
Or if you're stuck in Font Awesome 4 and you need a version 4 reference to lookup icon names and codes, make sure you use the older one here. A link to that is found in the footer links on fontawesome.com.
try adding it from CDN, The link is below
https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css
There is No error in tag

Target Angular 4 CSS to a single page div

Good afternoon.
Premise: I’m not a web developer and I have little familiarity with all these new names that emerge as mushrooms from one moment to the next. Then I ask you not to give nothing for granted.
My question is very simple: I want to target bootstrap 4 style only on a specific elements (e.g. a div) of my page: the rest of the page hasn't to be involved with this styles.
I notice that a colleague of mine used LESS on an older bootstrap version but I red that it is not support in Bootrastrap 4.
Any ideas?
Thanks,
Sergio
I think to have found the solution but I'd like know if it is the right way.
Here my steps:
I downloaded Bootstrap 4 files using
npm install bootstrap#4.0.0-alpha.6
from dos prompt inside a local folder
Then I modified bootstrap.scss file placed inside node_modules\bootstrap\scss surrounding all code with a class (e.g. .thisismyclass{...})
I then downloaded Koala from this site
http://koala-app.com/
I added the entire local folder (where the boostrap files are) in the Koala UI.
Automatically it create the .css files near the scss files with the reference to my manually added class.
Now, in my page, I added the refernce to my new css and then I added my main class to the div which must use Bootstrap styles.
It's right?
Thanks,
Sergio

Bootstrap not including any glyphicons

First time using bootstrap. I added "bootstrap":"3.3.7" to my dependencies in my bower.json file and it adds to my wwwroot/lib folder but I know it's supposed to include a fonts folder in the bootstrap directory, but it's not there. I tried downloading the bootstrap.zip file from their website, extracting that file and then adding the fonts folder included in that download to my bootstrap directory, but it still didn't work. I've tried looking in bootstrap.css file for the #font-face for glyphicons but there are none. I am just learning how to implement everything into an ASP.Net Core app so I'm new to these technologies.
I think the #font-face is defined in fontawesome. Also, unless you have at least one html element using the font, it will not be requested. So you need to use the font in a style rule (the #font-face doesn't count).
Therefore, download fontawesome and then add an element to your html and then the font will be requested. An element like this for example:
<span class="glyphicon glyphicon-asterisk"></span>

How to build bootstrap version 4 so that the CSS only contains specific parts, such as grid?

Bootstrap version 3 has a nifty web tool, on their site, that lets you customize the CSS file. You can choose which styles the CSS file will include, such as the grid styles, code styles, or specific components such as navbars, etc.
The bootstrap version 4 site does not have this, yet. I'm trying to figure out how to build this type of CSS file using the cloned repository.
How can I build bootstrap version 4 so that the CSS file only contains the specific styles that I need?
(1) Download bootstrap source from github https://github.com/twbs/bootstrap there is button in green to download if you don't have git.
(2) Install ruby and sass follow instructions at http://sass-lang.com/install
(3) cd into scss folder of the source you've downloaded
(4) change bootstrap.scss file to import only components you need for example if you dont need card remove #import "card"
(5) In terminal or command prompt cd into scss folder
(6) Run sass bootstrap.scss bootstrap-custom.css instead of bootstrap-custom you can put any name you want
(7) file named bootstrap-custom.css is generated use it however you want;

Twitter Bootstrap Customization responsive

I want to set up bootstrap like that Twitter Bootstrap Customization Best Practices
I want though the responsive version. I found this thread Twitter Bootstrap responsive css is not generated form the less files
but it's not clear to me how can I set up bootstrap files so I can customized it using the responsive version ?
If you are wondering how to use less to customise the bootstrap css and then use this in your project, then there are basic approaches.
You can combine your customisation into the base bootstrap css files and import this into your project, or you can leave the bootstrap files untouched, create a second css file for your customisation and import this into your project as well, after the bootstrap css.
Overwrite vs override.
From the first link you give, you can see that both approaches have their supporters.
I've usually used the first method, and this is what I've done.
Download a copy of the less files, here is one source, and add to your project files
Open the bootstrap.less file. You'll see that it orchestrates everything and imports the individual less files
Create theme-variables.less and theme-css.less files and save to this less folder
You need to import these files in the right sequence. Adding the variables file at the end of the Core variables and mixins block with #import "theme-variables.less"; and the theme file at the end of the Base CSS block with #import "theme-css.less"; works for me. Depending on what you are customising, you may need to play with this a bit
That's basically it. Edit your custom files, compile bootstrap.less, and import the resulting bootstrap css file(s) into your project.
Naturally at the start you want to keep good backups incase something goes wrong, and likewise when you upgrade Bootstrap.
Good luck!
First download form https://github.com/twbs/bootstrap less version
How to use Less and less compilers
http://lesscss.org/
http://winless.org/
Bootstrap tutorial
http://www.w3resource.com/twitter-bootstrap/tutorial.php

Resources