How to change style of background color using Vue.js only

user10462904 picture user10462904 · Nov 9, 2018 · Viewed 36.4k times · Source
import Vue from 'vue'
import App from './App'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'




Vue.config.productionTip = false
Vue.use(BootstrapVue);


/* eslint-disable no-new */
new Vue({
  el: '#app',
  components: { App },
  template: '<App/>'
})

i tried to change the background color of element with with vue bind styling using the command v-bind:style='{backgroundColor : color} but its not at full height, even though i tried to remove the margin and the padding for the body element on CSS but still not working as u can see on the pic thanks

#wrapper{
   
    width: 650px  ;
    height: auto;
    background-color: rgb(198, 241, 200);
    margin: 0 auto;
    margin-top: 200px;
    border-radius: 10px;
}
html, 
body {
    margin: 0;
    padding: 0;
    background-color:rgb(250, 28, 65);
}

screenshot

Answer

Boussadjra Brahim picture Boussadjra Brahim · Nov 9, 2018

bind your element to a style object as follows:

  <div :style="myStyle" id="wrapper">

in your data object :

     data(){
       return{
         myStyle:{
            backgroundColor:"#16a085" 
            }
          ...
           }
         }

You could check this i made several changes in your css rules without affecting the Vue logic