简体   繁体   English

在引导程序之外使用glyphicon

[英]Using a glyphicon outside of bootstrap

How does one use a glyphicon without using bootstrap? 如何在不使用引导程序的情况下使用glyphicon

I like one particular glyphicon. 我喜欢一只特殊的雕ly。 It's called glyphicons-chevron-left. 它叫做glyphicons-chevron-left。 All it gives is this 它所提供的就是这个
<span class="glyphicons glyphicons-chevron-left"></span>

I've downloaded the free version and found the .png I needed and used it as such: 我已经下载了免费版本,并找到了我需要的.png并使用了它:

<input type="image" src="images/glyphicons-chevron-left.png" class = "back_btn"/>

But then, when I give this button height and width the image loses quality. 但是,当我指定此按钮的高度和宽度时,图像质量下降。 I was wondering if there is a way to do it better? 我想知道是否有更好的方法?

This is because Glyphicon is a font: one file containing all the icons in special vector format which allows resizing (if you resize a png image it will become ugly). 这是因为Glyphicon是一种字体:一个包含所有图标的特殊矢量格式的文件,该文件允许调整大小(如果您调整png图像的大小,它将变得很丑陋)。 You can directly download the Glyphicons on their website or even create your own set of icons if you only need some by using a tool like Icomoon (maybe Icomoon does not offer to select icons from Glyphicons, but you will surely find equivalent icons in other sets). 您可以直接在他们的网站上下载Glyphicons,或者如果只需要使用Icomoon之类的工具来创建图标,甚至可以创建自己的图标集(也许Icomoon不提供从Glyphicons中选择图标的功能,但是您肯定会在其他图标集中找到等效的图标)。

You have three options other than the one you have already tried. 除了已经尝试过的选项以外,您还有其他三个选项。

SVG SVG

You can use an SVG image rather than a PNG, which will not pixellate as you make it bigger or smaller as its a vector. 您可以使用SVG图像而不是PNG,当您将其作为矢量放大或缩小时,它不会像素化。

The disadvantage of this is some older browsers don't have SVG support (IE 8 and below I believe) 这样做的缺点是某些较旧的浏览器不支持SVG(我相信IE 8及以下版本)

FontAwesome / Other icon font family FontAwesome /其他图标字体家族

These are cross browser compatible so you won't have that problem. 这些是跨浏览器兼容的,因此您不会遇到问题。 However you will have to load in an entire font just to use one character. 但是,仅使用一个字符就必须加载整个字体。 Which probably isn't ideal. 这可能不是理想的。 It is still better than loading in the entire bootstrap css library though. 不过,它仍然比加载整个Bootstrap CSS库更好。

Customise Bootstrap 自定义引导

Alternatively your third option is to head over to bootstraps website and customise your build and just include the glyphicons icons. 另外,您的第三个选择是前往引导网站并自定义您的构建 ,只包含字形图标。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM