我正在尝试对我正在构建的网站使用一些媒体查询.然而,我遇到的问题是,当媒体查询样式实际被应用时,它们被覆盖.我不能为我的生活告诉为什么,因为我使用相同的精确选择器.任何人都可以指出我没有看到的东西吗?
原始CSS
#global-wrapper-outer > #global-wrapper-inner {
width: 85%;
height: 100%;
margin: 0 auto;
position: relative;
}
#global-wrapper-outer > #global-wrapper-inner > nav {
background: #fff;
padding-bottom: 20px;
box-shadow: 0 4px 2px -2px gray;
}
Run Code Online (Sandbox Code Playgroud)
媒体查询CSS
@media screen and (max-width:1024px) {
#global-wrapper-outer > #global-wrapper-inner {
width: 100%;
}
#global-wrapper-outer > #global-wrapper-inner > nav {
display: none;
}
}
Run Code Online (Sandbox Code Playgroud)
第二个媒体查询工作正常,我将导航设置为无显示.但是,当我尝试将#global-wrapper-inner的宽度设置为100%时,它不适用.当我按下F12并选择该元素时,我可以看到样式被"应用".但是,样式本身被划掉并且实际上没有应用,它仍然具有85%的原始宽度.
希望标题有意义,我会尽力描述我的问题.
我目前正在开发ASP.NET Web API.在我的"公司"控制器中,我有一个GetCompany()动作.
/// <summary>
/// Gets the 'Authorization-Token' request header and finds the company with the
/// matching decrypted token from the database, returns it; if null, returns 404
/// </summary>
/// <returns>Matching company for token passed in request or 404 if null</returns>
[HttpGet][ResponseType(typeof(Company))]
[Route("api/company/")]
public HttpResponseMessage GetCompany() {
string token = Request.Headers.GetValues("Authorization-Token").First();
ICollection<Company> companies;
Company c;
using (BaseRepository r = new BaseRepository()) {
companies = r.Get<Company>(null, null, null);
c = companies.Where(cm => RSA.Decrypt(cm.Token) == token).FirstOrDefault<Company>();
}
if …Run Code Online (Sandbox Code Playgroud) 我在我的Global.asax文件中使用此代码来捕获所有404错误并将它们重定向到自定义控制器/视图.
protected void Application_Error(object sender, EventArgs e) {
Exception exception = Server.GetLastError();
Response.Clear();
HttpException httpException = exception as HttpException;
if (httpException != null) {
if (httpException.GetHttpCode() == 404) {
RouteData routeData = new RouteData();
routeData.Values.Add("controller", "Error");
routeData.Values.Add("action", "Index");
Server.ClearError();
IController errorController = new webbage.chat.Controllers.ErrorController();
Response.StatusCode = 404;
errorController.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
}
}
}
Run Code Online (Sandbox Code Playgroud)
我现在有三个控制器用于我的应用程序Users,Rooms和Home
当我输入类似的东西{localhost}/rooms/999(这会导致它抛出404,因为999是一个无效的房间ID),它重定向和呈现就好了,一切都按预期工作.
但是,如果我输入一个无效的控制器名称,{localhost}/test它会将它重定向到它应该的视图,但是当它呈现它只是HTML作为纯文本.有人能指出为什么会这样做吗?
这是我的ErrorController
public class ErrorController : Controller {
public ActionResult Index() {
return View();
} …Run Code Online (Sandbox Code Playgroud) 我正在使用AngularJS创建一个SignalR服务,该服务连接到我指定的集线器并公开.on和.invoke方法,以便我的控制器可以监听来自服务器的事件并调用服务器上的方法.
这是我服务的相关部分:
return {
on: function (eventName, callback) {
hub.on(eventName, function (result) {
$root.$apply(function () {
if (callback) {
callback(result);
}
});
});
},
ready: function (callback) {
return isLoaded.then(function () {
callback();
});
},
invoke: function (methodName, args, callback) {
return hub.invoke.apply(hub, $.merge([methodName], $.makeArray(args))).done(function (result) {
$root.$apply(function () {
if (callback) {
callback(result);
}
});
});
},
connection: connection
};
Run Code Online (Sandbox Code Playgroud)
我的集线器连接完美,但是当我尝试调用我的调用时,没有任何反应.这就是我所说的:
var chatHub = hub('chatHub');
chatHub.on('userConnected', function (user) {
console.log(user);
});
chatHub.ready(function () {
chatHub.invoke('Connect', …Run Code Online (Sandbox Code Playgroud) 我在我的网站中动态设置ul元素的宽度时遇到问题.
下面是我正在使用的jQuery
var button = $("#navbar");
alert(button);
var count = $("#header li").length;
alert(count);
$("#navbar").style.Width = count * 110
Run Code Online (Sandbox Code Playgroud)
这是HTML
<div id="header" class="clearfix">
<div class="clearfix hidden">
<img src="/Content/Images/main-logo.png">
</div>
<div id="navbar">
<ul>
<li id="home">
home
</li>
<li id="portfolio">
portfolio
</li>
<li id="about">
about
</li>
</ul>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
"alert(button)"返回[object Object],所以它不是null(至少我对它的理解),但每当我尝试设置它的宽度时,我都会得到标题中提到的错误.
谁知道我做错了什么?
我正在尝试创建一个VSIX包来部署我使用的一些常见的应用程序布局,但是当我创建项目模板然后将模板文件放在我的VSIX包中并构建它时,我Unexpected character '$'在我的一些中收到了很多消息命名空间上的C#类.根据文档,这应该是正确的格式.
这是抛出错误的类之一
using System.Web.Optimization;
namespace $safeprojectname$ {
public class BundleConfig {
public static void Register(BundleCollection bundles) {
bundles.Add(new StyleBundle("~/styles/site")
.IncludeDirectory("~/assets/styles", "*.css"));
bundles.Add(new ScriptBundle("~/scripts/libs")
.IncludeDirectory("~/assets/libs/jquery", "*.js")
.IncludeDirectory("~/assets/libs/bootstrap", "*.js")
.Include("~/assets/libs/angular/angular.js")
.Include("~/assets/libs/angular/angular-sanitize.js")
.Include("~/assets/libs/angular/angular-animate.js")
.IncludeDirectory("~/assets/libs/angular-ui", "*.js")
.IncludeDirectory("~/assets/scripts", "*.js"));
bundles.Add(new ScriptBundle("~/scripts/app")
//.IncludeDirectory("~/common/directives", "*.js")
//.IncludeDirectory("~/common/filters", "*.js")
//.IncludeDirectory("~/common/services", "*.js")
.Include("~/app/home/app.home.js")
.IncludeDirectory("~/app/home/controllers", "*.js")
.Include("~/app/app.js"));
}
}
}
Run Code Online (Sandbox Code Playgroud)
我检查了我的vstemplate文件,这就是它对该文件/文件夹的作用
<Folder Name="startup" TargetFolderName="startup">
<ProjectItem ReplaceParameters="true" TargetFileName="BundleConfig.cs">BundleConfig.cs</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="WebApiConfig.cs">WebApiConfig.cs</ProjectItem>
</Folder>
Run Code Online (Sandbox Code Playgroud) 我试图在一个页面上设置一个变量,然后将其显示在另一页上。两个页面都存在于同一域中。我以前从未使用过 sessionStorage,所以我不确定我在哪里犯了错误。由于某种原因,第二页只是一张空白页。这是第一页上设置变量的代码。
if (typeof(Storage) != "undefined") {
// Store
sessionStorage.setItem("score", 12);
document.getElementById("result").innerHTML = ("score");
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
}
Run Code Online (Sandbox Code Playgroud)
这是第二页上的代码,应该检索变量并将其打印到屏幕上。
if (typeof(Storage) != "undefined") {
// Retrieve
document.getElementById("result").innerHTML = sessionStorage.getItem("score");
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
}
Run Code Online (Sandbox Code Playgroud)
任何关于为什么没有得到变量的见解都会非常感谢。