制作网站的副本



我正在使用HTML和CSS进行练习来制作此站点的副本https://www.raidhqgame.com/但是我在Menuareadiv中使用填充时发现了一些问题

html

<header> 
    <div class="head1"> 
        <div class="logoArea">
            <img id="logo" src="https://www.raidhqgame.com/images/RHQ_Logo_680x200.png" alt="RAID_HQ LOGO"/>
        </div>
    <div class="menuArea">
        <a href="#">HOME</a>
        <a href="#">FEATURES</a>
        <a href="#">VIDEO & SCREENS</a>
        <a href="#">REVIEWS</a>
        <a href="#">DOWNLOAD</a>
        <a href="#">HELP</a>
        <a href="#">EPS</a>
    </div>
</div>
<div class="background_img"> 
    <img src="https://www.raidhqgame.com/images/RAID_Web_BG_01_1500x800.jpg" alt="" />
</div>

CSS

body{
    margin:0;
    padding:0;
}
.head1{
    height:60px;
    background:black;
}
.logoArea{
    float:left;
    width:40%
}
#logo{
    height:40px;
    padding:10px 0px 10px 110px;
}
.menuArea{
    display:block;
    float:right;
    width:60%;
}
a:link{
    text-decoration:none;
    color: green;
    font-family: "Poppins",sans-serif;
    font-weight:bold;
    font-size:12px;
    letter-spacing: 1px;
}


问题:当我将填充物添加到菜单div时,菜单上跳下来。而且" head1"类和" background_img"类之间也存在差距。
我该如何解决这两个问题?

我认为您可能会通过在Head1 Div而不是菜单中添加填充来获得所需的效果。

这是您的更新代码:https://jsfiddle.net/ntb7nt39/

CSS

.head1{
    height:60px;
    background:black;
    padding: 20px; // You should change this value to whatever you want
}

',而且" head1"类和" background_img"类之间也存在差距。'我无法重现该差距。



更新

'我想为菜单部分提供填充。不是整个头1。'

我更新了代码:https://jsfiddle.net/ntb7nt39/1/

CSS

.head1{
    height: 80px; // Increased height to make space for the navigation bar
    background:black;
}
.menuArea{
    display:block;
    float:right;
    width:60%;
    padding: 20px 0; // Added padding at the top and bottom of the navigation bar, change these values according to your needs.
}
  1. 您可以从类Menuarea中删除宽度= 60%,而您将可以添加任何类型的填充或
  2. 仅使用顶部和底部填充物,没有左右填充物,因为您通过设置40%60%覆盖了整个100%宽度,当您添加左右填充时,会增加宽度,从而增加导致此问题的宽度。

和第二期增加高度:100%到徽标类别。

最新更新