Code Example: Implementing CSS Last Child on a Div

To address the issue, two solutions are available. The first one involves the use of nth-child. A sample can be found at http://jsfiddle.net/uq9zaav3/3/. Meanwhile, the second option requires you to specify the location and timing for the clear div. You can also opt for nth-child(..) for this solution. In the latter example, the third item follows the “#left” rule (the first one) in the stylesheet and is thus floated to the left.


Solution:


For updated question:

The selector necessitates some modification, it ought to be adjusted to achieve the desired outcome.

li:last-child .streamBox {
  border: none;
}

The selector you’re using matches all the children of the parent since

<div class="streamBox">

is both the first and last child. To target only the last

<li>

and its

<div>

, use

:last-child

on the

<li>

. You can test it here, and I’ve made the border black to highlight the change.

Regarding the previous inquiry, the issue lies in the absence of a quotation mark in the attribute labeled as

class=""

. To resolve the problem, simply add the missing quotation mark as shown below.

blah blah
blah blah
blah blah
blah blah
​​​​

Once you test it here, you’ll see that the first three will have borders and it will function as expected.

Frequently Asked Questions

Posted in Css