【问题标题】:How to use my icon image with glyphicon class in bootstrap如何在引导程序中将我的图标图像与 glyphicon 类一起使用
【发布时间】:2015-08-08 05:02:40
【问题描述】:

您好,我正在使用 mvc 5,它集成了引导程序类,我必须在我的菜单中使用字形图标,我想将我的图标图像用作字形图标,所以我希望在不影响预定义引导程序类的情况下,我对我的引导程序执行相同操作bootsrap 中带有新创建的 css 类的图标图像。

【问题讨论】:

    标签: twitter-bootstrap-3 asp.net-mvc-5


    【解决方案1】:

    很难理解您在寻找什么。您确实应该发布一个示例,但在这里尝试并提供帮助。

    来自 Bootstrap 网站:

    不要与其他组件混用图标类不能直接 与其他组件相结合。它们不应与 同一元素上的其他类。相反,添加一个嵌套并应用 图标类。

    仅用于空元素图标类只能用于 不包含文本内容且没有子元素的元素。

    正确使用:

    <a href="@Url.Action("Action", "Controller")" class="btn btn-warning">
        link text 
        <span class="glyphicon glyphicon-plus-sign"/>
    </a>
    

    如果您想使用 Bootstrap 以外的自定义 css 类,则创建一个新的 css 文件,所有您的所有类都包含在其中,甚至是您想要从引导程序覆盖的类,然后将该 css 文件加载到位于 App_Start 中的捆绑文件中目录。如下图。

    public class BundleConfig
        {
            // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
            public static void RegisterBundles(BundleCollection bundles)
            {
                bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                            "~/Scripts/jquery-{version}.js"));
    
                bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                            "~/Scripts/jquery.validate*"));
    
                // Use the development version of Modernizr to develop with and learn from. Then, when you're
                // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
                bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                            "~/Scripts/modernizr-*"));
    
                bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                          "~/Scripts/bootstrap.js",
                          "~/Scripts/respond.js"));
    
                bundles.Add(new StyleBundle("~/Content/css").Include(
                          "~/Content/bootstrap.css",
                          "~/Content/site.css",
                          "~/Content/YOURCUSTOMCSSGOESHERE.css  
                              ));
            }
        }
    

    【讨论】:

      猜你喜欢
      • 2017-06-17
      • 2016-12-07
      • 1970-01-01
      • 1970-01-01
      • 2021-12-16
      • 2017-10-15
      • 2012-06-08
      • 1970-01-01
      • 2013-09-17
      相关资源
      最近更新 更多