למד CSS כמו מקצוען

מדריך מקיף לכל מאפייני CSS, הערכים והאפשרויות

קטגוריות לימוד

📏

יחידות מידה

PX, REM, EM, %, VW, VH ועוד.

ללמוד עוד ←
📐

רוחב וגובה

Width, Height, Min ו-Max.

ללמוד עוד ←
↔️

Margin ו-Padding

רווחים פנימיים וחיצוניים.

ללמוד עוד ←
🔤

טיפוגרפיה

גופנים, גדלים, משקלים וטקסט.

ללמוד עוד ←
🎨

צבעים ושקיפות

HEX, RGB, HSL ו-Opacity.

ללמוד עוד ←
▢

גבולות וצללים

Border, Radius ו-Shadow.

ללמוד עוד ←
🧱

Display

Block, Inline, Flex ו-Grid.

ללמוד עוד ←
📍

Position

Static, Relative, Absolute ו-Fixed.

ללמוד עוד ←
↔️

Flexbox

סידור אלמנטים בצורה גמישה.

ללמוד עוד ←
▦

CSS Grid

בניית מערכות שורות ועמודות.

ללמוד עוד ←
🔄

Transform

סיבוב, הגדלה והזזה.

ללמוד עוד ←
✨

Animation

אנימציות ומעברים.

ללמוד עוד ←
🧮

פונקציות CSS

Calc, Clamp, Min ו-Max.

ללמוד עוד ←
🧩

Pseudo Classes

Hover, Focus, Before ו-After.

ללמוד עוד ←
📱

Responsive

התאמת האתר לכל המסכים.

ללמוד עוד ←
⚙️

משתנים ב-CSS

יצירה ושימוש במשתנים.

ללמוד עוד ←
🛠️

מאפיינים נוספים

Overflow, Cursor, Filter ועוד.

ללמוד עוד ←

יחידות מידה ב-CSS

יחידות מידה קובעות את הגדלים, המרווחים והמיקומים של אלמנטים.

יחידות מוחלטות

יחידה משמעות דוגמה
pxפיקסלים100px
cmסנטימטר5cm
mmמילימטר20mm
inאינץ'2in
ptנקודות12pt
pcפיקה2pc

יחידות יחסיות

יחידהמשמעות
%יחס לאלמנט המכיל
emיחס לגודל הגופן של האלמנט
remיחס לגודל הגופן של HTML
vwאחוז מרוחב חלון הדפדפן
vhאחוז מגובה חלון הדפדפן
svhגובה חלון קטן
dvhגובה חלון דינמי
vminהצד הקטן של החלון
vmaxהצד הגדול של החלון
chרוחב התו 0
exגובה האות x

דוגמת שימוש

.box {
    width: 50%;
    height: 100vh;
    padding: 2rem;
    font-size: 1.5rem;
}

Width ו-Height

שליטה ברוחב ובגובה של אלמנטים.

Width

width: auto;
width: 100px;
width: 200px;
width: 50%;
width: 100vw;
width: fit-content;
width: max-content;
width: min-content;

Height

height: auto;
height: 100px;
height: 300px;
height: 100%;
height: 100vh;

Min ו-Max

min-width: 100px;
max-width: 1200px;

min-height: 100px;
max-height: 800px;

Margin ו-Padding

Margin - רווח חיצוני

margin: 10px;
margin: 20px;

margin: 10px 20px;

margin-top: 10px;
margin-right: 20px;
margin-bottom: 30px;
margin-left: 40px;

margin: auto;

Padding - רווח פנימי

padding: 10px;
padding: 20px;

padding: 10px 20px;

padding-top: 10px;
padding-right: 20px;
padding-bottom: 30px;
padding-left: 40px;

טיפוגרפיה

Font Size

font-size: 10px;
font-size: 12px;
font-size: 16px;
font-size: 20px;
font-size: 24px;
font-size: 32px;
font-size: 48px;

font-size: 1rem;
font-size: 2em;
font-size: 150%;

font-size: small;
font-size: medium;
font-size: large;
font-size: x-large;

Font Weight

ערךמשמעות
100Thin
200Extra Light
300Light
400Normal
500Medium
600Semi Bold
700Bold
800Extra Bold
900Black

Text Align

text-align: left;
text-align: right;
text-align: center;
text-align: justify;
text-align: start;
text-align: end;

Text Decoration

text-decoration: none;
text-decoration: underline;
text-decoration: overline;
text-decoration: line-through;

Line Height

line-height: normal;
line-height: 1;
line-height: 1.5;
line-height: 2;
line-height: 24px;

צבעים ושקיפות

צבעים

color: red;
color: blue;
color: green;
color: black;
color: white;

color: #ffffff;
color: #000000;
color: #ff0000;

color: rgb(255, 0, 0);
color: rgba(255, 0, 0, 0.5);

color: hsl(120, 100%, 50%);
color: hsla(120, 100%, 50%, 0.5);

Opacity

הטווח הוא 0 עד 1.

opacity: 0;
opacity: 0.1;
opacity: 0.25;
opacity: 0.5;
opacity: 0.75;
opacity: 1;

גבולות וצללים

Border

border: 1px solid red;
border: 2px dashed blue;
border: 3px dotted green;
border: none;

border-width: 1px;
border-width: 2px;
border-width: 5px;

border-style: solid;
border-style: dashed;
border-style: dotted;
border-style: double;
border-style: groove;
border-style: ridge;

border-color: red;

Border Radius

border-radius: 0;
border-radius: 5px;
border-radius: 10px;
border-radius: 20px;
border-radius: 50%;
border-radius: 100px;

Box Shadow

box-shadow: 0 2px 5px black;

box-shadow:
0 5px 15px rgba(0,0,0,.3);

box-shadow:
0 10px 30px rgba(0,0,0,.5);

Text Shadow

text-shadow: 2px 2px 5px black;

Display

ערכי Display

display: block;
display: inline;
display: inline-block;

display: flex;
display: inline-flex;

display: grid;
display: inline-grid;

display: table;
display: none;
display: contents;

Position

סוגי Position

position: static;
position: relative;
position: absolute;
position: fixed;
position: sticky;

מיקום

top: 0;
right: 0;
bottom: 0;
left: 0;

inset: 10px;
inset: 10px 20px;

Z-Index

z-index: -1;
z-index: 0;
z-index: 1;
z-index: 10;
z-index: 100;
z-index: 9999;

Flexbox

Flex Direction

flex-direction: row;
flex-direction: row-reverse;
flex-direction: column;
flex-direction: column-reverse;

Justify Content

justify-content: flex-start;
justify-content: center;
justify-content: flex-end;
justify-content: space-between;
justify-content: space-around;
justify-content: space-evenly;

Align Items

align-items: flex-start;
align-items: center;
align-items: flex-end;
align-items: stretch;
align-items: baseline;

Flex Wrap

flex-wrap: nowrap;
flex-wrap: wrap;
flex-wrap: wrap-reverse;

Flex Properties

flex-grow: 0;
flex-grow: 1;

flex-shrink: 1;
flex-shrink: 0;

flex-basis: auto;
flex-basis: 200px;

gap: 10px;
row-gap: 20px;
column-gap: 15px;

CSS Grid

Grid Layout

display: grid;

grid-template-columns: 1fr 1fr;

grid-template-columns:
repeat(3, 1fr);

grid-template-columns:
200px 1fr;

grid-template-columns:
repeat(auto-fit, minmax(200px, 1fr));

grid-template-rows:
100px 200px;

gap: 10px;

row-gap: 20px;

column-gap: 15px;

Grid Position

grid-column: span 2;
grid-row: span 2;

grid-column: 1 / 3;
grid-row: 1 / 3;

Transform

Scale

transform: scale(1);
transform: scale(1.5);
transform: scaleX(2);
transform: scaleY(2);

Rotate

transform: rotate(45deg);
transform: rotateX(45deg);
transform: rotateY(45deg);

Translate

transform: translateX(100px);
transform: translateY(50px);
transform: translate(20px, 30px);

Skew

transform: skew(10deg);
transform: skewX(10deg);
transform: skewY(10deg);

Animation ו-Transition

Transition

transition: all 0.3s ease;

transition-duration: 1s;

transition-delay: 0.5s;

transition-timing-function: linear;
transition-timing-function: ease;
transition-timing-function: ease-in;
transition-timing-function: ease-out;
transition-timing-function: ease-in-out;

Animation

animation-name: move;
animation-duration: 2s;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-fill-mode: forwards;
animation-timing-function: linear;

Keyframes

@keyframes move {

    0% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(100px);
    }

    100% {
        transform: translateX(0);
    }

}

פונקציות CSS

Calc

width: calc(100% - 50px);
height: calc(100vh - 100px);

Min

width: min(100%, 1200px);

Max

width: max(50%, 400px);

Clamp

font-size: clamp(16px, 3vw, 32px);

Linear Gradient

background:
linear-gradient(red, blue);

background:
linear-gradient(90deg, red, blue);

Radial Gradient

background:
radial-gradient(circle, red, blue);

Filter

filter: blur(5px);
filter: brightness(1.2);
filter: grayscale(100%);
filter: contrast(150%);
filter: saturate(200%);

Pseudo Classes ו-Elements

Pseudo Classes

a:hover {}

a:active {}

a:visited {}

input:focus {}

input:checked {}

input:disabled {}

input:enabled {}

li:first-child {}

li:last-child {}

li:nth-child(2) {}

li:nth-child(odd) {}

li:nth-child(even) {}

:not(.active) {}

:root {}

Pseudo Elements

p::before {
    content: "★";
}

p::after {
    content: "!";
}

p::first-letter {}

p::first-line {}

::selection {}

::placeholder {}

Responsive Design

Media Queries

/* Mobile */

@media (max-width: 600px) {

    .container {
        width: 100%;
    }

}

/* Tablet */

@media (min-width: 601px)
and (max-width: 900px) {

    .container {
        width: 90%;
    }

}

/* Desktop */

@media (min-width: 901px) {

    .container {
        width: 80%;
    }

}

גדלי מסכים נפוצים

מכשיררוחב לדוגמה
טלפון קטןעד 480px
טלפוןעד 600px
טאבלט600px–900px
מחשב900px ומעלה
מסך רחב1200px ומעלה

משתנים ב-CSS

יצירת משתנים

:root {

    --primary: #648cff;

    --secondary: #a16cff;

    --spacing: 20px;

    --radius: 10px;

}

.box {

    color: var(--primary);

    padding: var(--spacing);

    border-radius: var(--radius);

}

מאפיינים נוספים

Overflow

overflow: visible;
overflow: hidden;
overflow: scroll;
overflow: auto;

overflow-x: hidden;
overflow-y: auto;

Cursor

cursor: auto;
cursor: default;
cursor: pointer;
cursor: wait;
cursor: move;
cursor: not-allowed;
cursor: grab;
cursor: zoom-in;

Object Fit

object-fit: fill;
object-fit: contain;
object-fit: cover;
object-fit: none;
object-fit: scale-down;

Visibility

visibility: visible;
visibility: hidden;
visibility: collapse;

White Space

white-space: normal;
white-space: nowrap;
white-space: pre;
white-space: pre-wrap;
white-space: pre-line;

List Style

list-style: none;
list-style: disc;
list-style: circle;
list-style: square;
list-style: decimal;

Box Sizing

box-sizing: content-box;
box-sizing: border-box;

Pointer Events

pointer-events: auto;
pointer-events: none;

User Select

user-select: auto;
user-select: none;
user-select: text;
user-select: all;
Hosted & Compiled with HtmlRunner.com