Skip to content

Instantly share code, notes, and snippets.

View helabenkhalfallah's full-sized avatar
🎯
Focusing

Héla Ben Khalfallah helabenkhalfallah

🎯
Focusing
View GitHub Profile
.card-container {
container-type: inline-size;
}
.card {
display: flex;
flex-direction: row;
gap: 1rem;
border: 1px solid #ccc;
padding: 1rem;
@helabenkhalfallah
helabenkhalfallah / ContainerExamples.css
Last active March 24, 2024 10:07
Container Examples
@container (max-width: 500px) {
/* Normal css styles can go here */
}
@container (min-width: 500px) {
/* Normal css styles can go here */
}
@container (width > 500px) {
/* Normal css styles can go here */
}
@container (width >= 500px) {
.hero-image {
height: 100dvh; /* Height will adapt to the address bar's appearance */
}
.sticky-footer {
height: 100svh; /* Remains visible and consistent */
}
.fullscreen-gallery {
height: 100lvh; /* Utilizes the entire screen, no UI */
@helabenkhalfallah
helabenkhalfallah / hasSelector.css
Created March 24, 2024 12:48
CSS has Selector
// Syntax: <target>:has(<condition>) { <styles> }
/* Select the .card element when it
contains a <figure> immediately
followed by a paragraph. */
.card:has(figure + p) {
flex-direction: row;
}
/* Selects an h1 heading with a
/* Select the 2nd child. */
:nth-child(2)
/* Select all even children (2nd, 4th, 6th, 8th, and so on). */
:nth-child(2n)
/* Select all odd children (1st, 3rd, 5th, 7th, and so on). */
:nth-child(2n+1)
/* Select the 1st (=(5×0)+1), 6th (=(5×1)+1), 11th (=(5×2)+1), … child. */
<!-- CustomButton.svelte -->
<button on:click> Click me </button>
<style>
button {
height: 4rem;
width: 8rem;
background-color: #aaa;
border-color: #f1c40f;
@helabenkhalfallah
helabenkhalfallah / LifeCycle.svelte
Created April 10, 2024 18:56
Svelte Life Cycle
<script>
import { afterUpdate, beforeUpdate, onDestroy, onMount, tick } from 'svelte';
onMount(() => {
console.log('the component has mounted');
});
beforeUpdate(() => {
console.log('the component is about to update');
});
@helabenkhalfallah
helabenkhalfallah / SvelteProject.txt
Last active April 10, 2024 19:47
Svelte Project Basic Structure
// https://codesandbox.io/p/sandbox/mystifying-goldberg-7n73cn?file=%2Fpublic%2Findex.html%3A7%2C28
awesome-project/
├── src/
│ ├── components/
│ │ ├── Button.svelte
│ │ └── Header.svelte
│ ├── routes/
│ │ ├── Home.svelte
│ │ └── About.svelte
│ ├── App.svelte
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8" />
<meta name="viewport" content="width=device-width" />
<title>Svelte app</title>
<link rel="stylesheet" href="public/bundle.css" />
</head>
@helabenkhalfallah
helabenkhalfallah / index.js
Last active April 10, 2024 19:45
Svelte Index File
import App from "./App.svelte";
const app = new App({
target: document.body
});
export default app;