导航栏在buefy中透明

时间:2020-03-12 14:10:47

标签: vue.js buefy

我正在创建一个美化工具,由于缺乏实践,我面临一些样式上的困难。

我想修改导航栏的背景,因此我想使背景透明,以便显示页面底部。我该怎么办?

enter image description here

<template>

<div class="Shellhub-LP-1280">
  <div class="textura Nuvem">

    <b-navbar>

      <template slot="brand">
          <b-navbar-item tag="router-link" :to="{ path: '/' }" transparent="true">
              <img
                  src="https://raw.githubusercontent.com/buefy/buefy/dev/static/img/buefy-logo.png"
                  alt="Lightweight UI components for Vue.js based on Bulma"
              >
              <!-- <img src="@/static/logo-inverted.png"> -->
          </b-navbar-item>
      </template>

      ...

    </b-navbar>
  </div>
</div>

</template>

<style>

.Shellhub-LP-1280 {
   /* width: 100%; */
   height: 2283px;
   background-color: #333640;
}

.textura {
   /* width: 100%; */
   height: 771px;
}

.Nuvem {
   width: 100%;
   height: 755px;
   object-fit: contain;
   opacity: 0.9;
   float: right;
   background: url('../static/nuvem.png');
   background-repeat: no-repeat;
   background-position: right;
}

谢谢

1 个答案:

答案 0 :(得分:2)

bufy navbar API:

https://buefy.org/documentation/navbar/#api-view

传递此道具:

<b-navbar :fixed-top="true"  :transparent="true" >

Vue文档-组件道具(建议阅读):


透明的“错误”:

打开 github 问题: BUG: navbar is-transparent not working

重要transparent影响navbar items(不是导航栏包装器本身)。

从导航栏项目中删除所有悬停或活动背景

因此添加简单的CSS样式:

nav.navbar.is-fixed-top {
  background: transparent;
}

身体顶部填充问题

我找不到消除身体顶部填充物的方法。我添加了这种样式:

body{
  padding-top: 0px!important;
}

基本示例:

const app = new Vue()
app.$mount('#app')
img.responsive_img{
  width: 100%;
  height: auto;
}
body{
  padding-top: 0px!important;
}

/* change navbar background color */
nav.navbar.is-fixed-top {
  background: transparent;
}
<link href="https://unpkg.com/buefy/dist/buefy.min.css" rel="stylesheet"/>

<div id="app">
    <b-navbar class="is-link" :fixed-top="true"  :transparent="true">
        <template slot="brand">
            <b-navbar-item tag="router-link" :to="{ path: '/' }">
                <img
src="https://raw.githubusercontent.com/buefy/buefy/dev/static/img/buefy-logo.png"
alt="Lightweight UI components for Vue.js based on Bulma"
                >
            </b-navbar-item>
        </template>
        <template slot="start">
            <b-navbar-item  href="#">
                Home
            </b-navbar-item>
            <b-navbar-item href="#">
                Documentation
            </b-navbar-item>
            <b-navbar-dropdown label="Info">
                <b-navbar-item href="#">
About
                </b-navbar-item>
                <b-navbar-item href="#">
Contact
                </b-navbar-item>
            </b-navbar-dropdown>
        </template>

        <template slot="end">
            <b-navbar-item tag="div">
                <div class="buttons">
<a class="button is-primary">
    <strong>Sign up</strong>
</a>
<a class="button is-light">
    Log in
</a>
                </div>
            </b-navbar-item>
        </template>
    </b-navbar>

    <header style="min-height: 200vh;">
      <img class="responsive_img" src="https://picsum.photos/2000/600"/> 
  </header>
</div>

<script src="https://unpkg.com/vue/dist/vue.min.js"></script>
<script src="https://unpkg.com/buefy/dist/buefy.min.js"></script>

更改滚动条上的导航栏背景颜色

only by custom code

请参阅此codepen(我在滚动条上添加了一个类): https://codepen.io/ezra_siton/pen/jOPZgmR

在滚动她时更改背景颜色:

nav.navbar.is-fixed-top.isActive{
  transition: background-color 0.5s ease;
  background: red; /* change color on scroll */
}

将导航栏链接颜色更改为白色(对于黑暗英雄)-添加“链接”修饰符: https://bulma.io/documentation/components/navbar/#colors

 <b-navbar  class="is-link" :fixed-top="true"  :transparent="true" >

删除悬停/活动

:transparent="true" 从导航栏项目中删除所有悬停或活动背景。