Applying CSS to the second level of nested div within a container div

I have a parent div with nested child divs that I want to style using one class. The challenge is getting the styles to apply correctly to specific child divs.

<div class='aa-callout aa-prime'>
  <div class='row p-1 h-100'>
    <div class='col-1 d-flex align-items-center'>
      <i class="fal fa-exclamation-circle fa-3x text-white mx-auto"></i>
    </div>  
    <div class='col-11'>
      <h4>Blue is for information</h4>
      <p>Sed ut perspiciatis unde.</p>
    </div>
  </div>  
</div>

The goal is to style the background color and other properties of the smaller div containing the icon. However, attempts to target it using CSS selectors have not been successful.

.aa-prime > div:nth-child(2) {

and

.aa-prime div:nth-child(2) {

do not apply the desired styles to the left-hand div with the icon (such as background color and rounded edges).

.aa-callout {
  max-width:100%;
  flex: 0 0 100%;
  border: 1px solid #dee2e6;
  border-radius: .5rem;
  padding-left:15px;
  padding-right:15px;
}
.aa-prime > div:nth-child(2) {
  background-color: #036A96!important;
}
.aa-prime h4 {
  color:#036A96!important;
}

Answer №1

If the structure remains constant (i.e. not subject to change), you can employ the following selector:

.aa-prime > div:first-child > div:first-child { ...

(Please take note: using :nth-child(2) will not be effective since the second div is nested within the first div)

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

How is it that the magic table refuses to conform to CSS styling? This is truly sorcery!

My HTML table is as simple as it gets: <table class="dispdtab"> <tr> <td><b>Dealer: </b></td> <td>dealername</td> </tr> <t ...

The Vue Bootstrap component is failing to render correctly after an update to the Vuex Store. This issue can be resolved by implementing

Having trouble getting an object in a Vue CLI app component to re-render when there is a Vuex store change triggered by another component. Even though I modify the curDocType variable, the value of the b-form-select object remains unchanged at 0. Unsure if ...

designing a dynamic search icon animation

I need help with adjusting the search bar in vue. Currently, it opens from the left side but I want it to open from the right side instead. Also, I would like to replace the background image with a font awesome icon. Can someone guide me on how to achiev ...

Tips for collapsing or expanding a single button in Angular 6

I want to create rows of collapsible buttons in my code, but every time I visit the page, all the buttons are already expanded. Additionally, when I click on any button, they all expand or collapse simultaneously. HTML <div id="accordion" *ngFor="let ...

Ways to showcase Form utilizing function

I've just started learning React JS and bootstrap. I'm attempting to load a login form using a React JS class with an embedded function, but when the function is triggered on click event, it's not rendering the Form and instead displaying co ...

I'm currently attempting to create a dynamic object using code, but it doesn't seem to be functioning as expected. I'm curious about what might be causing the issue

I am brand new to exploring JavaScript, HTML, and CSS. I've gone through my code several times but can't quite pinpoint what's causing it not to function properly. While there are no apparent errors being returned, the expected behavior is n ...

JS Plugin Loading Problem

What combination of libraries/frameworks would work best for optimizing performance in an HTML5/CSS3/JS app with moving elements? I have done some research, but I am venturing into unfamiliar territory when it comes to performance. Are there key principles ...

Personalized Pinterest button to link to a custom URL (Text Link, Image, or Both)

I've been searching for a solution without success. I'm looking to customize the image for my Pinterest (Pin It) button and pin a specific image by URL, not just the current page. Here is the custom link I created: <a href="http://pinterest. ...

Size attribute set to 0 for an HTML input element

When an input element is rendered, it should have a width of 0. However, when there is no text in the input, the width should remain 0. To achieve this, you can use the following jQuery code: $('input').on('input', function () { $(th ...

Tips for modifying HTML elements using Javascript after a link is clicked

Imagine a scenario where there is a DIV called "videoplayer" containing an image within it. Is there a straightforward method to modify the HTML content inside this DIV when a link is clicked? For instance, the current content of the DIV is as follows: ...

Live CSS editing tool

Are there any Javascript libraries or plugins available that enable real-time modification of CSS classes/styles on a webpage? ...

Making the navbar color modifications to the dropdown menu

I am currently working on applying color changes to the text in my navbar for the links that have been visited, are active, and are being hovered over. I have successfully implemented this for my regular hyperlink elements. However, I am facing an issue wi ...

The banner refuses to show up at the top and the CSS styling is not taking effect

In my Django project, I have the following HTML code: <!DOCTYPE html> {% load static %} <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, ...

Showcasing the most recent three Wordpress blog posts in a Bootstrap4 carousel

I'm currently working on a Bootstrap4 carousel that should display the featured image, title, and the beginning of the 3 latest blog posts. Although the desired content is showing up in the carousel, it seems to be stuck on the first post without auto ...

Transforming fonts into various web-compatible font formats

This morning, I delved into the fascinating world of fonts as I am in need of a specific font for my CSS project. It appears to be quite complex to rely on others for correct font types, so I started exploring methods to convert fonts from one type to ano ...

What is the best way to increase margin beyond mt-5 or mb-5 in Bootstrap 4?

I am working on a form and would like to set its margin-top to 100px. Is it possible to achieve this using Bootstrap classes, or do I need to create a custom class for it? <form class="mt-5"> </form> It seems that the maximum margin-top I ca ...

Customize stroke widths for each individual SVG item

I'm facing an issue with applying consistent stroke width to my CSS on a webpage. Here is the code snippet I am using: path { fill: none; stroke-width: 10pt; stroke: red; } Despite this, the rendering appears differently on certain SVGs. You c ...

Ways to Adjust the Earth's Position in WebGL Earth

I have been working with this WebGL Earth component for my project, but I am facing difficulty in adjusting the position of the planet on the canvas. My intention was to place the planet at the bottom of the page, but I haven't been able to achieve th ...

Tips for customizing the WooCommerce product page

If you want to customize the layout of a WooCommerce product page, you can override the template by copying the WooCommerce template folder into your theme. You can find step-by-step instructions here. I am looking to change the layout of a WooCommerce pr ...

Adjusting the background position as the background size is set to cover

I'm trying to create a moving background effect on a slider with a background image. The background image changes position as the slider transitions between slides, creating a dynamic visual experience. Here's an example of how I implemented thi ...