gpt4 book ai didi

HTML 元素未进入顶栏

转载 作者:太空宇宙 更新时间:2023-11-04 01:33:44 26 4
gpt4 key购买 nike

我一直致力于开发一个简单的网站,以提高我在 HTML 和 CSS 方面的技能。我一直遇到一个问题,我似乎无法让类中的某些元素进入页面顶部的栏。

这是 html 的片段。

<body>
<!-- A logo will go here but here is some text for now -->
<h1 ID="Logo">Website</h1>
<img Class="Social" src="assets/facebook.png"/>
<img Class="Social" src="assets/twitter.png"/>
<img Class="Social" src="assets/instagram.png"/>
<img Class="Social" src="assets/snapchat.png"/>
<!-- The menu bar -->
<ul class="menu" ID="Menu_Bar">
<li Class="Menu_Item" ID="Home">
<a Class="Menu_Link" href="index.html">Home</a>
</li>
<li Class="Menu_Item" ID="About_Us">
<a Class="Menu_Link" href="about.html">About Us</a>
</li>
<li Class="Menu_Item" ID="Events">
<a Class="Menu_Link" href="events.html">Events</a>
</li>
<li Class="Menu_Item" ID="Contact">
<a Class="Menu_Link" href="contact.html">Contact Us</a>
</li>
</ul>
<!-- An image-->
<img ID="theGang" src="https://static.pexels.com/photos/126407/pexels-photo-126407.jpeg"/>
</body>

ID Logo 使顶栏横跨整个屏幕顶部,我似乎无法让“社交”类中的元素进入该顶栏。他们似乎就坐在它的正下方。

这是CSS。

/* allows elements to use the full lengths of the webpage */
* {
margin: 0px;
border: 0px;
padding: 0px;
}

body {
margin: 0px;
padding: 0px;
}

/* this is the formatting for the logo */
#Logo{
font-family: 'Germania One', cursive;
font-size: 80px;
color: #2E2F44;
background-color: #DE1B2B;
}

.Social {
float: right;

}

/*
*=== Formats the menu bar for the webpage
*===Begin===*
*/
.menu{
position: fixed;
width: 100%;
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #2E2F44;
font-family: 'Germania One', cursive;
font-size: 20px;
}

.Menu_Item{
float: left;
}

.Menu_Item .Menu_Link {
display: block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

.Menu_Item .Menu_Link:hover {
background-color: #DE1B2B;
}
/*
*===End===*
*/

/* Formats the header image, 'z-index' makes the image fall behind the nav bar */
#theGang{
position: absolute;
max-width: 100%;
height: auto;
display: none;
z-index: -1;
}

最佳答案

如果您将 display: inline-block 添加到 #Logo css 规则,这将使 #Logo 保持在左侧,而 .Social 元素,这是您要查找的内容,还是要保留红色条和“网站”一词旁边的 .Social 元素?

关于HTML 元素未进入顶栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46628767/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com