<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>參照父選擇器 - www.tw511.com</title> <link rel="stylesheet" type="text/css" href="style.css" /> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> </head> <body> <div class="container"> <h1>參照父選擇器的使用範例</h1> <a href="https://www.tw511.com/"> www.tw511.com </a> </div> </body> </html>
a { font-size: 20px; &:hover { background-color: yellow; } }
sass --watch C:\Ruby22-x64\style.scss:style.css
a { font-size: 20px; } a:hover { background-color: yellow; }
此處&將被替換父選擇<a>標籤。當連結滑鼠懸停,它會顯示背景色為黃色。