gpt4 book ai didi

html - 在 CSS 中格式化 topnav

转载 作者:行者123 更新时间:2023-11-28 03:15:04 26 4
gpt4 key购买 nike

谁能帮我弄清楚如何将我的菜单栏 (w/id = "topnav") 置于我的 HTML 页面顶部的中心?我尝试了一堆背景大小的东西,但似乎没有任何效果。我希望它固定并在滚动时水平填充页面。

#topnav a{
text-decoration: none;
color: #000;
padding-left: 50px;
padding-right: 50px;
padding-bottom: 10px;
}

#topnav{
font-family: Courier;
text-align: center;
padding: 15px;
position: fixed;
left: 50%;
transform: translateX(-50%);
background: white;
/*background-size: 100% auto !important;*/
}

最佳答案

您是否尝试过将宽度设置为 100%?

编辑:

#topnav{
font-family: Courier;
text-align: center;
padding: 15px;
position: fixed;
left: 50%;
transform: translateX(-50%);
background: black;
/*background-size: 100% auto !important;*/
width: 100%;
top: 0;
}

这应该可行

关于html - 在 CSS 中格式化 topnav,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45517256/

26 4 0