Javascript 由于Visual Studio MVC中的div,CSS未加载

Javascript 由于Visual Studio MVC中的div,CSS未加载,javascript,jquery,css,razor,model-view-controller,Javascript,Jquery,Css,Razor,Model View Controller,我使用的是visual studio 2013 MVC,我的_布局有一个模板,所有脚本都加载到我的视图索引中,在我的_布局中我有一个导航栏,导航栏应该有一个使用大量css和js的消息下拉菜单 当我以部分视图的形式加载消息时,一切都正常,但当我尝试使用JQuery自己重新加载数据时,我必须将其放入div中。这样做会破坏所有样式,就像没有Css一样,我还尝试更改父div的id,这也会破坏样式。我正在使用AdminLTE 2 示例: 当它是这样的时候,它就起作用了 <li class="drop

我使用的是visual studio 2013 MVC,我的_布局有一个模板,所有脚本都加载到我的视图索引中,在我的_布局中我有一个导航栏,导航栏应该有一个使用大量css和js的消息下拉菜单

当我以部分视图的形式加载消息时,一切都正常,但当我尝试使用JQuery自己重新加载数据时,我必须将其放入div中。这样做会破坏所有样式,就像没有Css一样,我还尝试更改父div的id,这也会破坏样式。我正在使用AdminLTE 2

示例:

当它是这样的时候,它就起作用了

<li class="dropdown notifications-menu">
  <!-- Menu toggle button -->
  @Html.Action("Notifications", "Home")
</li>
如何使样式工作或使用不同的方法不断重新加载该零件?我认为,主要是任何不使用div的东西都可以工作

我正在从数据库加载数据,所以它必须通过控制器

在_布局上,我只放置了管理员的
,然后在页面的主要区域放置了呈现索引的
@renderbody()
。该索引包含Adminlte模板和大多数带有样式的脚本的

<style type="text/css">
    .dropdown {font-size:2em;} 
    .notifications-menu {color:red;} 
    .dropdown div, .notifications-menu div {font-weight:bold;}
</style>

.下拉列表{字体大小:2em;}
.通知菜单{颜色:红色;}
.dropdown div、.notifications菜单div{font-weight:bold;}
和列表项

<ul>
    <li class="dropdown notifications-menu">
        <!-- Menu toggle button -->
        @Html.Action("Notifications", "Home") 
    </li>
</ul>
<ul>
    <li class="dropdown notifications-menu">
        <!-- Menu toggle button -->
        <div>
            @Html.Action("Notifications", "Home")
        </div>
    </li>
</ul>
  • @动作(“通知”、“主页”)
  • @动作(“通知”、“主页”)

我看不到类选择器.下拉菜单或.notifications菜单提供的样式的效果有什么不同,对div元素的额外特殊性也如预期的那样起作用。您的样式选择器是如何声明的?

我不确定您的问题是否正确,但通常不能在内联元素中使用块(div、a等)元素,除了通过css将block元素更改为内联元素外:其他元素都在模板bower_components/bootstrap/dist/css/bootstrap.min.css bower_components/font awesome/css/font-awesome.min.css bower_components/Ionicons/css/Ionicons.min.css dist/css/AdminLTE.min.css dist/css/css/skins/skins/skin-blue.min.css附带的css中声明dist/css/skins/skin-green.min.css选择器中包含.dropdown或.notifications菜单的样式是什么?不是在什么文件中声明的-值是什么?
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
    <i class="fa fa-bell-o"></i>
    <span class="label label-warning">@ViewBag.Notifications</span>
</a>
<ul class="dropdown-menu">
    <li class="header">Tiene @ViewBag.Notifications notificaciones</li>
    <li>
        <!-- Inner Menu: contains the notifications -->
        <ul class="menu" style=" max-height: 200px; margin: 0; padding: 0; list-style: none; overflow-x: hidden;">
            @foreach (string notification in ViewBag.NotificationMsgs) {
            <li>
                @{string[] detail = notification.Split('|');}

                <!-- start notification -->

                <a href="@detail[8]">
                    <i class="fa @detail[3] @detail[4]"></i> @detail[5]<br />@detail[2]
                </a>
            </li>
            }
            <!-- end notification -->
        </ul>
    </li>
    <li class="footer"><a href="#">Ver todas</a></li>
</ul>
<style type="text/css">
    .dropdown {font-size:2em;} 
    .notifications-menu {color:red;} 
    .dropdown div, .notifications-menu div {font-weight:bold;}
</style>
<ul>
    <li class="dropdown notifications-menu">
        <!-- Menu toggle button -->
        @Html.Action("Notifications", "Home") 
    </li>
</ul>
<ul>
    <li class="dropdown notifications-menu">
        <!-- Menu toggle button -->
        <div>
            @Html.Action("Notifications", "Home")
        </div>
    </li>
</ul>