导航菜单布局

制作包含logo、菜单、按钮的3分离布局菜单

完成效果
在这里插入图片描述

准备html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <header>
        <img src="./logo.svg" alt="logo" class="logo">
        <nav>
            <ul class="nav_links">
                <li><a href="#">Html</a></li>
                <li><a href="#">CSS</a></li>
                <li><a href="#">JS</a></li>
            </ul>
        </nav>
        <a href="#"><button>Contact</button></a>
    </header>
</body>
</html>

编写css

*{
    box-sizing: border-box;
    margin: 0px;
    padding: 0px;
    background-color: black;
}
li,a,button{
    font-weight: 500;
    font-size: 16px;
    color: white;
    text-decoration: none;
}
header{
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 30px 10%;
}
.logo{
    cursor: pointer;
}
.nav_links{
    list-style: none;
}
.nav_links li{
    display: inline-block;
    padding: 0px 20px;
}
.nav_links li:nth-child(1){
    text-decoration: underline;
}
.nav_links li a{
    transition: all .3s ease 0s;
}
.nav_links li a:hover{
    color: aquamarine;
}
button{
    padding: 9px 25px;
    background-color: aquamarine;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all .3s ease 0s;
}
button:hover{
    background-color: rgba(127, 255, 212, .8);
}

补充

flex中的元素,可通过order配置顺序,数字越大,越靠后
margin-left: auto; 可控制所占位置,把左边的挤过去
.logo中添加

order: 3;
margin-left: auto;

变为
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值