我试图为html中的每个第二个元素创建一些背景颜色,使其与 nth-child(odd)颜色不同,但不知何故它不能正常工作,因为每个孩子都有背景颜色。
这是工作小提琴看到我的问题,因为它有很多HTMl要粘贴:)
https://jsfiddle.net/7xwgszwg/8/
public class IdentityConfig
{
public void Configuration(IAppBuilder app)
{
app.CreatePerOwinContext<AppDBContext>(AppDBContext.Create);
app.CreatePerOwinContext<AppUserManager>(AppUserManager.Create);
app.CreatePerOwinContext<AppRoleManager>(AppRoleManager.Create);
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
// Enables the application to validate the security stamp when the user logs in.
// This is a security feature which is used when you change a password or add an external login to your account.
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<AppUserManager, AppUser>(
validateInterval: TimeSpan.FromMinutes(15),
regenerateIdentity: (manager, user) => manager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie))
},
CookieName = "MyCookie",
//CookieDomain = "www.example.com",
//CookieHttpOnly = true,
//CookieSecure = CookieSecureOption.Always,
ExpireTimeSpan = TimeSpan.FromMinutes(double.Parse(ConfigurationManager.AppSettings["app:SessionTimeout"])),
SlidingExpiration = true
});
}
}
答案 0 :(得分:2)
除了h
中缺少nt-child
(应该是nth-child
)之外,问题是.acccesories-description
元素不是兄弟姐妹,而且nth-child
区分兄弟元素。
您很可能希望将nth-child
应用于.accesories-box-main
,然后将.acccesories-description
定位为着色
.accesories-box-main:nth-child(odd) .acccesories-description{
background-color:red;
}
演示
答案 1 :(得分:0)
你有拼写错误,nth-child()
你遗忘了h
:https://jsfiddle.net/7xwgszwg/4/