Really bugging me, but why isn't Chrome showing the :after pseudo selector?? I haven't noticed this before. It's quite simple CSS too. It shows in all other browsers as well!
I did notice on the Bootstrap site though, their forms are showing the :after
selector in the DOM. Weird...
Please look at this code snippet that I made. It's doing it here too if you inspect the DOM in your browser. -
.form-horizontal .form-group {
margin-bottom: 10px;
}
.form-horizontal .form-group:before {
display: table;
content: " ";
}
.form-horizontal .form-group:after {
clear: both;
}
<div class="form-horizontal">
<div class="form-group">
<label>First Name *</label>
<input id="txtCustodianFName" type="text" class="form-control" placeholder="First Name" />
</div>
<div class="form-group">
<label>Last Name *</label>
<input id="txtCustodianLName" type="text" class="form-control" placeholder="Last Name">
</div>
</div>
Pseudo classes on elements can be triggered to investigate how an element may react if it were to be hovered over for example. You can right click on a node in the Elements panel and select Force element state. Alternatively, the Toggle element state icon can be clicked on in the Styles sub-pane.
::before. ::before is a generated content element that represents a styleable abstract first child of the respective element. The content inserted using ::before is inserted before other content inside the element and is displayed inline by default. The value of the content is specified using the content property.
A CSS pseudo-element is a keyword added to a selector that lets you style a specific part of the selected element(s). For example, ::first-line can be used to change the font of the first line of a paragraph. /* The first line of every <p> element.
The content
property is required for :before
and :after
pseudo selectors. If it is not included, it will have no effect on the element. If you are using the selectors to preform a clearfix, or some other case where you don't actually want any content, you can simply leave the content
property blank with content:'';
Like you have already done for the :before
selector. Your CSS should look like this:
.form-horizontal .form-group:after {
content: '';
clear: both;
}
Learning To Use The :before And :after Pseudo-Elements In CSS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With