Reputation:
Actually, I have a div
tag and I run code like below:
<div class="navbar-text">someText</div>
...
.navbar-text:before {
display: block;
height: 20px;
width: 20px;
background: #f00;
}
But I cannot see the red square. How can I make it appear?
Upvotes: 0
Views: 51
Reputation: 1142
::before or :: after will not work without a content
property. It may be empty but it has to be there.
.navbar-text:before {
content: '';
display: block;
height: 20px;
width: 20px;
background: #f00;
}
<div class="navbar-text">someText</div>
Upvotes: 1
Reputation: 3117
Is this what you want:
.navbar-text:before {
display: inline-block;
height: 10px;
width: 10px;
content: '';
background: #f00;
}
<div class="navbar-text"> Some Text</div>
Upvotes: 0