在這裏你去,玩得開心(我現在評論它解釋的代碼):
https://jsfiddle.net/MasterDoctor/rcc37dbr/1/
HTML:
<nav class="fancynav">
<ul>
<li><a href="#" class="arrow-link">Home</a></li>
<li><a href="#" class="arrow-link">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
CSS:
body {
/* Set body background (duh!) */
background-color: #000;
}
nav.fancynav ul {
/* Style navbar list */
list-style-type: none;
padding: 0;
margin: 0;
}
nav.fancynav ul li {
/* Remove bullet points */
list-style-type: none;
float: left;
margin-left: 10px;
}
nav.fancynav ul li a {
color: #3F51B5;
line-height: 24px;
text-decoration: none;
font-family: "Verdana";
font-size: 12px;
text-transform: uppercase;
transition: border-bottom 0.15s;
border-bottom: 1px solid rgba(0,0,0,0);
}
nav.fancynav ul li a:hover:not(.arrow-link) {
border-bottom: 1px solid #3F51B5;
}
nav.fancynav ul li a.arrow-link {
/* Style the main link as a block, with uppercase letters, Verdana font, blue color, no margin or padding, some left and vertical padding and a nice CSS transition. */
font-family: "Verdana";
display: inline-block;
text-transform: uppercase;
text-decoration: none;
color: #3F51B5;
border: 1px solid #3F51B5;
padding: 0px;
margin: 0px;
height: 24px;
padding-left: 5px;
font-size: 12px;
transition: background-color 0.15s, color 0.15s;
}
nav.fancynav ul li a.arrow-link:hover {
/* Modify the color and background on hover */
color: white;
background-color: #3F51B5;
}
nav.fancynav ul li a.arrow-link:after {
/* This is for styling the arrow, make it a block (but inline), the right background color, set the line height to make the arrow vertically centered, add some margin for spacing and finally set the color of the arrow. */
content: "\2192";
display: inline-block;
background-color: #3F51B5;
padding: 0px;
margin: 0px;
height: 24px;
line-height: 24px;
padding: 0px 5px;
margin-left: 5px;
color: white;
}
編輯#1 :對不起,我知道發佈已完成的代碼是不受歡迎的,但我拖延了一些討厭的後端工作(和家庭作業)。
編輯#2:三角形,你可以使用CSS(https://css-tricks.com/snippets/css/css-triangle/),也可以使用UTF-8符號(https://www.w3schools.com/charsets/ref_utf_arrows.asp)
這是我曾嘗試到目前爲止
你正在開始正確的軌道,但你需要確保下次發佈你的代碼在這個問題:) – scoopzilla
對於箭頭,你可以使用→ - UTF-8右箭頭。 – SamJakob