I am using vuejs-datepicker in one of my vue project. I want to hide the default input and show the Calendar when user press a button. I am trying to have the <datepicker/>
inside a div apply css for the div so that I can hide it.
<div class="datePickerDiv">
<datepicker class="date" ref="datepick"></datepicker>
</div>
<style scoped>
.datePickerDiv {
position: relative;
float: left;
margin-top: -40px;
}
.datePickerDiv input {
border: none;
background: transparent;
}
</style>
But its not working as I expect. Sample https://codesandbox.io/s/relaxed-sea-qfuix?file=/src/components/HelloWorld.vue:742-910
You need to use the >>>
combinator in order to deeply select the input
tag:
.datePickerDiv >>> input {
border: none;
background: transparent;
}
This is because you're using the scoped
attribute on your style tag. scoped
will only work to apply styling to child components directly referenced in your current Vue component. In this case, datepicker is creating its own child input
which will not be affected by the style, unless you use the deep selector shown above.