Get rid of the right border on the last child pseudo-class

I can't seem to figure this out. It's frustrating because I usually don't struggle with something as basic as a pseudo-class.

My goal is to remove the right border of a div element for the last child. I've managed to make it work by adding a class to the last element, but I want to find a more efficient solution since the content will be generated in a loop.

Below is the HTML code. The entire content is enclosed within a section with an id of #small-featured. All the content inside bootstrap columns is wrapped in #featured-wrapper.

<section id="small-featured">
  <div class="container">
    <div class="row">
      <div class="col-md-3">
        <div class="featured-wrapper">
          <a href="#"><img src="assets/img/36-6022.png" alt=""></a>
          <p>The Product Title</p>
        </div>
      </div>
      <div class="col-md-3">
        <div class="featured-wrapper">
          <a href="#"><img src="assets/img/36-5100.jpg" alt=""></a>
          <p>The Product Title</p>
        </div>
      </div>
      <div class="col-md-3">
        <div class="featured-wrapper">
          <a href="#"><img src="assets/img/46-455.jpg" alt=""></a>
          <p>The Product Title</p>
        </div>
      </div>
      <div class="col-md-3">
        <div class="featured-wrapper">
          <a href="#"><img src="assets/img/unisaw.jpg" alt=""></a>
          <p>The Product Title</p>
        </div>
      </div>
    </div>
  </div>
</section>

Here is the CSS

#small-featured {
  text-align: center;
}

#small-featured img {
  width: 250px;
  padding: 0 15px;
}

.featured-wrapper {
   border-right: 1px solid #eee;
}

#small-featured .featured-wrapper:last-child {
   border-right: none;
}

When I apply my final CSS rule, all borders disappear. I have also tried targeting just .featured-wrapper:last-child without success.

Any suggestions?

Answer №1

#small-featured .col-md-3:last-child .featured-wrapper {
  border-right: none;
}

(Every instance of .featured-wrapper is the last child element.) ¯\_(ツ)_/¯

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

"Create sleek and stylish forms with Bootstrap's horizontal

I am attempting to create a horizontal form in Bootstrap using the code provided in their documentation. The example they show has input boxes filling the entire column space, but for some reason this is not happening when I try it, even after copying the ...

Why does getElementById work when getElementsByClassName doesn't?

I created a script with the purpose of hiding images one and two, while keeping image 3 visible and moving it into their place. The script functions correctly when using div Id's instead of div Classes. However, I prefer to use div classes for groupin ...

What is the most efficient way to transmit an HTML document element from a client to a server in Node JS

I am attempting to capture a snapshot of my client-side document object and send it to the Node.js server. However, when I try to convert it into a string using: JSON.stringify(document.documentElement) I encounter an issue where it becomes an empty obje ...

What is the best way to position a title at the bottom center of each image within my grid gallery?

I'm struggling to find a way to position a title at the bottom of each image in my grid gallery, right in the center of the photo with a light-gray background. I want the text to be fully visible regardless of the image used. Currently, I can only put ...

What are the risks of using react + bootstrap without importing bootstrap.js?

When bootstrap library is used along with React, potential unpredictable behavior and difficult bugs may arise due to DOM modifications. Is it feasible to use bootstrap without including bootstrap.js? What are the drawbacks? While I am aware of the ' ...

Ways to compel divs underneath aligned divs

There are six divs numbered 1 to 6. I want divs 2, 4, and 6 to be positioned below divs 1, 3, and 5 respectively. Is it possible to achieve this layout? Sorry if my explanation is not very clear. Thank you. http://jsfiddle.net/LkGV8/ <body> <d ...

perform an action in PHP when a button is clicked

I'm currently developing a PHP admin panel that displays a list of users in an HTML table format. Each row in the table includes a button that allows the admin to send a notification to the selected user. Below is the code I used to create and displa ...

Can you define the "tab location" in an HTML document using React?

Consider this component I have: https://i.stack.imgur.com/rAeHZ.png React.createClass({ getInitialState: function() { return {pg: 0}; }, nextPage: function(){ this.setState({ pg: this.state.pg+1} ) }, rend ...

What is the maximum length for the string that can be passed to jQuery's .append() method?

In Angular, I developed a simple program that leverages router functionality to showcase two pages within a single-page application. The setup includes a page with two navigational buttons and a wrapper div (ng-view) that dynamically displays the content o ...

The struggle of media queries: How can you reset an element to its original display style when it's set to none?

If faced with the following scenario, how would you handle it? Imagine this: You need to hide a visible element when a specific media query is met: .myElement { display: block; } and the media query to hide it: @media (min-width: 1000px) { .myElement ...

What is the best way to align the 'Typography' component in the center?

Attempting to center it using flexbox with justify-content did not yield the desired result. I also tried replacing the Typography component with a div tag, but still no success. import {AppBar,Zoom,Toolbar,Typography,CssBaseline,useScrollTrigger,Fab,ma ...

Displaying and hiding elements as the page is scrolled

Is there a way to create a single scrolling page with a fixed element that remains visible as the user scrolls down? Imagine an image of a car on a road, where the car appears to be moving down the road as the user scrolls. The car should go under certain ...

utilizing the power of Ajax in Laravel version 5.7

I am seeking assistance in utilizing AJAX to delete and update table rows with a modal in Laravel 5.7. I am new to AJAX and would appreciate any help, especially in explaining how AJAX sends/gets data in the controller and if there are any differences betw ...

Is the p tag not becoming absolute from the bottom even when set to position: absolute?

My p tag in the section properties of div class="sf sf_2 won't align to 0 px from the bottom of the div. It seems to move 0px from the top, right, and left but not bottom. I've tried changing its position property and where it's nested, but ...

I am puzzled as to why my jQuery height and width functions are returning NaN as the result

I am attempting to calculate the ratio of height and width for each image on a webpage. Unfortunately, I am consistently receiving a NaN result and I cannot figure out why. I have been using get() and find() <div class='image-wrapper'> ...

Automatically tally up the pages and showcase the page numbers for seamless printing

I've been tackling a challenge in my Vue.js application, specifically with generating invoices and accurately numbering the pages. An issue arose when printing the invoice – each page was labeled "Page 1 of 20" irrespective of its actual position in ...

Alignment of inner div within the footer

I'm struggling to align my footer navigation inline with my footer title. Check out this code snippet to see what I've tried so far: https://jsfiddle.net/nkzsufov/ I experimented with using absolute and relative positioning: .footerNav { margi ...

Tips for resizing a tooltip using CSS

I am currently working on customizing tooltips and would like them to display right below the hover text in a responsive manner, with the ability to have multiline text. Instead of spreading horizontally, I want the tooltip to expand vertically based on th ...

Error: TweenLite has not been recognized

/justincavery/pen/mPJadb - this is a link to CodePen After copying the code from CodePen and running it, I encountered an error: "Uncaught ReferenceError: TweenLite is not defined". The image only draws once and there is no animation unless I press "F5 ...

The behavior of Bootstrap 5 containers varies depending on whether they are located within a row

Have you noticed the difference in maximum width between Bootstrap 4.6 and Bootstrap 5? It seems that containers have a 1320px max-width in Bootstrap 4.6, whether inside or outside a row. However, this is not the case in Bootstrap 5 and I couldn't fin ...