龙空技术网

vue项目header模块编写

一步走到头 211

前言:

今天同学们对“css里面header”可能比较注意,你们都需要学习一些“css里面header”的相关内容。那么小编同时在网络上搜集了一些对于“css里面header””的相关文章,希望你们能喜欢,我们一起来学习一下吧!

前端学习的太差了,一个header写了半天才写个勉强能用的。

vue-cli引入scss

npm install node-sass --savenpm install sass-loader --save

从element-ui官方拷贝一个导航栏修改

<div class="myHeader">        <div class="headBack">            <el-row class="container">                <el-col :span="24">                    <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect" text-color="#000">                        <el-menu-item index="1">处理中心</el-menu-item>                        <el-submenu index="2">                            <template slot="title">我的工作台</template>                            <el-menu-item index="2-1">选项1</el-menu-item>                            <el-menu-item index="2-2">选项2</el-menu-item>                            <el-menu-item index="2-3">选项3</el-menu-item>                            <el-submenu index="2-4">                                <template slot="title">选项4</template>                                <el-menu-item index="2-4-1">选项1</el-menu-item>                                <el-menu-item index="2-4-2">选项2</el-menu-item>                                <el-menu-item index="2-4-3">选项3</el-menu-item>                            </el-submenu>                        </el-submenu>                        <el-menu-item index="4"><a href="; target="_blank">订单管理</a></el-menu-item>                    </el-menu>                </el-col>            </el-row>        </div>    </div>

css样式完善

/*顶部导航栏盒子*/.myHeader {  /** 导航栏固定在顶部*/  .headBack{    width: 100%;    background: rgba(40,52,44,0.6);    box-shadow: 0 2px 4px rgba(0,0,0,0.2);    position: fixed;    left: 0;    top: 0;    z-index: 100;  }  .headBox .el-menu {    background: transparent;    border-bottom: none!important;  }  .headBox .el-menu-demo li.el-menu-item,  .headBox .el-menu--horizontal .el-submenu .el-submenu__title {    height: 38px;    line-height: 38px;    border-bottom: none!important;  }  //导航栏字体修改  .headBox .el-submenu div.el-submenu__title{    color: #fff;  }  .el-menu--horizontal >ul ,  .headBox>ul li.el-menu-item:hover,  .headBox>ul li.el-submenu:hover .el-submenu__title,  .headBox ul .el-submenu .el-menu .el-menu-item ,  .headBox .el-menu--horizontal.menu  ul{    background: #48456C;    border-bottom: none;    box-shadow: 0 0 0px 0 rgba(0, 0, 0, 0.1) !important;  }  // 如果展开颜色显示和下拉列表一致  .is-opened{    background: #48456C !important;  }  // 菜单右边  .userInfo{    position: absolute;    right: 30px;    color: #ffffff;    line-height: 38px;  }   .userInfo a {    color: #fff;    font-size: 13px;    transition: all 0.2s ease-out;  }  .headBox .userInfo a:hover {    color: #48456C;  }  .pcsearchbox{    max-width: 170px;    height: 100%;    line-height: 38px;    position: absolute;    top: 0;    right: 0;    cursor: pointer;  }  /*pc搜索框*/  .headBox .pcsearchbox {    padding: 0;    max-width: 170px;    /*min-width: 30px;*/    height: 100%;    line-height: 38px;    position: absolute;    top: 0;    right: 0;    cursor: pointer;  }  .headBox .pcsearchbox:hover .pcsearchinput {    opacity: 1;    /*transform: scaleX(1);*/    visibility: visible;  }  .headBox .pcsearchbox i.pcsearchicon {    color: #fff;    padding-left: 10px;  }  .headBox .pcsearchbox .pcsearchinput {    width: 180px;    padding: 10px 20px 10px 20px;    background: rgba(40, 42, 44, 0.6);    border-radius: 0 0 2px 2px;    position: absolute;    right: 0;    top: 38px;    opacity: 0;    visibility: hidden;    /*transform: scaleX(0);*/    transform-origin: right;    transition: all 0.5s ease-out;  }  .headBox .pcsearchbox .hasSearched {    opacity: 1;    /*transform: scaleX(1);*/    visibility: visible;  }  .headBox .pcsearchbox .el-input {    width: 100%;  }  .headBox .el-input__inner {    height: 30px;    border: none;    background: #fff;    /*border: 1px solid #333;*/    border-radius: 2px;    padding-right: 10px;  }}/*下拉选项菜单*/.el-menu--horizontal .el-menu .el-menu-item,.el-menu--horizontal .el-menu .el-submenu__title {  background-color: #64609E !important;  float: none;  height: 36px;  line-height: 36px;  color: #909399;  position: relative;}//  下拉菜单body > div.el-menu--horizontal.menu > ul{  list-style: none;  position: relative;  margin: 0;  z-index: 100;  min-width: 130px;  border: none;  padding:  0;  border-radius: 2px;  box-shadow: 0 0px 0px 0 rgba(0, 0, 0, 0.1);}body > div.el-menu--horizontal.menu > ul > li:hover {  background: #48456C !important;}

修改后的页面

<template>    <div class="myHeader">        <div class="headBack">            <el-row class="container">                <el-col :span="24">                    <!-- pc端导航 -->                    <div class="headBox">                        <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal"                                 @select="handleSelect" text-color="#fff">                            <el-menu-item index="1">处理中心</el-menu-item>                            <el-submenu index="2" popper-class="menu">                                <template slot="title">我的工作台</template>                                <el-menu-item index="2-1">选项1</el-menu-item>                                <el-menu-item index="2-2">选项2</el-menu-item>                                <el-menu-item index="2-3">选项3</el-menu-item>                            </el-submenu>                            <el-menu-item index="4"><a href="; target="_blank">订单管理</a></el-menu-item>                            <div index="" class="pcsearchbox">                                <i class="el-icon-search pcsearchicon"></i>                                <div class="pcsearchinput" :class="input?'hasSearched':''">                                    <el-input placeholder="搜索" icon="search" v-model="input" :on-icon-click="searchEnterFun" @keyup.enter.native="searchEnterFun" @change="searchChangeFun">                                    </el-input>                                </div>                            </div>                            <div class="userInfo">                                <div v-show="!haslogin" class="nologin">                                    <a href="javascript:void(0);" @click="logoinFun(1)">登录 </a>|<a href="javascript:void(0);" @click="logoinFun(0)"> 注册</a>                                </div>                                <div v-show="haslogin" class="haslogin">                                    <i class="fa fa-fw fa-user-circle userImg"></i>                                    <ul class="haslogin-info">                                        <li>                                            <a href="#/UserInfo">个人中心</a>                                        </li>                                        <li>                                            <a href="#/LikeCollect?like=1">喜欢列表</a>                                        </li>                                        <li>                                            <a href="#/LikeCollect?like=2">收藏列表</a>                                        </li>                                        <li>                                            <a href="javascript:void(0);" @click="userlogout">退出登录</a>                                        </li>                                    </ul>                                </div>                            </div>                        </el-menu>                    </div>                </el-col>            </el-row>        </div>    </div></template><script>    export default {        name: ""    }</script><style lang="scss">    @import "../static/css/header.scss";</style>

效果

标签: #css里面header