What is the proper way to convert the Vue3 ::v-deep SASS syntax to utilize :deep?

HTML:

<template>
 <form class="bg-white">
  <div class="source-field">
...

The original SASS code looks like this:

.form::v-deep
  .source-field
    width: 129px
    display: inline-block
    margin: 0px 2px 5px 2px

When trying to change it like this, none of the styles apply anymore:

:deep(.form)
  .source-field
    width: 129px
    display: inline-block
    margin: 0px 2px 5px 2px

Alternatively, this code also works:

::v-deep
  .source-field
    width: 129px
    display: inline-block
    margin: 0px 2px 5px 2px

However, this code does not work:

:deep()
  .source-field
    width: 129px
    display: inline-block
    margin: 0px 2px 5px 2px

Answer №1

Detailed information can be found in the documentation: https://vuejs.org/api/sfc-css-features.html#scoped-css

To target child components in scoped styles, use the :deep() pseudo-class:

<style scoped>
.a :deep(.b) {
  /* ... */
}
</style>

For a well-explained answer, visit:

A potential solution for your scenario:

In your code, you have .form::v-deep .source-field, where .form is the parent component. You can rewrite it as .form >>> .source-field for better comprehension. With the new :deep() syntax, combine it with the parent selector followed by the child's name as a "parameter". (e.g. .parent :deep(.child))

To address your specific case, consider using .form :deep(.source-field). To maintain nested selectors, you can try:

.form
  :deep(.source-field)
    width: 129px
    display: inline-block
    margin: 0px 2px 5px 2px

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Text remains constant until the mouse hovers over the image

Check out this Example Here is the HTML code: <ul class="img-list"> <li> <img src="http://s11.postimg.org/ynw9rnexf/Cetina_river.jpg" width="360px" height="280px" /> <span class="text-content"><span> Text To Dis ...

I'm encountering an issue with the "z-index: -1" property in React

After creating a form placed alongside buttons, I encountered an issue where the form overlaps the buttons and prevents them from being clicked. Despite setting the z-index to -1, it seems that the form remains clickable even when not visible. Research ind ...

Discover the div element while scrolling with VUE.js

Is it possible to trigger a function when a specific div becomes visible on the page? This particular div is located in the middle of my content. I would like the function to execute when I scroll to that div with a specific ID or reference. I'm quite ...

Troubleshooting an Issue with CSS Sliding Doors

I'm having trouble getting the right image to show on my website. The left side of the image is fine, but I can't figure out how to make the right one appear. As a HTML/CSS beginner, I'm still learning the basics. For more information, vis ...

During the rendering process, the property "projects" was attempted to be accessed, however, it has not been defined within

I am struggling to understand this issue. Despite looking at numerous other problems and solutions, I still can't grasp the root cause of the error. In my projects.js file, there is an array. Whenever I try to import {projects} from "@/projects.js", I ...

Unable to fix position: sticky issue following Angular 15 update

Following the angular material update to version 15, many of us experienced issues with CSS changes breaking. This also affected legacy code that included sticky headers. <div class="row"> <div class="col-12"> <di ...

The Vue app's Axios request deployed on Amazon S3 fetches the home page of the website

My Vue app is deployed as a "static" site on Amazon S3 and the CORS configuration remains default. To prevent 404 errors on routing, I include the following line after building the app: <script>history.pushState({}, "Application entry", location.has ...

I need a layout similar to the navbar on http://thecoloradan.com/ but I am not asking for instructions on how to do it

Have you seen the stunning navbar on this website? It appears to merge with the background upon loading, then smoothly shifts to the top of the page as you scroll. The transition is accompanied by a lovely animation. I am curious about the steps needed to ...

Establishing a primary color for all text in Vuetify

How can I set a base color for all text in a Vue + Vuetify project? I attempted to change the theme's primary color in vuetify.ts: export default new Vuetify({ theme: { themes: { light: { primary: "#E53935", }, }, }, } ...

The ion-content scrolling directive is failing to show any displayed information

Within my Ionic application, I have a very simple HTML structure: <ion-pane> <ion-header-bar class="bar-stable"> <h1 class="title">Ionic Blank Starter</h1> </ion-header-bar> <ion-content> ...

Eliminating elements that adjust according to different screen sizes

Website: I am currently working on customizing a Tumblr theme I downloaded by removing some responsive elements. The rollover effects I created are being affected when the screen size goes below 1024px, and I am not happy with how it looks. Additionally, ...

How can the border of the select element be removed when it is active in select2

After examining the CSS code, I am still unable to locate the specific property that is being applied to the main element. I am currently customizing the select2 library to suit my needs. However, I am stuck in the CSS as I cannot determine which property ...

The animation of the splash screen in Angular is quite jarring and lacks fluidity

I am experiencing some issues with my angular splash screen animation. It works perfectly when there is no activity in the background, but when I simulate a real-life application scenario, the animation becomes stuttered, choppy, or sometimes does not anim ...

The CSS property object-fit: cover is unable to properly display JPEG images with EXIF orientation greater than 1

I'm having trouble with my Angular app and creating a gallery of photos from my Samsung Galaxy. I am using the "object-fit: cover" css attribute for a nice design, but it only seems to work correctly when the image has an EXIF "orientation" property e ...

Be cautious of potential warnings and errors that may arise while utilizing casl and vue together

I've been attempting to integrate @casl/ability and @casl/vue into my VueJS application, but I'm facing difficulties making it work. I'm unsure if I'm making a mistake in the implementation or if there is a compatibility issue with the ...

What is the best way to make my button sticky across different screen sizes on my webpage?

I'm having trouble figuring out how to make my purple button sticky and responsive on the right side of the screen as I scroll down. Can someone help me with this? This is the snippet of my HTML code: <Col className="colPre"> ...

How to create a full-page background image using Bootstrap?

Take a look at this example: In the provided example, there is a background landing page that expands to fit the width of the viewport, remains responsive, and does not take up the full width of the page. How can you utilize bootstrap to manually code an ...

Troubleshooting the issue of JavaScript not executing on elements with a specific CSS class

I am attempting to execute a JavaScript function on each element of an ASP.NET page that is assigned a specific CSS Class. Despite my limited knowledge of JavaScript, I am unable to determine why the code is not functioning properly. The CSS Class is being ...

Basic jQuery Slideshow Counter

I'm having trouble implementing a text-based horizontal slider on my website that scrolls left and right with mouse control. I want to display the current index of each slide along with the total number of slides (e.g. 1/4) and update the index as use ...

Removing the rows that do not contain a table - nested div elements within other div elements

I am trying to create stripped rows with "complex" children, but I'm having trouble figuring out how to do it. I am using bootstrap, although I'm not sure if that makes any difference! This is what I have attempted so far: https://jsfiddle.net/ ...