mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
updates
This commit is contained in:
@@ -48,98 +48,6 @@ Selectors can be a single tag, class, ID, or attribute. It can also be a [combin
|
||||
Below is a series of selectors and property/value combinations that we'll apply to our CSS demo page.
|
||||
|
||||
```css
|
||||
/* Targeting the entire page */
|
||||
body {
|
||||
font: 1.2em sans-serif;
|
||||
}
|
||||
|
||||
/* Targeting an HTML tag */
|
||||
h1 {
|
||||
/* Color name */
|
||||
color: black;
|
||||
|
||||
/* 6-digit hex */
|
||||
background: #ababab;
|
||||
|
||||
/* Margin: specified separately for each side */
|
||||
margin-bottom: 15px;
|
||||
margin-top: 15px;
|
||||
|
||||
/* Shorthand: Padding applies to all sides */
|
||||
padding: 10px;
|
||||
|
||||
/* Border shorthand and 3-digit hex */
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
/* Overriding inherited styles */
|
||||
span {
|
||||
color: #004578;
|
||||
}
|
||||
|
||||
/* Sibling selector */
|
||||
a ~ a {
|
||||
/* Changing elements from inline to block */
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Targeting a class name */
|
||||
.tiles {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Descendant selector */
|
||||
.tiles img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Direct descendant selector */
|
||||
.tiles > div {
|
||||
/* rgb color */
|
||||
background: rgb(10, 10, 10);
|
||||
color: white;
|
||||
flex-basis: 100%;
|
||||
/* Padding/margin shorthand. Goes clockwise from top.
|
||||
10px - all
|
||||
10px 20px - top/bottom left/right
|
||||
10px 20px 15px - top left/right bottom
|
||||
*/
|
||||
padding: 10px 20px 15px;
|
||||
margin: 10px 20px 10px 0;
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
/* Qualified selector */
|
||||
div.important-links {
|
||||
background: #004578;
|
||||
}
|
||||
|
||||
/* Style inheritance only works for unstyled elements */
|
||||
a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Hover pseudo-selector */
|
||||
a:hover {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
/* Positional pseudo-selector */
|
||||
.tiles > div:last-child {
|
||||
/* overrides margin-right but leaves other margins alone */
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
/* ID selector */
|
||||
#contact-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Attribute selector */
|
||||
input[type='submit'] {
|
||||
margin-top: 10px;
|
||||
}
|
||||
```
|
||||
|
||||
## Next Step
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="./style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<h1>This is my <span>Title</span></h1>
|
||||
<div class="tiles">
|
||||
<div class="important-links">
|
||||
<h2>Important Links</h2>
|
||||
<a href="#">We're Awesome</a>
|
||||
<a href="#">Learn More</a>
|
||||
<a href="#">Hire Us</a>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Our Logo</h2>
|
||||
<img src="../../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Contact Us</h2>
|
||||
<div id="contact-form">
|
||||
<label>Email</label><input type="email" />
|
||||
<input value="Submit" type="submit" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
132
step1-02/demo/index.html
Normal file
132
step1-02/demo/index.html
Normal file
@@ -0,0 +1,132 @@
|
||||
<html>
|
||||
<body>
|
||||
<div
|
||||
class="codepen"
|
||||
data-theme-id="36294"
|
||||
data-prefill
|
||||
data-editable="true"
|
||||
data-height="100%"
|
||||
data-theme-id="1"
|
||||
data-default-tab="html,result"
|
||||
>
|
||||
<pre data-lang="css">
|
||||
/* Targeting the entire page */
|
||||
//body {
|
||||
font: 1.2em sans-serif;
|
||||
}
|
||||
|
||||
/* Targeting an HTML tag */
|
||||
//h1 {
|
||||
/* Color name */
|
||||
color: black;
|
||||
|
||||
/* 6-digit hex */
|
||||
background: #ababab;
|
||||
|
||||
/* Margin: specified separately for each side */
|
||||
margin-bottom: 15px;
|
||||
margin-top: 15px;
|
||||
|
||||
/* Shorthand: Padding applies to all sides */
|
||||
padding: 10px;
|
||||
|
||||
/* Border shorthand and 3-digit hex */
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
/* Overriding inherited styles */
|
||||
//span {
|
||||
color: #004578;
|
||||
}
|
||||
|
||||
/* Sibling selector */
|
||||
//a + a {
|
||||
/* Changing elements from inline to block */
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Targeting a class name */
|
||||
//.tiles {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* Descendant selector */
|
||||
//.tiles img {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Direct descendant selector */
|
||||
//.tiles > div {
|
||||
/* rgb color */
|
||||
background: rgb(10, 10, 10);
|
||||
color: white;
|
||||
flex-basis: 100%;
|
||||
/* Padding/margin shorthand. Goes clockwise from top.
|
||||
10px - all
|
||||
10px 20px - top/bottom left/right
|
||||
10px 20px 15px - top left/right bottom
|
||||
*/
|
||||
padding: 10px 20px 15px;
|
||||
margin: 10px 20px 10px 0;
|
||||
border: 1px solid white;
|
||||
}
|
||||
|
||||
/* Qualified selector */
|
||||
//div.important-links {
|
||||
background: #004578;
|
||||
}
|
||||
|
||||
/* Style inheritance only works for unstyled elements */
|
||||
//a {
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Hover pseudo-selector */
|
||||
//a:hover {
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
/* Positional pseudo-selector */
|
||||
//.tiles > div:last-child {
|
||||
/* overrides margin-right but leaves other margins alone */
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
/* ID selector */
|
||||
//#contact-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* Attribute selector */
|
||||
//input[type='submit'] {
|
||||
margin-top: 10px;
|
||||
}
|
||||
</pre>
|
||||
<pre data-lang="html">
|
||||
<h1>This is my <span>Title</span></h1>
|
||||
<div class="tiles">
|
||||
<div class="important-links">
|
||||
<h2>Important Links</h2>
|
||||
<a href="#">We're Awesome</a>
|
||||
<a href="#">Learn More</a>
|
||||
<a href="#">Hire Us</a>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Our Logo</h2>
|
||||
<img src="../../assets/fabric.jpg" width="100" alt="fabric logo" />
|
||||
</div>
|
||||
<div>
|
||||
<h2>Contact Us</h2>
|
||||
<div id="contact-form">
|
||||
<label>Email</label><input type="email" />
|
||||
<input value="Submit" type="submit" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,62 +0,0 @@
|
||||
/* body {
|
||||
font: 1.2em sans-serif;
|
||||
} */
|
||||
|
||||
/* h1 {
|
||||
color: black;
|
||||
background: #ababab;
|
||||
margin-bottom: 15px;
|
||||
margin-top: 15px;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
} */
|
||||
|
||||
/* span {
|
||||
color: #004578;
|
||||
} */
|
||||
|
||||
/* a ~ a {
|
||||
display: block;
|
||||
} */
|
||||
|
||||
/* .tiles {
|
||||
display: flex;
|
||||
} */
|
||||
|
||||
/* .tiles img {
|
||||
width: 100%;
|
||||
} */
|
||||
|
||||
/* .tiles > div {
|
||||
background: rgb(10, 10, 10);
|
||||
color: white;
|
||||
flex-basis: 100%;
|
||||
padding: 10px 20px 15px;
|
||||
margin: 10px 20px 10px 0;
|
||||
border: 1px solid white;
|
||||
} */
|
||||
|
||||
/* div.important-links {
|
||||
background: #004578;
|
||||
} */
|
||||
|
||||
/* a {
|
||||
color: white;
|
||||
} */
|
||||
|
||||
/* a:hover {
|
||||
color: #ccc;
|
||||
} */
|
||||
|
||||
/* .tiles > div:last-child {
|
||||
margin-right: 0;
|
||||
} */
|
||||
|
||||
/* #contact-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
} */
|
||||
|
||||
/* input[type='submit'] {
|
||||
margin-top: 10px;
|
||||
} */
|
||||
27
step1-02/exercise/answers.css
Normal file
27
step1-02/exercise/answers.css
Normal file
@@ -0,0 +1,27 @@
|
||||
h2 {
|
||||
color: red;
|
||||
}
|
||||
|
||||
h2 + div {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.myList li {
|
||||
border: 1px solid green;
|
||||
}
|
||||
|
||||
.myClass {
|
||||
background: green;
|
||||
}
|
||||
|
||||
#myId {
|
||||
background: yellow;
|
||||
}
|
||||
|
||||
.myClass.otherClass {
|
||||
color: white;
|
||||
}
|
||||
|
||||
section > div:last-child {
|
||||
border: 1px solid pink;
|
||||
}
|
||||
56
step1-02/exercise/index.html
Normal file
56
step1-02/exercise/index.html
Normal file
@@ -0,0 +1,56 @@
|
||||
<html>
|
||||
<body>
|
||||
<div
|
||||
class="codepen"
|
||||
data-theme-id="36294"
|
||||
data-prefill
|
||||
data-editable="true"
|
||||
data-height="100%"
|
||||
data-theme-id="1"
|
||||
data-default-tab="html,result"
|
||||
>
|
||||
<pre data-lang="css">
|
||||
/* 1. */
|
||||
|
||||
/* 2. */
|
||||
|
||||
/* 3. */
|
||||
|
||||
/* 4. */
|
||||
|
||||
/* 5. */
|
||||
|
||||
/* 6. */
|
||||
|
||||
/* Bonus */
|
||||
</pre>
|
||||
<pre data-lang="html">
|
||||
<section>
|
||||
<h2>1. Text Color: Red</h2>
|
||||
<div>2. Color Green (hint: Sibling Selector)</div>
|
||||
<ul class="myList">
|
||||
<li>
|
||||
3. Border Green
|
||||
</li>
|
||||
</ul>
|
||||
<main>
|
||||
<div class="myClass">4. Background Green</div>
|
||||
<div class="myClass otherClass">
|
||||
5. Background Green & Color White
|
||||
(Hint Qualified Selector)
|
||||
</div>
|
||||
<div id="myId" class="otherClass">6. Background Yellow</div>
|
||||
</main>
|
||||
<ul>
|
||||
<li>
|
||||
Don't Style Me
|
||||
</li>
|
||||
</ul>
|
||||
<div>Bonus: Border Pink</div>
|
||||
</section>
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user