- Hands-On Full Stack Web Development with Aurelia
- Diego Jose Argüelles Rojas Erikson Haziz Murrugarra Sifuentes
- 276字
- 2021-06-25 20:58:24
How does it work?
CSS is based on rules. These rules are defined on .css files, called style sheet. Style sheets can be composed of one or more rules, applied to one HTML or XML document; the rule has two parts: selector and declaration:
h4 { color : red}
The h4 element is the selector, and { color : red } is the declaration.
The selector works as a link between the document and the style, specifying the elements that will be affected by that declaration. The statement is the part of the rule that states what the effect will be. In the previous example, selector h4 indicates that all elements h4 will be affected by the declaration stating that the color property will have the network value (red) for all elements h4 of the document or documents that are linked to that style sheet.
We have three ways to link our style sheet with the HTML file.
The first option is to use the <link> element, on the <head> section of the HTML file. We just need to specify the absolute or relative path/URL of our style sheet to import into our web page:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Aurelia is Awesome</title>
<link rel="stylesheet" type="text/css" />
</head>
<body>
.
.
</body>
</html>
Next, we can use the <style> element of the HTML file, generally in the <head> section too. It will be loaded when our file is called by the application:
<!DOCTYPE html>
<html lang="en">
<head>
<style type="text/css">
body {
padding-left: 11em;
font-family: Georgia, "Times New Roman", serif;
color: red;
background-color: #d8da3d;
}
h1 {
font-family: Helvetica, Geneva, Arial, sans-serif;
}
</style>
</head>
<body>
<!--Here the styles will be applied-->
</body>
</html>
Alternatively, we can style the HTML directly using the style flag:
<!DOCTYPE html>
<html lang="en">
<head>
<!--Nothing here-->
</head>
<body>
<h1 style="color: blue">Aurelia is awesome!</h1>
</body>
</html>
Ready to add some cool style to our application? This is just the beginning!
- EJB 3.1從入門到精通
- 物聯網短距離無線通信技術應用與開發
- Hands-On Industrial Internet of Things
- 電子政務效益的經濟分析與評價
- Learning QGIS 2.0
- 面向物聯網的嵌入式系統開發:基于CC2530和STM32微處理器
- Learning Swift(Second Edition)
- 網絡安全應急響應技術實戰
- 5G技術與標準
- 從實踐中學習手機抓包與數據分析
- Microsoft Power Platform Enterprise Architecture
- 無線傳感器網絡定位技術
- Qt5 Python GUI Programming Cookbook
- 計算機通信網絡安全
- 互聯網安全的40個智慧洞見(2018)