asp.net mvc 4 tabs

前端 未结 4 1067
难免孤独
难免孤独 2020-12-05 08:43

I\'m working on a project with Visual Studio 2010 ASP.Net MVC4 (engine view Razor) and need to make a tabs. I define this scrips and css:



        
相关标签:
4条回答
  • 2020-12-05 08:55

    Bootstrap 3.x solution:

    <ul class="nav nav-tabs">
        <li class="active">
            <a href="#tab_1" data-toggle="tab">Tab Header 1</a>
        </li>
        <li>
            <a href="#tab_2" data-toggle="tab">Tab Header 2</a>
        </li>
        <li>
            <a href="#tab_3" data-toggle="tab">Tab Header 3</a>
        </li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane fade active" id="tab_1">
            <p>Content for Tab 1 goes here.</p>
        </div>
        <div class="tab-pane fade" id="tab_2">
            <p>Content for Tab 2 goes here.</p>
        </div>
        <div class="tab-pane fade" id="tab_3">
            <p>Content for Tab 3 goes here.</p>
        </div>
    </div>
    
    0 讨论(0)
  • 2020-12-05 09:07

    Just to add Bootstrap 3.x solution. I encountered a problem using class="tab-pane fade active" id="tab_1", the entries in tab_1 will not display upon page load.

    Instead, I removed fade in the tab_1 (see below)

    <div class="tab-pane active" id="tab_1">
        <p>Content for Tab 1 goes here.</p>
    </div>
    

    or replace it with class="tab-pane fade active in"

    It worked for me.

    0 讨论(0)
  • 2020-12-05 09:09

    Here is a jsfiddle for Jquery Tabs.

    Step 1: Import

    <link href="@Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.24.min.js")" type="text/javascript"></script>
    

    Step 2: Html Code

    In the ‘li’ tags you need to define the tab header and for each tab header a tab content div exists, the code below is pretty self explanatory.

    <div id="tabs">
    
    <ul>
        <li><a href="#tabs-1">Tab Header 1</a></li>
        <li><a href="#tabs-2">Tab Header 2</a></li>
        <li><a href="#tabs-3">Tab Header 3</a></li>
    </ul>
    
    <div id="tabs-1">
    Content for Tab 1 goes here.<br/>
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
    sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    </div>
    
    <div id="tabs-2">
    Content for Tab 2 goes here.<br/>
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
    sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    </div>
    
    <div id="tabs-3">
    Content for Tab 3 goes here.<br/>
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
    sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
    </div>
    
    </div>
    

    Step 3: Final Touch – Jquery call to tabs()

    <script type="text/javascript">
        $(function () {
            $("#tabs").tabs();
        });
    </script>
    

    Output:

    enter image description here

    Source

    0 讨论(0)
  • 2020-12-05 09:11

    If you work with ASP.net MVC4 then config _Layout.cshtml add this lines into Head html

    @Styles.Render("~/Content/css")    
    @Styles.Render("~/Content/themes/base/css")
    @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/jqueryui")
    @Scripts.Render("~/bundles/modernizr")
    

    and delete from body (html) this line

    @Scripts.Render("~/bundles/jquery")
    

    and execute the program and show the tabs

    0 讨论(0)
提交回复
热议问题