Reputation: 23597
I have the following CSS...
.border:before{
content: "";
color:black;
border-left:10px solid black;
height:90%;
}
.border{
display:flex;
}
If I remove the display flex I see the border, however, when I add the display flex it disappears. Basically looking to have a side border that is only 90% the height of the div.
Upvotes: 0
Views: 49
Reputation: 6717
The reason is that you don't have a height
specified on .border
. The ::before
pseudo-element has a height
declared in %
. Since .border
doesn't have a specific height
, then the height
of the pseudo-element is set to 0
.
Specify a height
on .border
, or on the pseudo-element.
/* Styles go here */
.border:before{
content: "";
color:black;
border-left:10px solid black;
height:90%;
}
.border{
display:flex;
height:42px;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<h1 class="border">Hello Plunker!</h1>
</body>
</html>
Alternatively, you could just add the border to .border
itself and not use a pseudo-element.
/* Styles go here */
.border{
display:flex;
border-left:10px solid black;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<h1 class="border">Hello Plunker!</h1>
</body>
</html>
Upvotes: 2