ฉันเพิ่งทำสิ่งที่ตรงกันข้ามกับสิ่งนี้โดยใช้:after
และ::after
เพราะฉันต้องการทำให้เส้นขอบด้านล่าง1.3rem
กว้างขึ้น:
องค์ประกอบของฉันได้พิการสุดเมื่อใช้:before
และ:after
ในเวลาเดียวกันเพราะองค์ประกอบมีความสอดคล้องกับแนวนอนdisplay: flex
, และflex-direction: row
align-items: center
คุณสามารถใช้สิ่งนี้เพื่อสร้างสิ่งที่กว้างขึ้นหรือแคบลงหรืออาจเป็นม็อดมิติทางคณิตศาสตร์:
a.nav_link-active {
color: $e1-red;
margin-top: 3.7rem;
}
a.nav_link-active:visited {
color: $e1-red;
}
a.nav_link-active:after {
content: '';
margin-top: 3.3rem; // margin and height should
height: 0.4rem; // add up to active link margin
background: $e1-red;
margin-left: -$nav-spacer-margin;
display: block;
}
a.nav_link-active::after {
content: '';
margin-top: 3.3rem; // margin and height should
height: 0.4rem; // add up to active link margin
background: $e1-red;
margin-right: -$nav-spacer-margin;
display: block;
}
ขออภัยนี่เป็นSCSS
เพียงแค่คูณตัวเลขด้วย 10 และเปลี่ยนตัวแปรด้วยค่าปกติบางค่า
div:before
left: 50px
.