简体   繁体   English

HTML和CSS。 我的div类对CSS没有反应

[英]Html and css. My div class doesn't react to css

I created a div class and called it .center in CSS. 我创建了一个div类,并在CSS .center其称为.center When doing all the styling it doesn't react when shown in browser. 进行所有样式设置时,在浏览器中显示时不起作用。 I made the exact same thing with the same code when creating the home page. 创建主页时,我用相同的代码做了完全相同的事情。 However when I do the same thing for the second page nothing happens. 但是,当我为第二页做同样的事情时,什么也没发生。

 .center { position: absolute; left: -25%; top: 85%; width: 100%; text-align: center; font-size: 18px; font-family: 'Anton', sans-serif; color: white; } 
 <div style="cursor:pointer; position: absolute; width: 59px; height: 42px; left: 687px; top: 29px;" onclick="openNav()"> <div class="fa fa-angle-double-down" style="font-size:50px; color:white; hover: black;"></div> <div class="center">Menu</div> </div> 

I have the same attributes for the homepage and the menu text is white with the font family and have the hover effect. 我对主页具有相同的属性,菜单文本与字体家族为白色,并且具有悬停效果。 However on this page it doesn't react to the CSS it's just plain black with standard font. 但是,在此页面上,它对CSS无效,只是纯黑色的标准字体。

Your div.center is positioned absolutely in relation to its parent. 您的div.center绝对相对于其父项定位。 Do this: 做这个:

.center {
  position: absolute;
  margin-left: auto;
  margin-right: auto;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 18px;
  font-family: 'Anton', sans-serif;
  color: #FFF;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM