在CSS中,設(shè)置上下邊框?yàn)閱螌?shí)線可以通過(guò)以下代碼實(shí)現(xiàn):
border-top: 1px solid #000; border-bottom: 1px solid #000;
上述代碼中的border-top
和border-bottom
分別表示上邊框和下邊框,1px
表示邊框的寬度為1像素,solid
表示邊框的樣式為實(shí)線,#000
表示邊框的顏色為黑色,你可以根據(jù)自己的需求修改這些值。
如果你想要設(shè)置其他樣式的邊框,比如虛線或雙實(shí)線,可以使用dashed
或double
關(guān)鍵字。
border-top: 1px dashed #000; border-bottom: 2px double #000;
上述代碼中的border-top
表示上邊框?yàn)?像素的虛線,顏色為黑色;border-bottom
表示下邊框?yàn)?像素的雙實(shí)線,顏色為黑色。
除了上述方法,你還可以使用border
屬性來(lái)同時(shí)設(shè)置上下邊框。
border: 1px solid #000;
上述代碼中的border
屬性會(huì)同時(shí)設(shè)置上下左右四個(gè)邊框?yàn)?像素的實(shí)線,顏色為黑色,如果你只想設(shè)置上下邊框,可以使用border-top
和border-bottom
屬性。