gpt4 book ai didi

css - 部分 View 使用错误的 css 样式表,即使没有链接

转载 作者:行者123 更新时间:2023-11-28 05:31:50 25 4
gpt4 key购买 nike

首先,我创建了名为“showCatButton.cshtml”的部分 View 并与 CategoryList2.css 样式表相关联。

body {

}

#mainMenu{
left:0px;
position:fixed;
top:50%;
transform: translateY(-50%);
list-style-type:none;
}
.subMenu {
list-style-type:none;
}
li
{
width:300px;
height:50px;
border-radius:5px;
background:linear-gradient(to bottom, #45484d 0%,#000000 100%);
color:white;
border:1px solid black;
text-align:center;
}
li:hover
{
color:black;
background:linear-gradient(to bottom, #e6e6e6 30%,#e6e6e6 40%,#e6e6e6 50%
, #f2f2f2 60%, #f2f2f2 70%, #f2f2f2 80%, #f2f2f2 90%, #f2f2f2 100%);
}
#mainMenu li ul {
display:none;
}
#mainMenu li:hover ul {
display:block;
position:absolute;
top:0px;
left:300px;
}
<html>
<head>
<meta name="viewport" content="width=device-width" />
<link type="text/css" rel="stylesheet" href="~/Content/CategoryList2.css"/>
</head>

<body>
<ul id="mainMenu">
some-unimportant code.
</ul>
</body>
</html>

接下来我创建了 Header 部分 View 。使用以下代码。

<html>
<head>
<meta name="viewport" content="width=device-width" />
</head>

<body>
<script src='@Url.Content("~/Scripts/jquery-3.1.0.min.js")' type="text/javascript"></script>
<script src='@Url.Content("~/Scripts/jquery-ui-1.11.4.min.js")' type="text/javascript"></script>
<div id="Header">
<ul>
<li>
Main
</li>
<li>
Delivery methods
</li>
<li>
About shop
</li>
<li>
Contacts
</li>
</ul>
</div>


</body>
</html>
即使没有链接,它也使用 CategoryList2.css 样式表。尽管我没有添加任何链接。我通过以下代码将部分 View 添加到链接。
@using OnlineShop.Models;
@using System.Data.Entity;


@{
Layout = null;
}
<html>
<head>

<meta name="viewport" content="width=device-width" />
<title>Main page</title>
<link type="text/css" rel="stylesheet" href="~/Content/MainPage.css" />
</head>
<body>

<div>
@Html.Partial("~/Views/PartialViews/Header.cshtml")
</div>
<div id="CategoryList">
@Html.Partial("~/Views/PartialViews/showCatButton.cshtml")
</div><br/>
</body>
</html>
有什么问题吗?

最佳答案

那些不是部分 View ,它们是完整的 html 页面。将部分 View 视为包含在其父 View 中的一段 html。没有任何 html body 或 head 标签。你已经从 parent 那里继承了那些。

我会将样式和脚本保存在一个地方,即父页面。假设您在部分 View 中拥有所有可用的内容。

关于css - 部分 View 使用错误的 css 样式表,即使没有链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38467141/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com