בורר אחים סמוך
חלק מהיחידה שליטה ב-CSS במסלול ה-HTML של Coddy. שיעור 4 מתוך 43.
בורר האחים הסמוכים (+) משמש לעיצוב של רכיב שמופיע מיד אחרי רכיב מסוים. לשניהם חייב להיות אותו הורה, ו״סמוכים״ פירושו ״מופיעים מיד זה לצד זה״.
לדוגמה:
<h2>Heading</h2>
<p>This paragraph is styled</p>עם CSS זה:
h2 + p {
font-weight: bold;
}הפסקה מעוצבת משום שהיא מופיעה ישירות אחרי רכיב h2.
אתגר
קלצרו בורר CSS שמכוון רק לפסקאות (<p>) שמופיעות מיד אחרי רכיב <h2> שמתאר משחק כדורסל. עצבו את הפסקאות האלה עם צבע גופן כחול וגודל גופן של 18px.
נסו בעצמכם
<html>
<head>
<title>Adjacent Sibling Selector</title>
<style>
/* CSS solution goes here */
</style>
</head>
<body>
<h2>Basketball Game Overview</h2>
<p>The basketball game was an exciting match between the **Los Angeles Lakers** and the **Golden State Warriors**, featuring intense offense and solid defense from both teams.</p>
<p>During the first half, the Lakers held a slight lead, with LeBron James making key plays, while Stephen Curry of the Warriors kept the game tight with impressive three-pointers.</p>
<p>This paragraph is not directly after an h2, so it should not be affected.</p>
<p>In the second half, the Warriors fought back, with Klay Thompson hitting critical shots, but the Lakers secured their win with solid defense and a game-winning dunk by Anthony Davis.</p>
</body>
</html>
השיעור הזה כולל חידון קצר. התחילו את השיעור כדי לענות עליו ולעקוב אחרי ההתקדמות.
כל השיעורים ביחידה שליטה ב-CSS
תרגלו בעצמכם: Web אונליין