ฉันเพิ่งทำสิ่งที่ตรงกันข้ามกับสิ่งนี้โดยใช้:afterและ::afterเพราะฉันต้องการทำให้เส้นขอบด้านล่าง1.3remกว้างขึ้น:
องค์ประกอบของฉันได้พิการสุดเมื่อใช้:beforeและ:afterในเวลาเดียวกันเพราะองค์ประกอบมีความสอดคล้องกับแนวนอนdisplay: flex, และflex-direction: rowalign-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:beforeleft: 50px.