Html 菜单赢了';不要在视差图像的顶部

Html 菜单赢了';不要在视差图像的顶部,html,css,Html,Css,我试图在视差图像的顶部添加一个菜单,但是当我在CSS中将float:left添加到ull{}时,它会使菜单进入视差图像,而不是位于其顶部。需要帮助使菜单位于视差图像的顶部并固定,以便在向下滚动时,菜单保持在视差图像的上方 这是网站的HTML: <html> <head> <title>Croydon Cycles</title> <link rel="shortcut icon" type="image/png" href="images/

我试图在视差图像的顶部添加一个菜单,但是当我在CSS中将float:left添加到ull{}时,它会使菜单进入视差图像,而不是位于其顶部。需要帮助使菜单位于视差图像的顶部并固定,以便在向下滚动时,菜单保持在视差图像的上方

这是网站的HTML:

<html>

<head>
<title>Croydon Cycles</title>
<link rel="shortcut icon" type="image/png" href="images/favicon.png">
<link href="https://fonts.googleapis.com/css?family=Karla" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet">
<link href="style.css" rel= "stylesheet" type="text/css">
<script 

src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"> 
</script>
<script src="parallax.min.js"></script>
</head>

<body>


<div class="title">
     <img src="images/Logo.png" alt="Croydon Cycles" align="center">

</div>

<ul id="nav">
    <li><a href="#">Home</a></li>
    <li><a href="#">Contact</a></li>
    <li><a href="shop.html">Shop</a></li>
    <li><a href="#">Location</a></li>

</ul>




<div class="container">



    <div class="parallax" data-parallax="scroll" data-z-index="1">
        <div class="b1">
            <a href="shop.html">

                <input type="button" class="button" value="view all bikes" >
            </a>
        </div>




    </div>
    <p>The Croydon Cycles was founded in 2001 in order to promote and encourage 
            all areas of cyclesports. The club has a rich history of racing both on the 
            road and track. We also have an active social side and regular training trips away. 
            Croydon Cycles is located in mostly around Thornton heath pond, 
            however we still are active around all of Croydon.</p>


</div>


<div class="profiles">

        <p id="Header-1">Here are some of the members of Croydon Cycles:</p>

    <div class="pic-1">
        <img src="images/profile-1.jpg" alt="Proffesional biker"  height="280px" width="420px">
        <p>The Croydon Cycles was founded in 2001 in order to promote and encourage 
                all areas of cyclesports. The club has a rich history of racing both on the 
                road and track. We also have an active social side and regular training trips away. 
                Croydon Cycles is located in mostly around Thornton heath pond, 
                however we still are active around all of Croydon.</p>
    </div>



    <div class="pic-2">
    <img src="images/profile-2.jpg" alt="Proffesional biker"  height="280px" width="420px">
    <p>The Croydon Cycles was founded in 2001 in order to promote and encourage 
            all areas of cyclesports. The club has a rich history of racing both on the 
            road and track. We also have an active social side and regular traini.</p>
    </div>
</div>

</body>

</html>
    * {
    margin: 0;
    padding: 0;
    }


    p {
    font-family: 'Karla', sans-serif;
    margin: 2.5%;
    padding:0;
    }

   .title {
    text-align: center;
    }

   .container {

    margin: 0 auto;
    background: #f9f9f9;
    font-size: 24px;
    object-fit: cover;

}

.parallax {
    background: url('images/background-1.jpeg') no-repeat center;
    background-size: cover;
    background-attachment: fixed;
    height: 400px;
    min-height: 400px;


}

.b1{
    text-align: center;
}

.button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
    position: absolute;
    top: 65%;
    left: 45%;
}

.pic-1{
    height:280px; 
    width:420px;
    float: left;
    padding-left: 100px;
}


.pic-2{
    height:280px; 
    width:420px;
    float: right;
    padding-right: 100px;  

}

#Header-1 {
    font-family: 'Lobster', cursive;
    font-size: 35px;
}

ul {

}

ul li{
    list-style: none;
    display: inline-block;
    float:left;

}

ul li a{
    text-decoration: none;
}

尝试使用
headerBlock
类为标题和ul添加div父级,并添加以下内容:

.headerBlock {
  background-color: white;
  position: fixed;
  width: 100%;
}
比如这个例子

*{
保证金:0;
填充:0;
}
p{
字体系列:“卡拉”,无衬线;
利润率:2.5%;
填充:0;
}
.头衔{
文本对齐:居中;
}
.集装箱{
保证金:0自动;
背景#f9f9f9;
字体大小:24px;
对象匹配:覆盖;
}
.视差{
背景:url('http://via.placeholder.com/500x500“)无重复中心;
背景尺寸:封面;
背景附件:固定;
高度:400px;
最小高度:400px;
}
.b1{
文本对齐:居中;
}
.按钮{
背景色:#4CAF50;
边界:无;
颜色:白色;
填充:15px 32px;
文本对齐:居中;
文字装饰:无;
显示:内联块;
字体大小:16px;
利润:4倍2倍;
光标:指针;
位置:绝对位置;
最高:65%;
左:45%;
}
.pic-1{
高度:280px;
宽度:420px;
浮动:左;
左侧填充:100px;
}
.pic-2{
高度:280px;
宽度:420px;
浮动:对;
右边填充:100px;
}
#标题-1{
字体系列:“龙虾”,草书;
字体大小:35px;
}
.头锁{
背景色:白色;
位置:固定;
宽度:100%;
}

克罗伊登旋回
克罗伊登周期成立于2001年,旨在促进和鼓励 自行车运动的所有领域。该俱乐部有着丰富的历史,无论是在球场上还是在球场上 道路和轨道。我们也有积极的社交活动和定期的培训旅行。 Croydon Cycles主要位于Thornton heath pond附近, 然而,我们仍然活跃在克罗伊登全境

以下是克罗伊登旋回的一些成员:

克罗伊登周期成立于2001年,旨在促进和鼓励 自行车运动的所有领域。该俱乐部有着丰富的历史,无论是在球场上还是在球场上 道路和轨道。我们也有积极的社交活动和定期的培训旅行。 Croydon Cycles主要位于Thornton heath pond附近, 然而,我们仍然活跃在克罗伊登全境

克罗伊登周期成立于2001年,旨在促进和鼓励 自行车运动的所有领域。该俱乐部有着丰富的历史,无论是在球场上还是在球场上 道路和轨道。我们也有积极的社交活动和定期的培训


听起来您好像没有清除浮动。因此
ul
的高度基本上为0。查看如何使用ul li选择器中的
clear
属性remove float:left属性。我正在尝试在列表之间没有空格除了float:left;,还有其他代码可以这样做吗;?我试图使列表之间没有空格,所以我添加了float:left;对于ul标签,它完成了这项工作,但使菜单位于视差图像的左上方。我在添加ul标签时添加了您告诉我要添加的代码,以使我的菜单仍在视差图像中。您添加了headerblock div吗?你说的让列表之间没有空格是什么意思?是的,我添加了headerblock div,当你在列表上悬停时,指针在列表的间隙上下移动,一个关于如何创建菜单的视频显示了如何通过添加一个float:left;在ul li{}标记中,当我添加此项时,列表彼此相邻,没有空格,但它会出现在视差图像中,而不是在上面。我已经试验并发现,使用
    周围的导航标记和您的headerblock div代码,问题已经解决。非常感谢您花时间帮助我解决这个问题。很高兴我能帮忙:)