Reputation: 2742
I am using CSS in a list to show a solid border for a selected item in the list. Everything works fine except the bottom left of that solid being cut off in an inclined fashion while it shows correctly at top. What am I doing wrong?
CSS:
.item {
list-style: none;
width: -webkit-fill-available;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
height: 37px !important;
font-weight: 600;
border-bottom: 0.1px solid #e8e8e8;
margin-right: 200px;
}
.menu {
background: #F8F9FA;
min-height: 100%;
float: left;
width: 100%;
position: absolute;
ul {
margin: 0px;
list-style: none;
padding: 0px;
li {
font-size: 13.5px;
padding: 10px;
}
li:hover {
text-decoration: none;
background-color: #f3f4f5;
}
}
}
.enable {
background-color: #FFFFFF !important;
border-right: 5px solid #3081ed;
}
HTML:
<div class="menu">
<ul style="display: inline">
<li class="item" [ngClass]="{'enable': selectedItem == 'Test 1'}" (click)="selectedItem = 'Test 1'">
<span class="ml-2"> Test 1 </span>
</li>
<li class="item" [ngClass]="{'enable': selectedItem == 'Test 2'}" (click)="selectedItem = 'Test 2'">
<span class="ml-2"> Test 2 </span>
</li>
</ul>
</div>
Here's a stackblitz demo attached for CSS and html markup.
Upvotes: 1
Views: 590
Reputation: 396
Problem: I've checked your code, everything is fine except this line border-bottom: 0.1px solid #e8e8e8;
because of border-bottom
, there is a tridimensional sense of the li element and that's why the left side is crooked.
Solution:
box-shadow: 0px 0.1px #000;
in your code:
.item {
list-style: none;
width: -webkit-fill-available;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
height: 200px !important;
font-weight: 600;
/* border-bottom: 0.1px solid #e8e8e8; */ =>remove this line
box-shadow: 0px 0.1px #000; =>add this line
margin-right: 200px;
}
in your code:
.enable {
background-color: #FFFFFF !important;
/* border-right: 5px solid #3081ed; */ =>remove this line
position:relative; => add this line
}
li.item.enable::before {
content: "";
display: inline-block;
width: 6px;
height: 37px;
position: absolute;
right: 0;
background: #3081ed;
}
Upvotes: 1