-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Icon Request: Spacer/Blank #1606
Comments
Can you please show an use case for this? Icons in fontawesome have not the same height or width (expecially the latter). You can make an icon invisible with a line of css or you can use "icon-fixed-with" class Examples:
|
I think the icon-fixed-width class, which i wasn't previously aware of, mostly sorts this out for my purposes, but for the record: In Bootstrap with the glyphicon sprite it was possible to use icon-spacer (or any other unrecognised classname of that format) and get a space the same size as the actual images, as a happy accident due to the way the CSS was written. I was wanting to recreate this with Font Awesome, and it turns out I can. As long as you add the icon-fixed-width class you can add icon-spacer (or any other unrecognized classname including just "icon-", and repeating "icon-fixed-width" would also work) and get a space the same size as the icons. Thinking about it now, since Font Awesome is constantly adding icons it might still be a good idea to claim one name which will continue to work like this in future (e.g. icon-blank, icon-nothing). The main use case would be to simplify the code needed to provide a blank space the same size as an icon since it would just be like any other icon. Particularly useful where you're provided with free text entry to specify an icon (since Font-Awesome is always growing) you can just tell them to use "spacer" rather than add a tickbox, or special case that in the code later. |
We can assume the average icon has 1em width, so .icon-spacer::before,
.icon-blank::before {
width: 1em;
content: ' ';
} I can provide a couple of examples where 1em doesn't fit the space of the missing icon: http://jsfiddle.net/tagliala/7VcZq/3/ (the red line should match where icon is missing) I don't know if this will fit average needs |
I think an average space is fine, if people want it to line up pixel-perfect regardless of icon choice then they need to use fixed-width anyway. |
I agree with ds125v. This is an useful feature. |
https://github.com/twbs/bootstrap/blob/master/less/glyphicons.less#L31 this "solution" is nice (but we need the new syntax and please remember: fontawesome icons have not the same width) |
icon-blank would be great. we store states for certain user actions in our database and some states need an icon, others don't. with a blank icon, i can just write code to display an icon, no matter what. without a blank icon, i need to check if there is an icon and then display it in just those cases. |
Since icons have not the same width by design, it's recommended to add Example: http://jsfiddle.net/tagliala/uHQXF/3/ In @rafaelsalomon like cases, if a class is needed for database validation, the following 5 lines of css will do the job (4, if the .icon-spacer::before,
.icon-blank::before {
width: 1em;
content: ' ';
} |
I assume that the use case is to create a space to show/toggle the icon later. What about setting visibility: hidden for any icon that should not be visible? That would maintain the width and leave the space for the exact width of the chosen icon. |
It's not so much for an icon that will be shown later but for a set of items where some will have a logo and some won't. And, yes, there are a million hacks or other ways to make it all work. But it would be really nice if there was a blank icon. Date: Wed, 6 Aug 2014 13:32:55 -0700 I assume that the use case is to create a space to show/toggle the icon later. What about setting visibility: hidden for any icon that should not be visible? That would maintain the width and leave the space for the exact width of the chosen icon. — |
Icons have not the same width by design. Use If you need to validate the database, allow empty values :) Take a look at this example: http://jsfiddle.net/tagliala/YQTup/ |
closing as dup of #754 |
Added to troubleshooting guide: https://github.com/FortAwesome/Font-Awesome/wiki/Troubleshooting#need-a-blankempty-icon Feel free to edit that guide, I'm not a native English speaker |
I found that I needed a spacer to keep equivalent heights in buttons, and doing content: ' ' wasn't enough. Using a non-breaking space did the trick:
|
Simpliest way I can think: First build a blank css class: and then add it where you want: |
Dare I say... the proper way is:
As many have already mentioned, you’ll need to set |
Of all the replies here, only one really is the answer. The problem is when you're trying to set a space using CSS and not the FA classes. You can't do a content: "\f101 " or content: " \f101" or whatever. THAT'S why people are asking for a space character, so they can specify one via custom CSS. Why would we do that? Because sometimes you need to change the DOM like on a mouse-over or when something changes. In any case, the solution is to use content: "\f101\A0" or content: "\A0\f101" or whatever you want. The "\A0" is the "trick" to add a space to FA when using a content CSS attribute. But really, FA should just add a space font to avoid confusion. Tim |
@teckel12 you should not use a space to dynamically replace an icon because icons have not the same width by design choice. This could result in text flickering or content width changing. Please keep using Fiddle showing the issue: https://jsfiddle.net/tagliala/hu6qksdb/2/ |
Picture a menu with icons followed by text on each line. If we don't have an icon to use for a given menu item, we still need to have a "spacer" icon there so the text of the menu items align.
|
@JoshMcCullough thanks for bringing this to our attention. Since your issue is related to the SVG framework and it is a legitimate use case, could you please open a new issue? Please also add a link to this fiddle https://jsfiddle.net/tagliala/wks0e6pa/31/ which is using FA5's syntax Meanwhile, you could fix this by removing the |
I find that setting
Then you can use: |
This code helped me |
Is it possible to have have icon-spacer return a blank/transparent/invisible "spacer" that would take up roughly the same size as a normal icon for the purpose of aligning things?
The text was updated successfully, but these errors were encountered: