# CSS - Sass handwritten [sass.pdf](../../_resources/sass.pdf) [sass.pdf](../../_resources/sass%201.pdf) - nth-child pseudoclass To select the list for specific number. For eg: ```html ``` ```css ul li:nth-child(2){ color: red; } ``` instead of 2, odd or even can be used too. Output: ![Untitled](../../_resources/Untitled-5.png) also formula can be used like ```css ul li:nth-child(4n+0){ color: red; } ``` all multiples of 4 is selected - Caution while using flex When using flex layout, for eg to adjust div at center both horizontally and vertically. When we decrease height then upper portion gets out of screen too. To avoid this: set margin as auto for that div. ```css html, body, #root, .App { height: 100%; width: 100%; } .App { font-family: "Poppins", sans-serif; display: flex; align-items: center; justify-content: center; } .calcBox { margin: auto; display: grid; grid-template-columns: repeat(3, 1fr); width: 350px; grid-gap: 1rem; padding: 1rem; background-color: #696969; border: 2px solid black; border-radius: 2px; } ``` ```html
``` - Some important snippets minmax application: ```scss /* Use of minmax */ .List { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(200px, 3fr) minmax( 150px, 2fr ) minmax(100px, 1fr) minmax(100px, 1fr) minmax(200px, 3fr); } ``` - For inputButton properly implemented: ```html
``` ```css :root { --deeppink: rgb(255, 0, 104); --deeppinkDark: rgb(230, 0, 94); } .Playlist { margin-top: 5rem; display: flex; justify-content: center; width: 100%; } .Playlist .playlistInput { width: 50%; min-width: 300px; border: 4px solid var(--deeppink); border-radius: 3px; overflow-y: hidden; /* padding: 0.5rem; */ } .playlistInput input { width: 80%; /* height: 100%; */ height: 2rem; border: none; outline: none; padding: 0; } .playlistInput button { width: 20%; height: 3rem; background-color: var(--deeppink); color: white; border: none; /* box-sizing: border-box; */ cursor: pointer; transition: all 0.1s ease-in-out; } .playlistInput button:hover { background-color: var(--deeppinkDark); } ``` - Spinner ```jsx import "./Spinner.css"; // use 'npm i react-loader-spinner@4.0.0 import Loader from "react-loader-spinner"; // expected props: // visible: boolean , // classes: string, // color: string, // text: string // https://mhnpd.github.io/react-loader-spinner/docs/category/components/ /* text : Radio,Audio,Ball Triangle,Bars,Blocks,Circles With Bar,Circles,Color Ring,Comment,Discuss, DNA,Falling Lines,Fidget Spinner,Grid,Hearts,Hourglass, Infinity Spin,LineWave,MagnifyingGlass,Mutating Dots,Oval,Progress Bar,Puff, RevolvingDot,Rings,Rotating Lines,Rotating Square, Rotating Triangles,Tail Spin,Three Circles,Three Dots,Triangle, Vortex , Watch*/ function Spinner(props) { const { visible, text, type } = props; let classes = props.classes || ""; const color = props.color || "#fff"; let color1 = props.color; // console.log("is spinner visible: ", visible); return (
{text}
); } export default Spinner; ``` ```css .none { display: none; } .Spinner .Loading_Text { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } ``` other way ```js import "./Spinner.scss"; function Spinner(props) { const { visible, text, type } = props; let classes = props.classes || ""; const color = props.color || "#fff"; let color1 = props.color; // console.log("is spinner visible: ", visible); return ( //
{text}
); } export default Spinner; ``` Spinner.scss ```scss .none { display: none; } .spinner .Loading_Text { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .spinner { border: 8px solid #f3f3f3; border-top: 8px solid #000000; border-radius: 50%; width: 50px; height: 50px; animation: spin 1s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .spinnerStyle { display: "flex"; justify-content: "center"; align-items: "center"; } ``` - Creating pill shaped button ```css .proceed { margin-top: 1rem; color: white; background-color: black; border: none; border-radius: 9999px; padding: 1rem 0.5rem } ``` set border radius as very long size Output: ![Untitled](../../_resources/Untitled%201-2.png) - scroll to specific position with anchor tag - aspect-ratio ![Untitled](../../_resources/Untitled%202-2.png) - whitespace property ![Untitled](../../_resources/Untitled%203-1.png) - calc() ## CSS only Approach (If height is known/fixed) When you want the middle element to span across entire page vertically, you can use `[calc()](https://developer.mozilla.org/en-US/docs/Web/CSS/calc)` which is introduced in CSS3. Assuming we have a *fixed height* `header` and `footer` elements and we want the `section` tag to take entire available vertical height... **[Demo](http://jsfiddle.net/WdrDH/)** **Assumed markup** and your CSS should be ```css html, body { height: 100%; } header { height: 100px; background: grey; } section { height: calc(100% - (100px + 150px)); /* Adding 100px of header and 150px of footer */ background: tomato; } footer { height: 150px; background-color: blue; } ``` ```html
100px
Expand me for remaining space
``` - centralising div ![Untitled](../../_resources/Untitled%204-1.png) Ref: [https://www.youtube.com/watch?v=HOM47v73yG8&list=PLBOEc6PNYgCQZl3gDUDtv034yz-kwWkFo&index=3&t=200s](https://www.youtube.com/watch?v=HOM47v73yG8&list=PLBOEc6PNYgCQZl3gDUDtv034yz-kwWkFo&index=3&t=200s) [https://www.youtube.com/watch?v=HOM47v73yG8&list=PLBOEc6PNYgCQZl3gDUDtv034yz-kwWkFo&index=3&t=200s](https://www.youtube.com/watch?v=HOM47v73yG8&list=PLBOEc6PNYgCQZl3gDUDtv034yz-kwWkFo&index=3&t=200s) when using this method to centralize div, when we decrease screen height then div can go out of screen. To prevent this, use position absolute and - For setting dark theme We need to invert all colors of the page. ```html
hello