无法水平对齐div

时间:2018-05-18 01:21:55

标签: html css center

我正在为此网站here添加一些新功能,并添加了Cookie通知。

如您所见,目前位于页面底部。

现在我希望这个只有1500px宽,整个通知集中。我已经尝试了很多技术来实现这一点,但它似乎是左边的中心,这可能是因为实时聊天窗口。我不太清楚为什么会这样,或者我怎么能绕过这一点。

这是我尝试的最新代码

#cookie-notice.cn-bottom.wp-default {
color: #fff;
font-family: lato;
font-style: normal;
height: 80px;
font-size: 16px;
background-color: #406639 !important;
/* display: block; */
display: block;
margin-left: auto;
margin-right: auto;
/* width: 50%; */

我试图实现的其他功能是将插件中的选项放入cookie顶部,这与已经存在的绿色顶部导航重叠。我尝试使用position:relativeposition:absolute以及其他CSS来尝试将其浮动到页面顶部而不重叠任何内容。所以订单如下

  • COOKIES NOTICE
  • GREEN TOP-BAR
  • NAV-BAR

然后当饼干达成协议时,通知将消失,绿色顶栏将位于顶部。尝试此操作时,Cookie通知和绿色顶栏只是重叠。

1 个答案:

答案 0 :(得分:0)

#cookie-notice div移除高度并添加顶部/底部填充将是解决此问题的更好方法。试试这段代码。

#cookie-notice.cn-bottom.wp-default {
    color: #fff;
    font-family: lato;
    font-style: normal;
    font-size: 16px;
    background-color: #406639 !important;
    display: block;
    padding: 20px 0;
}
相关问题