Pseudo-elements are considered child elements in a grid container (just like in a flex container). Therefore, they take on the characteristics of grid items.
You can always remove grid items from the document flow with absolute positioning. Then use CSS offset properties (left
, right
, top
, bottom
) to move them around.
Here’s a basic example:
html {
width: 75%;
}
ul {
list-style: none;
}
input {
width: 100%
}
.grid {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
}
li {
position: relative;
}
li.required::after {
content: '*';
font-size: 15px;
color: red;
position: absolute;
right: -15px;
top: -15px;
}
<ul>
<li class="required">
<input type="text">
</li>
<li class="grid required">
<p>one</p>
<p>two</p>
<p>three</p>
</li>
<li class="required">
<input type="text">
</li>
</ul>