Learn Basic CSS by Building a Cafe Menu
基础框架
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>filename</title>
- </head>
-
- <body>
- <main>
- <section>
-
- </section>
- </main>
-
- <footer>
- <p>No Copyright -<a href="#">linkname</a> </p>
- </footer>
-
- </body>
- </html>
使用标签链接css样式文档rel=“stylesheet”
19:50 10mins
待学习知识点预估:
独立css文档调用
多个html文档共用同一个样式文件,相当于一个样式的组件便于快速修改样式
<link rel="stylesheet" href="coffeepattern.css">
css样式链接
- body{}
- h1,h2{...}
- x.classname{}
- .classname{}
样式类型
样式
复杂调用
不像html元素中那样无序,css中顺序很重要,html调用css的样式表顺序也重要‼️
设备适配兼容
- @media screen and(min-device-width:481px){
- #guarantee{
- margin-right:250px;
- }
- }
-
- @media screen and(max-device-width:480px){
- #guarantee{
- margin-right:30px;
- }
- }
css文档较大的时候建议在html中采用元素指定不同的样式表
15:30-16:00
step25居中元素:center the divhorizontally
setting its margin-leftand margin-right properties to auto
- margin-left:auto;
- margin-right:auto;
内联与外联
pelements are block-level elements, so they take up the entire width of their parent element.
o get them on the same line, you need to apply some styling to the pelements, so they behave more like inline elements.
Add a classattribute with the value item to the first articleelement under the Coffeeheading.
- <article class="item">
- <p class="flavor">French Vanilla</p>
- <p class="price">3.00</p>
- </article>
add a displayproperty with value inline-blockso the pelements behave more like inline elements.通过筛选类中的p实现内联
- .item p{
- display:inline-block;
- }
边框问题
The current width of the menu will always take up 80% of the body element's width. On a very wide screen, the coffee and dessert appear far apart from their prices.Add a max-width property to the menu class with a value of 500px to prevent it from growing too wide.
装饰
分割线:You can use an hr element to display a divider between sections of different content.
伪类
a:visited { propertyName: propertyValue; }.Change the color of the footer Visit our website link to be grey when a user has visited the link.