Vue component lacking Scss styling

One of the components in my project is an Img component, which includes a figure with a nested image element:

<figure>
  <img @dragstart="stopDrag" :src="src" />
</figure>

When using this component within another component, I am attempting to override the styling of the inner image from the parent. However, while the figure receives the new styles successfully, the inner image does not.

<template>
    <List>
      <li class="gridItem">
        <Img :src="require('@/assets/images/girl.png')" />
      </li>
    </List>
<template>

...

<style scoped lang="scss">
.gridItem {
  & figure {
    width: 100%;
    height: 100%;
    
    //I did try & >>> img, and it didn't work.

    & img {
      width: auto;
    }
  }
}
</style>

If you'd like to take a closer look at the issue, feel free to check out the current version of the project on my Github repository: Github Repo

Answer №1

>>> don't appear to work with the Sass libraries I've experimented with, such as node-sass and sass. However, both node-sass and sass still recognize the use of /deep/.

The SCSS code below is functional for scoped styles using node-sass 4.14.1 and sass 1.26.9:

.gridItem {
  & figure {
    width: 100%;
    height: 100%;

    & /deep/ img {
      width: 500px;
    }
  }
}

Answer №2

As per the Vue documentation on scoped CSS

"Certain pre-processors, like Sass, may struggle with parsing >>> correctly. In such cases, using the /deep/ or ::v-deep combinator as an alternative - both behave identically to >>>."

Instead of & >>> img, try using &::v-deep img. This should resolve the issue you are facing.

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

Issues with Vue v-for when using variable ranges

totalLoops = 3; Desired output: 1 2 3 Method: <div v-for="i in 3">{{ i }}</div> Issue Encountered: <div v-for="i in totalLoops">{{ i }}</div> I have exhaustively researched and experimented with various sol ...

Navigating Joomla with a Menu specifically designed for articles within a specific category

After recently starting to navigate Joomla, I've hit a roadblock with a seemingly simple task. I have multiple articles, each belonging to a specific category. My goal is to create a menu that displays all articles within a chosen category. When sele ...

Populate data into vue.js router guard before triggering it

I'm currently working on implementing a vue.js router guard in my main.js file, but I am encountering an issue. I have a list of entitlements that needs to be passed into the router guard, and although I am fetching this list into the store in the cre ...

What is the best way to have text wrap around an icon in my React application?

I am facing an issue while trying to display the note description over the trash icon in a React app. I have tried various methods but can't seem to achieve the desired effect. Can anyone guide me on how to get this layout? Here is what I intend to a ...

Processing of onSuccess in custom Vue.js AJAX directives

I've implemented a unique Vue directive for handling ajax forms and am looking to customize the onSuccess functionality with the data received... The directive code is as follows: Vue.directive('ajax', { bind: function (el, binding, v ...

Applying a CSS class (or style) dynamically depending on the variable with the help of a directive

I'm facing a situation where I need to apply ng-style (or ng-class) multiple times depending on a variable. However, this repetitive task of writing ng-class for the same functionality for each widget is quite cumbersome for me. Is there a way to si ...

What is the best way to restrict props to only accept pre-defined values?

I have a specific Use Case where I need a form to only accept the values "New" OR "Update" in a Prop called FormType. Any other values entered will trigger an error message. Currently, I am using the script setup method and I have defined props as shown b ...

What is the easiest way to import a CSS file into just one specific page in Ionic2?

Take, for instance, my desire to import the following: <link rel="stylesheet" href="mycss.css"> into example_page. I attempted importing it from index.html, but I fear that by doing so, the CSS will be loaded on every page each time I run my app. I ...

Issues arising from the v-for loop iterating through the products list

Apologies for any language errors in my English, as it is not my first language. If you would like to view my github page, you can find it here: https://github.com/CapitaineBarbarossa/test-carousel I am currently facing an issue with creating a dynamic car ...

What are the steps to create a dynamic website using vuetify?

I am interested in creating an adaptive website using Vuetify: https://vuetifyjs.com/en/ This means there will be multiple versions of the website catered to different devices. An adaptive design will offer various designs for different screen sizes, inc ...

Sending a list of data to a child component in Vue

After reviewing various answers on here, such as this one, it seems like passing imported JSON data from the parent to the child component should work. The import and looping through data functions perfectly if I do it all in the parent with a v-for: < ...

Issue with a hidden div, problem with scrolling, a div overlapping other divs

I'm feeling a bit lost here, trying to figure out what went wrong. It seems like a simple mistake, but I can't pinpoint it. Currently, I'm just testing everything out for a mobile website template. Hopefully, that information helps. For any ...

Personalized HTML checkbox featuring custom labels

I'm working on a website where I want to personalize the appearance of checkboxes with labels. Can anyone recommend some good libraries that can help me achieve this? For example, I have heard about the ibutton library, but I'd love to explore o ...

Utilize jQuery to retrieve data attributes and set them as CSS properties in a key-value format

Looking at the HTML below: <h4 data-padding-top="100" data-padding-left="0" data-text-align="left" data-color="#ffffff">Promotion Two</h4> I aim to use the data attributes as CSS styles for the H4 element. I have attempted to achieve this ...

HTML generates areas of blank space

Currently, I am in the process of developing a web page using Angular 2 and PrimeNG Design Framework. The layout is simple, with a menu bar at the top and content below it to fill the remaining space. However, there seems to be an unexplained gap at the bo ...

Tailored alignment of checkboxes and labels

I've designed a custom checkbox where the actual checkbox is hidden and a label is styled to look like a checkbox. Everything works fine, however, when I add a label, it doesn't align properly. Here's the link to the fiddle: http://jsfiddle ...

What causes the ul element to display upon clicking the input field?

Why is the ul disappearing with display: none when the input element is clicked? Here is the HTML code snippet: When this input is clicked: <input class="input country" type="text"/> This unordered list should be displayed (but ...

Simultaneously opening the second submenu and closing the previous submenu with a height transition results in the second submenu being positioned off-screen

Sample: https://codesandbox.io/p/sandbox/navbar-k2szsq (or refer to the code snippet below) In my navbar, I have implemented multiple submenus with a height transition when the user opens or closes a submenu. However, only one submenu can be open at a tim ...

Can we use ToggleClass to animate elements using jQuery?

I have a section on my website where I want to implement an expand feature. I am currently using jQuery's toggleClass function to achieve this effect. jQuery('.menux').click(function() { jQuery(this).toggleClass('is-active&a ...

Adjusting the width of the body container in a 2-column layout with menu padding is causing gaps to appear on the right side of

I'm having trouble getting my body div to fill the width of the page and align with the right side of my sidebar. Whenever I add padding to the sidebar, it creates blank space on the right that I can't seem to get rid of. Here is the code I am us ...