Make Div Partial Coloured
I know this question is asked before and also with good answers, however I still can't get this to work. What I try to do is make a div partial coloured. The problem I'm facing is
Solution 1:
Use a pseudo-element
* {
margin: 0;
padding: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.container {
width: 50%;
margin: auto;
height: 100vh;
border-left: 1px solid green;
/* for reference */
border-right: 1px solid green;
/* for reference */
}
.mybar {
height: 50px;
background: lightblue;
position: relative;
}
.mybar::after {
content: '';
position: absolute;
top: 0;
left: 50%;
background: inherit;
height: 100%;
width: 50vw;
z-index: -1
}
<div class="container">
<div class="mybar"></div>
</div>
Post a Comment for "Make Div Partial Coloured"