I came across an unusual issue with dynamic borders in CSS. I am trying to "restore" / show a certain side of a border which has been disabled by either setting its width to zero border-left-width:0;
or using border-left:none;
The problem is that I don't want to repeat the same border properties since it should be an adaptive dynamic solution where the hidden border should inherit the element's already set border.
Example code: JSFiddle
/* ================== chic ================== */
body, html {
margin: 0;
padding: 0;
font-family:Verdana, sans-serif;
height: 100%;
text-align: center;font-weight: bold;
background:#62726b;
color:#abd4b1;
}
div {
padding:50px;
position: absolute;
left:0;
right:0;
margin: 0 auto;
width:50%;
top:50%;
transform:translateY(-50%);
}
/* ============= setting border ============= */
div {
border:5px dashed #abd4b1;
border-right:none; /* hide right border */
border-left-width:0; /* hide left border by setting width to zero */
}
/* restoring borders */
div {
border-right: inherit; /* attempt 1 - make border inherit previous properties */
border-right: initial; /* attempt 2 - resest border to initial state */
border-left-width: inherit; /* attempt 3 - inherit the border width */
border-left-width: initial; /* attempt 4 - reset border width to initial state */
}
<div>ALL YOUR BORDERS ARE BELONG TO US</div>
Observation 1: a border side will not inherit its "parent" border
Observation 2: using initial
resets the border to browser default (I guess that's logical to happen)
So the question really is can a hidden/disabled border side be shown using pure CSS without repeating the border property twice?