html - 复制站点

标签 html css copy padding

我正在尝试使用 html 和 css 制作此站点的副本以进行练习 https://www.raidhqgame.com/ 但是我在 menuArea div 中使用 padding 时发现了一些问题。

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;
}


问题:当我向 menuArea div 添加填充时,menuArea 会向下跳。而且“head1”类和“background_img”类之间也有差距。
我该如何解决这两个问题?

最佳答案

我认为您可以通过向 head1 div 而不是 menuArea 添加填充来获得所需的效果。

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

CSS

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

'“head1”类和“background_img”类之间也存在差距。'我无法重现该差距。

更新

'我想为菜单部分添加填充。不是整个脑袋。”

我更新了代码: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.
}

关于html - 复制站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46079785/

相关文章:

typescript - Ionic 2 : Pass param to next page as copy, 未通过引用

javascript - 触发焦点操作,但仅当不是由于单击而触发时

jquery - 匹配不同尺寸的浏览器时,如何用父元素的specific固定一个元素的位置

css - 为所有东西设置最大高度——最佳实践?

python - 在 Python 中复制对象?

python-3.x - 如何使用对象的内部引用克隆/深度复制 Python 3.x 字典

c# - 如何从 C#.net 传递包含\n 和\t 的长文本的 javascript 参数

javascript - .load 获取页面,但不显示

javascript - 如何为按钮着色并保持状态?

html - 如何在 CSS 中使 'ease out' 失去焦点