diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..18991c69 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,35 @@ +// For format details, see https://aka.ms/devcontainer.json. For config options, see the +// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node +{ + "name": "Node.js", + // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile + "image": "mcr.microsoft.com/devcontainers/javascript-node:0-16", + "customizations": { + "vscode": { + "settings": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "workbench.editorAssociations": { + "*.md": "vscode.markdown.preview.editor" + } + }, + "extensions": ["learn-pack.learnpack-vscode"] + } + }, + + // Features to add to the dev container. More info: https://containers.dev/features. + // "features": {}, + + // Use 'forwardPorts' to make a list of ports inside the container available locally. + // "forwardPorts": [], + + "onCreateCommand": "npm i jest@29.7.0 jest-environment-jsdom@29.7.0 -g && npm i @learnpack/learnpack@5.0.13 -g && learnpack plugins:install @learnpack/html@1.1.7" + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "yarn install", + + // Configure tool-specific properties. + // "customizations": {}, + + // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. + // "remoteUser": "root" +} diff --git a/.github/workflows/learnpack-audit.yml b/.github/workflows/learnpack-audit.yml index 70f416ee..95814c2a 100644 --- a/.github/workflows/learnpack-audit.yml +++ b/.github/workflows/learnpack-audit.yml @@ -5,9 +5,9 @@ name: Learnpack audit on: push: - branches: [ master ] + branches: [ main ] pull_request: - branches: [ master ] + branches: [ main ] jobs: build: @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [14.x] + node-version: [20.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -25,5 +25,5 @@ jobs: uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - - run: npm install learnpack -g + - run: npm install @learnpack/learnpack@latest -g - run: learnpack audit \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8f255a69..b54a1f9f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,8 @@ !bc.json !learn.json !README.md +!README.es.md +!.vscode !/exercises !/exercises/* diff --git a/.gitpod.Dockerfile b/.gitpod.Dockerfile index 33ad46d7..6e137a77 100644 --- a/.gitpod.Dockerfile +++ b/.gitpod.Dockerfile @@ -3,5 +3,4 @@ FROM gitpod/workspace-full:latest USER gitpod -RUN npm i jest@24.8.0 -g -RUN npm i learnpack@0.1.17 -g && learnpack plugins:install learnpack-html@0.0.20 +RUN npm i jest@29.7.0 jest-environment-jsdom@29.7.0 -g && npm i @learnpack/learnpack@2.1.47 -g && learnpack plugins:install @learnpack/html@1.1.7 diff --git a/.gitpod.yml b/.gitpod.yml index 0eeb2583..fbb44ce0 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -8,7 +8,8 @@ ports: vscode: extensions: - - learnpack.learnpack-vscode + - learn-pack.learnpack-vscode + github: prebuilds: diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..2f5ad94d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "files.autoSave": "afterDelay", + "files.autoSaveDelay": 700, + "editor.minimap.enabled": false, + "workbench.editorAssociations": { + "*.md": "vscode.markdown.preview.editor" + } +} \ No newline at end of file diff --git a/README.es.md b/README.es.md new file mode 100644 index 00000000..23cb7b39 --- /dev/null +++ b/README.es.md @@ -0,0 +1,100 @@ +# Tutorial de Ejercicios de CSS de 4Geeks Academy + +
![]() |
+
+ |
+
Hello | +
My brother | +
+ Coding is a basic literacy in the digital age, and it is important for kids to understand and be able to work with and understand the technology + around them. Having children learn to code at a young age prepares them for the future. Coding helps children with communication, creativity, + math, writing, and confidence. +
diff --git a/exercises/02.1-add-a-style-tag/test.js b/exercises/02.1-add-a-style-tag/test.js new file mode 100644 index 00000000..0b3c714b --- /dev/null +++ b/exercises/02.1-add-a-style-tag/test.js @@ -0,0 +1,22 @@ +const fs = require('fs'); +const path = require('path'); +const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8'); +document.documentElement.innerHTML = html.toString(); + +jest.dontMock('fs'); + +const p = document.querySelector("p"); + +test("There should be atag", ()=>{ + expect(p).toBeTruthy(); +}) + +test("The
tag color should be blue", ()=>{ + let styles = window.getComputedStyle(p); + expect(styles["color"]).toBe("blue"); +}); + +test("The
tag should not contain any inline style", ()=>{ + let emptyBodyInlineStyle = {}; + expect(p.style._values).toEqual(emptyBodyInlineStyle); +}); diff --git a/exercises/02.2-rbga-colors/README.es.md b/exercises/02.2-rbga-colors/README.es.md new file mode 100644 index 00000000..e448639a --- /dev/null +++ b/exercises/02.2-rbga-colors/README.es.md @@ -0,0 +1,21 @@ +--- +tutorial: "https://www.youtube.com/watch?v=8RntHMOAFqI" +--- + +# `02.2` Your First Style + +Cuando usas CSS, la idea es aplicar `reglas css` a tus `elementos html`, siempre debes seleccionar primero el elemento y luego especificar qué reglas deseas aplicarle: + +Por ejemplo, este es el código si quiero que todos los `anchors` de mi sitio web (etiquetas ``) sean azules (`blue`): + +```css +a { + color: blue; +} +``` + +## 📝 Instrucciones: + +1. En este momento, se está aplicando un estilo que se encarga de hacer el enlace rojo (`red)`. + +2. Cambia el estilo para que tu enlace se vea amarillo (`yellow`). diff --git a/exercises/02.2-rbga-colors/README.md b/exercises/02.2-rbga-colors/README.md new file mode 100644 index 00000000..a47fb128 --- /dev/null +++ b/exercises/02.2-rbga-colors/README.md @@ -0,0 +1,21 @@ +--- +tutorial: "https://www.youtube.com/watch?v=TqmY9GLTwQ0" +--- + +# `02.2` Your First Style + +When doing CSS, the idea is to apply `css rules` to your `html elements`, you always have to select the element first, and then specify what rules you want to apply to it: + +For example, this is the code if you want to make all your website anchors (`` tags) blue: + +```css +a { + color: blue; +} +``` + +## 📝 Instructions: + +1. Right now there is a style being applied that is responsible for making the anchor `red`. + +2. Change the style to make your anchor look `yellow`. diff --git a/exercises/01.2-Your-First-Style/index.html b/exercises/02.2-rbga-colors/index.html similarity index 100% rename from exercises/01.2-Your-First-Style/index.html rename to exercises/02.2-rbga-colors/index.html diff --git a/exercises/02.2-rbga-colors/solution.hide.html b/exercises/02.2-rbga-colors/solution.hide.html new file mode 100644 index 00000000..a2a88d04 --- /dev/null +++ b/exercises/02.2-rbga-colors/solution.hide.html @@ -0,0 +1,14 @@ + + + + + + + Hello! I am an anchor in red, change my color to yellow + + diff --git a/exercises/02.2-rbga-colors/tests.js b/exercises/02.2-rbga-colors/tests.js new file mode 100644 index 00000000..32bf609b --- /dev/null +++ b/exercises/02.2-rbga-colors/tests.js @@ -0,0 +1,34 @@ +const fs = require('fs'); +const path = require('path'); +const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8'); +document.documentElement.innerHTML = html.toString(); + +jest.dontMock('fs'); + +describe("All the styles should be applied", ()=>{ + const a = document.querySelector("a"); + + test("The anchor tag should be yellow", ()=>{ + let styles = window.getComputedStyle(a); + expect(styles["color"]).toBe("yellow"); + }); + + test("The
tag should not contain any inline style", ()=>{ + let bodyInlineStyle = document.getElementsByTagName("body"); + let emptyBodyInlineStyle = {}; + expect(bodyInlineStyle[0].style._values).toEqual(emptyBodyInlineStyle); + }); + + test("The anchor tag should not contain any inline style", ()=>{ + let emptyBodyInlineStyle = {}; + expect(a.style._values).toEqual(emptyBodyInlineStyle); + }); + + test("You should not change the existing tag elements", ()=>{ + let head = document.querySelector('head') + expect(head).toBeTruthy() + + let meta = head.querySelector("meta") + expect(meta).toBe(null) + }) +}); diff --git a/exercises/01.3-Your-Second-Style/README.es.md b/exercises/02.3-your-second-style/README.es.md similarity index 67% rename from exercises/01.3-Your-Second-Style/README.es.md rename to exercises/02.3-your-second-style/README.es.md index 825c10a1..a6e3630c 100644 --- a/exercises/01.3-Your-Second-Style/README.es.md +++ b/exercises/02.3-your-second-style/README.es.md @@ -1,8 +1,12 @@ -# `01.2` Tu Segundo Estilo +--- +tutorial: "https://www.youtube.com/watch?v=vTS0D_QrbH8" +--- + +# `02.3` Your Second Style Cuando usas CSS, la idea es aplicar `reglas css` a tus `elementos html`, siempre debes seleccionar primero el elemento y luego especificar qué reglas deseas aplicarle: -Por ejemplo, este es el código si quiero que todos las anchors de mi sitio web (etiquetas ``) sean azules: +Por ejemplo, este es el código si quiero que todos los anchors de mi sitio web (etiquetas ``) sean azules: ```css a { @@ -13,4 +17,5 @@ a { ## 📝 Instrucciones: 1. Haz que el fondo de tu sitio web sea azul (blue) seleccionando el `body` y aplicando la regla `background` con valor `blue`. -2. Compila y muestra una vista previa del ejercicio y tu resultado debe ser un body azul (toda la página azul). + +2. Compila y muestra una vista previa del ejercicio y tu resultado debe ser un `body` azul (`blue`), es decir, toda la página azul. diff --git a/exercises/01.3-Your-Second-Style/README.md b/exercises/02.3-your-second-style/README.md similarity index 56% rename from exercises/01.3-Your-Second-Style/README.md rename to exercises/02.3-your-second-style/README.md index e1d363a0..8918e346 100644 --- a/exercises/01.3-Your-Second-Style/README.md +++ b/exercises/02.3-your-second-style/README.md @@ -1,12 +1,12 @@ --- -tutorial: "https://www.youtube.com/watch?v=W0CAqLIAoZI" +tutorial: "https://www.youtube.com/watch?v=ituoKgAh6ds" --- -# `01.3` Your Second Style +# `02.3` Your Second Style When doing CSS, the idea is to apply `css rules` to your `html elements`, you always have to select the element first, and then specify what rules you want to apply to it: -For example, this is the code if I want to make all my website anchors (` tag's`) blue: +For example, this is the code if you want to make all your website anchors (`` tags) blue: ```css a { @@ -17,4 +17,5 @@ a { ## 📝 Instructions: 1. Make your website background blue by selecting the `body` and applying the `background` rule with a `blue` value. -2. Build and preview the exercise and your result should be a blue `body` (the whole page blue). + +2. Run and preview the exercise and your result should be a blue `body` (the whole page blue). diff --git a/exercises/01.3-Your-Second-Style/index.html b/exercises/02.3-your-second-style/index.html similarity index 100% rename from exercises/01.3-Your-Second-Style/index.html rename to exercises/02.3-your-second-style/index.html diff --git a/exercises/02.3-your-second-style/solution.hide.html b/exercises/02.3-your-second-style/solution.hide.html new file mode 100644 index 00000000..9b239409 --- /dev/null +++ b/exercises/02.3-your-second-style/solution.hide.html @@ -0,0 +1,14 @@ + + + + + + + Hello! My background should be blue! + + diff --git a/exercises/02.3-your-second-style/tests.js b/exercises/02.3-your-second-style/tests.js new file mode 100644 index 00000000..8b52f01d --- /dev/null +++ b/exercises/02.3-your-second-style/tests.js @@ -0,0 +1,28 @@ +const fs = require('fs'); +const path = require('path'); +const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8'); +document.documentElement.innerHTML = html.toString(); + +jest.dontMock('fs'); + +describe("All the styles should be applied", ()=>{ + const body = document.querySelector("body"); + + test("The background should be blue", ()=>{ + let styles = window.getComputedStyle(body); + expect(styles["background"]).toBe("blue"); + }); + + test("The body tag should not contain any inline style", ()=>{ + let emptyBodyInlineStyle = {}; + expect(body.style._values).toEqual(emptyBodyInlineStyle); + }); + + test("You should not change the existing head tag elements", ()=>{ + let head = document.querySelector('head') + expect(head).toBeTruthy() + + let meta = head.querySelector("meta") + expect(meta).toBe(null) + }) +}); diff --git a/exercises/03-Inline-Styles/README.es.md b/exercises/03-Inline-Styles/README.es.md deleted file mode 100644 index 36e1ed60..00000000 --- a/exercises/03-Inline-Styles/README.es.md +++ /dev/null @@ -1,28 +0,0 @@ -# `03` Inline Styles (estilos en la línea) - -Los estilos inline son una muy mala idea a menos que no tengas otra opción (y esa es una situación muy poco común). Lamentablemente, tenemos que enseñarte cómo hacerlo porque existe la posibilidad de que necesites usarlos en algún momento. - -Para usar estilos inline, en lugar de declarar una etiqueta `; + let emptyBodyInlineStyle={}; + expect(body.style._values).toEqual(emptyBodyInlineStyle) + }); + + test("You should not change the existing tag elements", ()=>{ + let head = document.querySelector('head') + expect(head).toBeTruthy() + + let meta = head.querySelector("meta") + expect(meta).toBe(null) + + let href = link.getAttribute("href") + expect(href).toEqual('./styles.css') + }); + + test("Your tag background color should be blue", ()=>{ + let styles = window.getComputedStyle(body) + expect(styles["background-color"]).toBe("blue") + }) +}); diff --git a/exercises/03.1-background/README.es.md b/exercises/03.1-background/README.es.md new file mode 100644 index 00000000..e0af7277 --- /dev/null +++ b/exercises/03.1-background/README.es.md @@ -0,0 +1,31 @@ +--- +tutorial: "https://www.youtube.com/watch?v=a1ACEu996z4" +--- + +# `03.1` Background + +La regla `background` (fondo) de CSS nos permite asignar y trabajar con el background de cualquier contenedor (container). Los valores de background pueden ser `color` o una `imagen`. + +Si es una imagen, puedes especificar si quieres que la imagen se repita horizontalmente, verticalmente, ambas o ninguna, y también puedes especificar si quieres cambiar el tamaño y ajustar su tamaño al contenedor completo, entre otras propiedades, eso puede modificarse. + +## 📝 Instrucciones: + +1. Construye el ejercicio. + +2. Verifica la vista previa. + +3. En el archivo styles.css cambia el `background-size` a `contain` (verifica la pestaña styles.css). + +4. Construye y previsualiza el ejercicio nuevamente. + +5. Cambia el `background-repeat` a `repeat` para que se repita sobre el eje x y el eje y. + +6. Construye y previsualiza el ejercicio nuevamente. + +## 💡 Pista: + +Google es tu mejor amigo: + +- Recomendamos buscar en google `css background-size` para entender un poco mejor esta propiedad. + +- También recomendamos buscar `css background-repeat` diff --git a/exercises/02.1-Background/README.md b/exercises/03.1-background/README.md similarity index 50% rename from exercises/02.1-Background/README.md rename to exercises/03.1-background/README.md index d81d440a..3580ab7e 100644 --- a/exercises/02.1-Background/README.md +++ b/exercises/03.1-background/README.md @@ -1,32 +1,31 @@ --- -tutorial: "https://www.youtube.com/watch?v=MJI0-sFmTe8" +tutorial: "https://www.youtube.com/watch?v=fQh2OulBSp8" --- -# `02.1` Background +# `03.1` Background The `background` CSS rule allows us to assign and work with the background of any container. The background values can be a `color` or an `image`. -If it is an image, you can specify if you want the image to be repeated horizontally, vertically, or both, or not at all, and you can also specify if you want it to resize and fit the whole container where its being applied, among other properties that can be modified. +If it is an image, you can specify if you want the image to be repeated horizontally, vertically, or both, or not at all, and you can also specify if you want it to resize and fit the whole container where it is being applied, among other properties that can be modified. ## 📝 Instructions: - -1. Build the exercise. +1. Run the exercise. 2. Check the Preview. 3. On the styles.css file change the background-size to 'contain' (check the styles.css tab). -4. Build and Preview the exercise again. +4. Run and Preview the exercise again. -5. Change the background-repeat to 'inherit' to make it repeat over the x axis and y axis. +5. Change the background-repeat to 'repeat' to make it repeat over the x-axis and y-axis. -6. Build and Preview the exercise again. +6. Run and Preview the exercise again. -## 💡Hint: +## 💡 Hint: Google is your best friend: -- How to use the background-size: http://lmgtfy.com/?q=css+background-size -- How to use the background-repeat: http://lmgtfy.com/?q=css+background-repeat +- We recommend googling: `css background-size` and reading about it on w3schools or any other websites. +- We also recommend googling about `css background-repeat`. diff --git a/exercises/02.1-Background/index.html b/exercises/03.1-background/index.html similarity index 58% rename from exercises/02.1-Background/index.html rename to exercises/03.1-background/index.html index ce03ce24..a1227330 100644 --- a/exercises/02.1-Background/index.html +++ b/exercises/03.1-background/index.html @@ -2,9 +2,9 @@ -`. diff --git a/exercises/04-Class-Selector/README.md b/exercises/04-Class-Selector/README.md deleted file mode 100644 index fd476e56..00000000 --- a/exercises/04-Class-Selector/README.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -tutorial: "https://www.youtube.com/watch?v=RffCSMXgWFc" ---- - -# `04` Class Selector - -There are many ways to select HTML elements to apply styles to them, so far we have only use the `tag` selector, lets talk about the `.class` selector: - -#### 1) `.class` Selector - -It is the most popular css selector, you will probably use it every 5 minutes. - -Use the class property of the HTML element to select it. Styling rules will apply to all elements with the same class value - -```css -.small{ - font-size: 9px; -} -``` -**Note:** - -Any html tag with the `class="small"` will have a font-size of 9px. - -# 📝 Instructions: - -Right now there is a class selected on the CSS that is called `.b-blue`. Please apply that class to both of the `
` tags in HTML. - - diff --git a/exercises/04-list-styling/README.es.md b/exercises/04-list-styling/README.es.md new file mode 100644 index 00000000..f67abca2 --- /dev/null +++ b/exercises/04-list-styling/README.es.md @@ -0,0 +1,42 @@ +--- +tutorial: "https://www.youtube.com/watch?v=qcx31wUVmqI" +--- + +# `04` List styling + +En el desarrollo front end, a menudo tenemos que listar ítems y la forma de hacerlo es con las etiquetas `
`. diff --git a/exercises/05-class-selector/README.md b/exercises/05-class-selector/README.md new file mode 100644 index 00000000..eea336a9 --- /dev/null +++ b/exercises/05-class-selector/README.md @@ -0,0 +1,29 @@ +--- +tutorial: "https://www.youtube.com/watch?v=moLgdg7x84U" +--- + +# `05` Class Selector + +There are many ways to select HTML elements to apply styles to them, so far we have only used the `tag` selector, so let's talk about the `.class` selector: + +## `.class` Selector + +It is the most popular CSS selector, you will probably use it every 5 minutes. + +Use the class property of the HTML element to select it. Styling rules will apply to all elements with the same class value + +```css +.small{ + font-size: 9px; +} +``` + +*Any HTML tag with the `class="small"` will have a font-size of `9px`.* + +## 📝 Instructions: + +1. Right now there is a class selected on the CSS that is called `b-blue`. + +2. Please apply that class to both of the HTML `
` tags. + + diff --git a/exercises/04-Class-Selector/index.html b/exercises/05-class-selector/index.html similarity index 79% rename from exercises/04-Class-Selector/index.html rename to exercises/05-class-selector/index.html index e3abd1bd..03662721 100644 --- a/exercises/04-Class-Selector/index.html +++ b/exercises/05-class-selector/index.html @@ -2,9 +2,7 @@
-Hello!
+World!
+ + diff --git a/exercises/04-Class-Selector/styles.css b/exercises/05-class-selector/styles.css similarity index 100% rename from exercises/04-Class-Selector/styles.css rename to exercises/05-class-selector/styles.css diff --git a/exercises/05-class-selector/test.js b/exercises/05-class-selector/test.js new file mode 100644 index 00000000..36108cbd --- /dev/null +++ b/exercises/05-class-selector/test.js @@ -0,0 +1,40 @@ +const fs = require("fs"); +const path = require("path"); +const html = fs.readFileSync(path.resolve(__dirname, './index.html'), 'utf8'); +const css = fs.readFileSync(path.resolve(__dirname, "./styles.css"), "utf8"); +document.documentElement.innerHTML = html.toString(); + +jest.dontMock("fs"); + +describe("Bothtags should have a blue background", () => { + const body = document.querySelector("body") + const p = document.querySelectorAll("p"); + test("You should not change the existing
tag elements", () => { + let head = document.querySelector('head') + expect(head).toBeTruthy() + + let meta = head.querySelector("meta") + expect(meta).toBe(null) + + let title = head.querySelector('title').innerHTML + expect(title).toBe('05 Class selector') + }); + + test("The tag should not contain any inline style", () => { + document.querySelector( + "head" + ).innerHTML = ``; + let emptyBodyInlineStyle = {}; + expect(body.style._values).toEqual(emptyBodyInlineStyle) + }); + + test("There should be twotags", () => { + expect(p.length).toBe(2) + }); + test("Both
tags should have a class name 'b-blue'", () => { + p.forEach(e=>{ + let eClass = e.getAttribute("class"); + expect(eClass).toBe("b-blue") + }) + }); +}); diff --git a/exercises/05.1-combined-rules/README.es.md b/exercises/05.1-combined-rules/README.es.md new file mode 100644 index 00000000..8e735e07 --- /dev/null +++ b/exercises/05.1-combined-rules/README.es.md @@ -0,0 +1,42 @@ +--- +tutorial: "https://www.youtube.com/watch?v=NYlPhkmqgmU" +--- + +# `05.1` Combined Rules + +Los archivos CSS ocupan espacio en tu servidor y también tardan en descargarse (como todo); es otro documento de texto que el navegador debe descargar antes de mostrar la página, por lo que es importante mantener el documento CSS lo más pequeño posible. + +Una forma de hacerlo es combinando varias propiedades en una, como con `border`: + +```css +border-color: black; +border-style: solid; +border-width: 1px; +``` + +Las propiedades de border se pueden consolidar en una sola línea así: + +```css +border: black 1px solid; +``` + +## 📝 Instrucciones: + + +1. Combina las 4 reglas de padding en una sola utilizando la regla `padding`. + +2. Combina todas las reglas de background en una sola línea usando la regla `background`. + +*Las propiedades `background-position` y `background-size` pueden usar el mismo tipo de datos por lo que entrarán en conflicto, así que en vez de separar estas propiedades con un **espacio**, debes separarlas con una barra `/` de esta forma:* + +```css +background: 50px / cover +``` + +Donde el valor de la izquierda de la barra `/` es la propiedad `background-position` y la derecha es el `background-size`. + +## 💡 Pistas: + +- Cómo usar `background`: https://www.w3schools.com/cssref/css3_pr_background.php + +- Cómo usar `padding`: https://www.w3schools.com/css/css_padding.asp diff --git a/exercises/05.1-combined-rules/README.md b/exercises/05.1-combined-rules/README.md new file mode 100644 index 00000000..55bd0c87 --- /dev/null +++ b/exercises/05.1-combined-rules/README.md @@ -0,0 +1,41 @@ +--- +tutorial: "https://www.youtube.com/watch?v=VTOwd98T6FY" +--- + +# `05.1` Combined Rules + +CSS files take up space on your server and also take time to download (like everything); it is yet another text document that the browser has to download before rendering the page, which is why it's important to keep the CSS document as small as possible. + +One way to do that is by combining several properties into one, such as with `border`: + +```css +border-color: black; +border-style: solid; +border-width: 1px; +``` + +Border's properties can be consolidated into a single line like this: + +```css +border: black 1px solid; +``` + +## 📝 Instructions: + +1. Combine the 4 padding rules into only one using the `padding` rule. + +2. Combine all background rules into only one using the `background` rule. + +*The `background-position` and the `background-size` properties will conflict because they can handle the same type of values, so instead of separating these properties with a `space` you must separate them with a forward slash `/` as follows:* + +```css +background: 50px / cover +``` + +Where the left side value of the forward slash `/` is the `background-position` rule and the right value is the `background-size` rule. + +## 💡 Hints: + +- How to use `background`: https://www.w3schools.com/cssref/css3_pr_background.php + +- How to use `padding`: https://www.w3schools.com/css/css_padding.asp diff --git a/exercises/04.1-Combined-Rules/index.html b/exercises/05.1-combined-rules/index.html similarity index 79% rename from exercises/04.1-Combined-Rules/index.html rename to exercises/05.1-combined-rules/index.html index 2af5a24c..bca34a30 100644 --- a/exercises/04.1-Combined-Rules/index.html +++ b/exercises/05.1-combined-rules/index.html @@ -2,9 +2,7 @@
-- We are going to explain in this pharagraph the 3 most comon signs that you should look into yourself to recognize if you are learning. -
-- If you can't sleep, what better than watching videos of cats? - click here -
- - \ No newline at end of file diff --git a/exercises/06-Practicing-Rules/styles.css b/exercises/06-Practicing-Rules/styles.css deleted file mode 100644 index d89b1a47..00000000 --- a/exercises/06-Practicing-Rules/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* add your styles here */ \ No newline at end of file diff --git a/exercises/06-Practicing-Rules/tests.js b/exercises/06-Practicing-Rules/tests.js deleted file mode 100644 index 62263d92..00000000 --- a/exercises/06-Practicing-Rules/tests.js +++ /dev/null @@ -1,145 +0,0 @@ -const fs=require("fs"); -const path=require("path"); -const html=fs.readFileSync(path.resolve(__dirname, "./index.html"), "utf8"); -const css=fs.readFileSync(path.resolve(__dirname, "./styles.css"), "utf8"); - -jest.dontMock("fs"); - -describe("All the styles should be applied", function () { - beforeEach(() => { - //here I import the HTML into the document - document.documentElement.innerHTML=html.toString(); - - // apply the styles from the stylesheet if needed - - }); - afterEach(() => { - jest.resetModules(); - }); - - - - it("the background should match", function () { - document.querySelector( - "head" - ).innerHTML=``; - let body=document.querySelector("body"); - let styles=window.getComputedStyle(body); - expect(styles["background"]).toBe( - `url(../../.learn/assets/background-vertical.jpg?raw=true) repeat-y` - ); - }); - it("the font-family should be 'Times New Roman'", function () { - document.querySelector( - "head" - ).innerHTML=``; - let body=document.querySelector("body"); - let styles=window.getComputedStyle(body); - expect(styles["font-family"]).toBe("Times New Roman"); - }); - it("the padding-left should be '20px'", function () { - document.querySelector( - "head" - ).innerHTML=``; - let body=document.querySelector("body"); - let styles=window.getComputedStyle(body); - expect(styles["padding-left"]).toBe("20px"); - }); - it("the font-family in the H1 Tag should be 'Courier'", function () { - document.querySelector( - "head" - ).innerHTML=``; - let h1Tag=document.querySelector("h1"); - let h1TagStyles=window.getComputedStyle(h1Tag); - // get computed styles of any element you like - expect(h1TagStyles["font-family"]).toBe("Courier"); - }); - it("the color in the H1 Tag should be 'red'", function () { - document.querySelector( - "head" - ).innerHTML=``; - let h1Tag=document.querySelector("h1"); - let h1TagStyles=window.getComputedStyle(h1Tag); - // get computed styles of any element you like - expect(h1TagStyles["color"]).toBe("red"); - }); - it("the text-align in the H1 Tag should be 'center'", function () { - document.querySelector( - "head" - ).innerHTML=``; - let h1Tag=document.querySelector("h1"); - let h1TagStyles=window.getComputedStyle(h1Tag); - // get computed styles of any element you like - expect(h1TagStyles["text-align"]).toBe("center"); - }); - it("the text-decoration in the H2 Tag should be 'underline'", function () { - document.querySelector( - "head" - ).innerHTML=``; - // get computed styles of any element you like - const h2Tag=document.querySelector("h2"); - let h2TagStyles=window.getComputedStyle(h2Tag); - expect(h2TagStyles["text-decoration"]).toBe("underline"); - }); - it("the padding in the #id1 Tag should be '5px'", function () { - document.querySelector( - "head" - ).innerHTML=``; - // get computed styles of any element you like - const idTag=document.querySelector("#id1"); - let idTagStyles=window.getComputedStyle(idTag); - expect(idTagStyles["padding"]).toBe("5px"); - }); - it("the background-color in the #id1 Tag should be 'semi transparent white'", function () { - document.querySelector( - "head" - ).innerHTML=``; - // get computed styles of any element you like - const idTag=document.querySelector("#id1"); - let idTagStyles=window.getComputedStyle(idTag); - console.log("$$$:", idTagStyles) - expect(idTagStyles["background-color"]).toBe("rgba(255, 255, 255, 0.2)"); - }); - it("The a hover underline should be removed", function () { - document.querySelector( - "head" - ).innerHTML=``; - let cssArray=document.styleSheets[0].cssRules; - // console.log("$$$:", cssArray) - let orangeHoverSelector=""; - for (let i=0; i+ We are going to explain in this paragraph the 3 most common signs that you should look into yourself to recognize if you are learning. +
++ If you can't sleep, what's better than watching videos of cats? + click here +
+- We are going to explain in this pharagraph the 3 most comon signs that you should look into yourself to recognize if you are learning. + We are going to explain in this paragraph the 3 most common signs that you should look into yourself to recognize if you are learning.
If you can't sleep, what better than watching videos of cats? - click here + click here
Gender | ||
12 years | +12 | Male |
22 years | +22 | Female |
11 years | +11 | Male |
21 years | +21 | Male |
22 years | +22 | Female |
10 years | +10 | Male |
13 years | +13 | Female |
13 years | +13 | Male |
10 years | +10 | Male |
11 years | +11 | Male |
11 years | +11 | Male |
Here is some nice fake content