Focus on selecting a div nested within a separate component

I have encountered an issue with an imported component that has multiple nested divs which I am unable to modify.
Deep within these divs, I need to apply a bottom margin.

While using Chrome DevTools, I managed to add the desired margin to one of the divs and achieve the desired result.
However, I'm struggling to replicate this in my scss file. How can I accomplish this?

const MyComponent = props => {
  return (
    <div>
      {/* This component is not in my control. I can't modify this component*/}
      <ImportedComponent/> 
    </div>
  );
};

Although I can see the CSS changes in Chrome DevTools as shown below, I am unable to implement them in my scss file.

<div class="my-own-class">

    <!-- This is all coming from ImportedComponent, each div has some css class -->
    <div>
        <div>
            <div class="aCssClass anotherClass"> <!-- i want to be able to add my margin here, able to do it but only via Chrome dev tools-->
                <div>
                    <div>
                        Some data
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>

I have tried various styles in my scss file, but none seem to make any difference.

.my-own-class {
  margin-bottom : 1em;
}

.my-own-class > div:nth-child(3) {
  margin-bottom : 22px;
}

.my-own-class body .aCssClass {
  margin-bottom: 22px;
}

body .aCssClass {
  margin-bottom: 22px;
}

body > .aCssClass {
  margin-bottom: 22px;
}

.my-own-class .aCssClass {
  margin-bottom: 22px;
}

.my-own-class > .aCssClass {
  margin-bottom: 22px;
}

Screenshot

I made the necessary changes by adding margin-bottom 10px under body .sc_marginRight_0 on the right panel, as highlighted in the image linked below.

https://i.sstatic.net/1QpEk.png

Answer №1

It seems like the issue lies in the specificity of the CSS selector. You can resolve this by including the !important tag in your margin declaration.

.my-custom-class .someCSSClass {
  padding-top: 15px !important;
}

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

Is it possible to employ the useState hook within a High Order Component (HOC)?

I have a Higher Order Component (HOC) that generates a functional component. When I attempt to implement useState, I encounter the following error message: “src/HOC.js Line 5:35: React Hook "useState" cannot be called inside a callback. React ...

Can you provide step-by-step instructions on how to customize styles with MUI in my application?

I am encountering issues with MUI while attempting to customize the color of my buttons. The two methods I have tried so far have been unsuccessful. For example, Method 1: import React from 'react' import { Typography } from '@mui/material& ...

Is there a way to position the angular loading bar inside a specific 'div' instead of at the top of the page?

Recently, I integrated angular-loading-bar.js into my project to visually represent the progress of http calls. By default, the blue progress bar appears at the top of the screen. However, I wanted to customize it so that it would appear within a specific ...

Unable to write to csv file in UTF-8 using PHP fwrite, experiencing issues

Looking for assistance with handling PHP fwrite as CSV file is displaying incorrect characters. The output appears like this: općšpšćšćšp ćpšćpšćp šćpšćpšć This is the PHP code being used fo ...

Tips for preserving the contents of a list with HTML and Javascript

My latest project involves creating a website with a To-Do list feature. Users should be able to add and delete items from the list, which I achieved using JavaScript. Now, my next goal is to ensure that the current items on the list are saved when the pag ...

Parallax Effect Slows Down When Scrolling In Web Page

Currently in the process of creating a website with a scrolling parallax effect using Stellar.js on the header and three other sections. However, I'm experiencing lag when scrolling, especially at the top of the page. I've attempted to reduce la ...

Multiple instances of jQuery file being loaded repeatedly

Having an issue with the jQuery file (jquery-1.11.3.min.js) loading multiple times. It seems that other jQuery files in the index.html page might be causing this. Any advice on how to resolve this would be greatly appreciated. <script type="text/javasc ...

Bootstrap 5's h-100 feature functions flawlessly in Chrome, however, it encounters issues when used with a group

Can you please refer to this question: Issue with Aspect Ratio of Images in Bootstrap 5 due to Padding After applying the h-100 solution, everything looks great on Chrome. Unfortunately, when I check it in Safari, the aspect ratio of the image gets distor ...

There is no overload that fits the current call | Typescript, React, and Material UI

Embarking on my TypeScript journey with React and Material UI, I am hitting a roadblock with my initial component. // material import { Box } from '@material-ui/core'; // ---------------------------------------------------------------------- ...

I'm confused as to why the CSS Bottom property is causing the top edge of the div to align with the bottom of the document rather than the bottom edge

My challenge is to align an image slideshow on top of my footer, with the bottom edge of the slider touching the top edge of the footer. Despite using position: fixed and bottom: 0 properties, it appears that the positioning is off - aligning the top edge ...

Extract information from an external HTML table and store it in an array

I am looking for a way to extract data from an HTML table on an external site and save it as a JSON file for further manipulation. Is there a method to retrieve table data from an external HTML site that differs from the code example provided? Additional ...

Creating Dynamic Latex Text with react-three/fiber's 3D Rendering

I am exploring ways to incorporate 3D math equations using react-three/fiber, and have been on the lookout for a solution that integrates latex seamlessly. Currently, I have been utilizing the Text3D component from @react-three/drei but have yet to find a ...

React appears to be failing to properly render the final return statement

All my logs initially show up as undefined, but once the data is retrieved from the prop, they display correctly. However, they remain stuck on "Loading..." Is there an issue with my code structure? import React, { useEffect, useState } from 'react&a ...

Vertically aligning text in separate div containers

Currently, part of my dashboard page is styled using the Bulma CSS framework. One feature is a 'Widgets' feature with three large containers displaying key facts such as the number of sales, new customers, etc. The issue I'm facing is that ...

`Unable to upload spreadsheet file in xlsx format`

I'm currently working on implementing a feature to export data as xlsx files. I have been successful in exporting CSV and PDF formats, but encountered issues with the xlsx format due to dynamic imports. export const exportToXlsx = async ( gridElemen ...

The validation of radio input signals results in an error being returned

For a while now, I've been trying to solve the issue with radio button validation in my current project. Surprisingly, it works fine when there are no other functions in the form besides the radio buttons themselves. I suspect that the problem lies wi ...

conceal the spinner loading animation once the script has finished executing

I'm having trouble displaying the spinner at the beginning of an AJAX call and hiding it once the call is complete. Unfortunately, I cannot seem to hide the spinner after the script has finished executing. Any suggestions or ideas on how to solve thi ...

What is the method for implementing react-perfect-scrollbar with react-table to replace the default scrollbar?

I am experimenting with using react-perfect-scrollbar with react-table, but it seems to only work with a custom table. <PerfectScrollbar> <Table className='table'> <thead className='table-head'><t ...

Resizing images in different web browsers: Chrome, IE, and Safari

I'm currently in the process of building a website that utilizes the jquery tabs api. Each tab on the site contains an image that I would like to resize dynamically as the browser window size changes. Here is an example of one of the tabs: <li st ...

Incorporate a variable from an HTML form into PHP for FPDF functionality

How can I retrieve a variable from an "input" element in another HTML file? <input type="text" id="client" name="clientTest" required minlength="1" maxlength="30" size="30"> I need to pass this variable to my PHP file for FPDF. It seems like I hav ...