Home  >  Q&A  >  body text

How is application css overridden by BootstrapVue tables?

I have a simple BootstrapVue table.

CSS is defined in App.vue. This is the code for App.vue.

<template>
  <div id="app">
    <!-- <img alt="Vue logo" src="./assets/logo.png"> -->
    <TestTable msg="testing"/>
  </div>
</template>

<script>
import TestTable from './components/TestTable.vue'

export default {
  name: 'App',
  components: {
    TestTable
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;  
}
</style>

This is the code for TestTable.vue.

<template>
  <div>
    <b-table striped hover :items="items"></b-table>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        items: [
          { age: 40, first_name: 'Dickerson', last_name: 'Macdonald' },
          { age: 21, first_name: 'Larsen', last_name: 'Shaw' },
          { age: 89, first_name: 'Geneva', last_name: 'Wilson' },
          { age: 38, first_name: 'Jami', last_name: 'Carney' }
        ]
      }
    }
  }
</script>

margin-top: 60px Defined in App.vue. I want to modify TableTest.vue so that it covers the top of the margin of the CSS in App.vue. I want margin-top: 0px for TableTest.vue.

I'm using Vue v2.6 and Bootstrap-vue.

P粉545682500P粉545682500240 days ago322

reply all(2)I'll reply

  • P粉068510991

    P粉0685109912024-02-22 13:04:47

    You can trymargin-top:-60px;

    reply
    0
  • P粉821231319

    P粉8212313192024-02-22 11:49:21

    I commented on your question before, you applied margin-top: 60px in the parent component, while the child component has its own box model.

    Add a code snippet to show the structure of the component:

    Vue.component('item', {
      template:'#list-template',
      props:['item'],
    });
    
    var vm = new Vue({
      el:"#app",
      computed: {
        limitedItems() {
          return ['item1'];
        }
      }
    });
    #app {
      border: 2px solid black;
      margin-top: 60px;
    }
    sssccc
    

    reply
    0
  • Cancelreply