I am creating a vertical divider, that works fine. But the CSS is cumbersome.
The CSS is:
.headerDivider1 {
border-left:1px solid #38546d;开发者_StackOverflowheight:80px;position:absolute;right:250px;top:10px;
}
.headerDivider2 {
border-left:1px solid #16222c;height:80px;position:absolute;right:249px;top:10px;
}
The HTML is:
<div class="headerDivider1"></div><div class="headerDivider2"></div>
The result is:
How could I tidy the HTML and CSS up?
.headerDivider {
border-left:1px solid #38546d;
border-right:1px solid #16222c;
height:80px;
position:absolute;
right:249px;
top:10px;
}
<div class="headerDivider"></div>
<div class="headerdivider"></div>
and
.headerdivider {
border-left: 1px solid #38546d;
background: #16222c;
width: 1px;
height: 80px;
position: absolute;
right: 250px;
top: 10px;
}
for vertical divider only
.divider {
border-left: 1px solid #000;
height: 100%;
}
I prefer using the after
property for vertical divider using CSS because it's neither content nor a border.
.block {
position: relative; /* ADDED */
}
.block:after {
content: '';
position: absolute;
border-left: 1px solid black;
right: -10px;
height: 80%;
}
.block:last-child:after {
display: none; /* Hide the divider for the last block */
}
精彩评论