HTML+CSS简单导航栏实现

HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>导航栏</title>
    <link rel="stylesheet" href="index.css">
</head>
<body>
    <div class="container">
        <div class="navigation">
            <span class="logo"><b>LOGO</b></span>
            <ul>
                <li><a href="">Home</a></li>
                <li><a href="">Produce</a></li>
                <li><a href="">Contact</a></li>
                <li><a href="">About</a></li>
            </ul>
            <div class="search">
                <input type="text" placeholder="Please enter your msg">
                <button>
                    Search
                </button>
            </div>
            <span class="head_pic">&nbsp;</span>
            <span>
                <button>Sign in</button>
                <button>Sign up</button>
            </span>
        </div>
        <div class="content">
            
        </div>
        <div class="a">

        </div>
    </div>
</body>
</html>

CSS:

*{
    padding: 0;
    margin: 0;
}
html,body{
    height: 100%;
}
/* 容器 */
.container{
    width: 100%;
    height: 100%;
}
/* 导航栏 */
.container div.navigation{
    width: 100%;
    height: 50px;
    position: fixed;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: whitesmoke;
}
a{
    text-decoration: none;
}
ul{
    width: 35%;
    display: inline;
    list-style-type: none;
    line-height: 40px;
}
ul li{
    float: left;
    width: 25%;
    text-align: center;
}
li a{
    display: block;
    padding: 5px;
    color: black;
    font-size: 18px;
    font-family: 'Courier New', Courier, monospace;
}
li a:hover{
    background-color: wheat;
}
.navigation span.logo{
    width: 5%;
    height: 40px;
    margin-left: 10px;
    padding: 5px;
    text-align: center;
    font-size: 20px;
    letter-spacing: 2px;
    font-family:'Times New Roman', Times, serif;
    cursor: pointer;
}

.search{
    line-height: 40px;
    width: 25%;
    transition: width 2s;
}
.search:hover{
    width: 35%;
}
.search input[type=text]{
    float: left;
    width: 70%;
    height: 40px;
    border: none;
    background-color: lightgray;
    border-top-left-radius: 10px;
    border-bottom-left-radius: 10px;
    /* transition: width 2s; */
}
.search button{
    float: left;
    width: 30%;
    height: 40px;
    border: none;
    background-color: skyblue;
    border-top-right-radius: 10px;
    border-bottom-right-radius: 10px;
    font-size: 16px;
    color: white;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
}
.navigation span.head_pic{
    line-height: 40px;
    width: 40px;
    background: purple;
    background-image: url('cat.jpeg');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    border-radius: 50%;
    text-decoration: none;
    cursor: pointer;
}
.navigation span{
    width: 12%;
    margin-right: 10px;
    line-height: 40px;
}
.navigation span button{
    height: 40px;
    width: 70px;
    padding: 1px;
    border: none;
    border-radius: 20px;
    font-size: 15px;
    color: white;
    font-family: 'Courier New', Courier, monospace;
    cursor: pointer;
}
span button:first-child{
    float: left;
    background-color: orange;
}
span button:last-child{
    float: right;
    background-color:orange;
}
/* 获取焦点时右边不显示 */
div input[type=text]:focus{
    outline-width: 1px;
    outline-style: solid;
    outline-color: skyblue;
}
div input[type=text]::placeholder{
    font-size: 14px;
    letter-spacing: 1px;
}
div span button:hover{
    background-color: rgb(165, 111, 11);
}
/* 中间内容 */
.container div.content{
    height: 80%;
    /* margin-top: 10%; */
    background: none;
    background-color: green;
}
/* 展示内容 */
.a{
    height: 50%;
    background-color: blueviolet;
}

图片资源:

效果图:

 

 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值