בונים ביחד תבנית וורדפרס – פרק 5

ברוכים הבאים לחלק החמישי במדריך "בונים ביחד תבנית וורדפרס". החלק זה נכין את התשתית העיצובית לאתר שלנו. חשוב לקרוא את הפרקים הקודמים לחלק זה כיוון שאנו נסמכים עליהם בחלק זה של המדריך.

  • אהבתם? שתפו!

ניווט מהיר בין הפרקים:

מכינים תשתית עיצובית לתבנית וורדפרס שלנו

דפדפנים

חלק זה של המדריך הוא חלק קצר ונקודתי ובו נבנה הגדרות CSS בסיסיות בקובץ reset.css. אם אין לכם מושג על איזה קובץ אני מדבר סימן שדילגתם ישירות לפרק זה ועליכם לחזור אחורה ולקרוא את המדריך מההתחלה שלו.

השאיפה היא כמובן ליצור אתר אשר מותאם לכל הדפדפנים ולמרות שנצטרך לעשות התאמות לאינטרנט אקספלורר (אם אתם בונים אתרים אתם וודאי מודעים לכאב ראש אינטרנט אקספלורר יוצר) ואולי גם לכרום אך אנחנו ננסה לצמצם בעזרת reset.css את כמות ההתאמות שנצטרך לעשות עבור תצוגה דומה בכל הדפדפנים.

יש לכם קובץ reset.css שאתם אוהבים להשתמש בו? הוסיפו קישור אליו בתגובה ועזרו לכולנו לחסוך זמן ומאמץ.

בהמשך המדריך תקבלו קוד CSS שתוכלו להטמיע בעצמכם או להוריד את הקובץ קומפלט ולשלב אותו בתבנית החדשה שלכם.

נפתח את הקובץ reset.css

בתוך התיקייה css ↓
reset.css קובץ אשר יחיל הגדרות CSS בסיסיות ברחבי האתר

מה זה בכלל reset.css ולמה אנחנו משתמשים בו?

הסיבה שאנו מתחילים את העריכה של קבצים בתבנית החדשה שאנו בונים עם הקובץ reset.css היא שקיימים אינספור דפדפנים וכל אחד מהם מתייחס אחר לאלמנטים בסיסיים כמו תג הhtml ותגים אחרים בקוד של האתר שלנו.

הקובץ reset.css נועד כדי לצמצם או ליתר דיוק לאפס (ומכאן שם הקובץ Reset) את ההבדלים בין הדפדפנים השונים כך שנוכל להתחיל "נקי" ולצמצם הגדרות CSS (הגדרות עיצוביות) עבור דפדפן אחד ספציפי. אחרי הכל אתם בוודאי רוצים שהאתר יראה אותו הדבר או לפחות מאוד דומה בכל הדפדפנים השונים כגון פיירפוקס, אינטרנט אקספלורר, כרום וכו'.

 

קבצי reset.css פופולאריים מוכנים!

הנה כמה קבצי reset.css מוכנים להורדה באדיבות יוצרים שונים ברחבי העולם.

אנחנו נעשה שילוב של הקוד בקובץ normalize.css (הקישור האחרון ברשימה) עם קוד CSS משלנו אשר יעזור לנו לחסוך זמן ומאמץ בעת בניית התבנית בעזרת פקודות CSS מקוצרות ונפוצות… זה עלול לשקול 10kb יותר אבל זה בהחלט הבדל לא משמעותי לעומת חסכון הזמן וקלות השימוש.

 

מספיק תיאוריה ליום אחד, ניגשים לתכלס

נפתח את הקובץ reset.css אשר נמצא בתיקייה css שיצרנו בפרק הקודם. ונכניס בו את הקוד הבא (אשר אסביר בהמשך הדף). קוד זה הוא שילוב של normalize.css וקוד css אשר יצרתי עבור פרויקטים ומקצר את בזבוז הזמן וכתיבת פקודות חוזרות על עצמן במהלך בניית התבנית.

או ש… תוכלו להוריד את הקובץ reset.css ולהחליף אותו בקובץ הקיים קובץ reset.css להורדה

לחצו כאן לקוד המלא של reset.css +
	/******************************************************
	** HTML5 display definitions  (normalize.css v2.0.1)
	******************************************************/
	article, aside, details, figcaption, figure, footer, header, hgroup, nav, section, summary { display: block; }

	/* Correct `inline-block` in IE 8/9 */
	audio,canvas,video { display: inline-block; }

	/* displaying `audio` wit controls. */
	audio:not([controls]) { display: none; height: 0; }

	/* Address styling not present in IE 8/9 */
	[hidden] { display: none; }

	/*************************************
	** BASE
	*************************************/

	/* Set font family: sans-serif & fix user zoom */
	html {
		font-family: sans-serif; /* 1 */
		-webkit-text-size-adjust: 100%; /* 2 */
		-ms-text-size-adjust: 100%; /* 2 */
	}

	/* Remove default margin. */
	body { margin: 0; }

	/* Links */
	a:focus { outline: thin dotted; }
	a:active,a:hover { outline: 0;}

	/* Typography */
	h1 {  font-size: 2em; }
	abbr[title] { border-bottom: 1px dotted; }
	b,strong { font-weight: bold; }
	dfn { font-style: italic; }
	mark { background: #ff0; color: #000; }
	code,kbd,pre,samp { font-family: monospace, serif; font-size: 1em; }
	pre { white-space: pre; white-space: pre-wrap; word-wrap: break-word; }
	q { quotes: "201C" "201D" "2018" "2019"; }
	small { font-size: 80%; }
	sub,sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
	sup { top: -0.5em; }
	sub { bottom: -0.25em; }

	/* Embedded content */
	img { border: 0; }
	svg:not(:root) { overflow: hidden; }

	/* Figures */
	figure { margin: 0; }

	/* Forms */
	fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; }
	legend { border: 0; /* 1 */ padding: 0; /* 2 */ }
	button, input, select, textarea { 
		font-family: inherit; /* 1 */
		font-size: 100%; /* 2 */
		margin: 0; /* 3 */
	}

	button,input { line-height: normal; }
	button,
	html input[type="button"], /* 1 */
	input[type="reset"],
	input[type="submit"] {
		-webkit-appearance: button; /* 2 */
		cursor: pointer; /* 3 */
	}

	button[disabled],html input[disabled] { cursor: default; }

	/**
	* 1. Address box sizing set to `content-box` in IE 8/9.
	* 2. Remove excess padding in IE 8/9.
	*/

	input[type="checkbox"], input[type="radio"] { box-sizing: border-box; padding: 0; }
	input[type="search"] { -webkit-appearance: textfield;  -moz-box-sizing: content-box; -webkit-box-sizing: content-box; box-sizing: content-box; }
	input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
	button::-moz-focus-inner,input::-moz-focus-inner { border: 0; padding: 0; }
	textarea { overflow: auto; vertical-align: top;}

	/* tables */
	table { border-collapse: collapse; border-spacing: 0; }



	/******************************************************
	** SAGIVE SEO EASY CSS ADDONS
	******************************************************/


	/*****************************************
	** POSITION
	*****************************************/
	.fleft {float: left;}
	.fright {float: right;}
	.ltr {direction: ltr;}
	.rtl {direction: rtl;}
	.fix {clear: both;}


	/*****************************************
	** EASY TEXT
	*****************************************/
	.center {text-align: center !important;}
	.tleft {text-align: left !important;}
	.tright {text-align: right !important;}
	.top {vertical-align: top !important;}
	.middle {vertical-align: middle !important;}
	.bottom {vertical-align: bottom !important;}
	.bold {font-weight: bold;}
	.italic {font-style: italic;}
	.underline {text-decoration: underline;}
	.capital {text-transform: uppercase;}

	/*****************************************
	** FONT SIZE
	*****************************************/
	.fs9 {font-size: 9px !important;}
	.fs10 {font-size: 10px !important;}
	.fs11 {font-size: 11px !important;}
	.fs12 {font-size: 12px !important;}
	.fs13 {font-size: 13px !important;}
	.fs14 {font-size: 14px !important;}
	.fs15 {font-size: 15px !important;}
	.fs16 {font-size: 16px !important;}
	.fs17 {font-size: 17px !important;}
	.fs18 {font-size: 18px !important;}
	.fs19 {font-size: 19px !important;}
	.fs20 {font-size: 20px !important;}
	.fs21 {font-size: 21px !important;}
	.fs22 {font-size: 22px !important;}
	.fs24 {font-size: 24px !important;}
	.fs26 {font-size: 26px !important;}
	.fs28 {font-size: 28px !important;}
	.fs30 {font-size: 30px !important;}
	.fs32 {font-size: 32px !important;}


	/*****************************************
	** EASY PADDING
	*****************************************/
	.p0 {padding: 0% !important;}
	.p1 {padding: 1% !important;}
	.p2 {padding: 2% !important;}
	.p3 {padding: 3% !important;}
	.p4 {padding: 4% !important;}
	.p5 {padding: 5% !important;}
	.p6 {padding: 6% !important;}
	.p7 {padding: 7% !important;}
	.p8 {padding: 8% !important;}
	.p9 {padding: 9% !important;}
	.p10 {padding: 10% !important;}

	.pr0 {padding-right: 0% !important;}
	.pr1 {padding-right: 1% !important;}
	.pr2 {padding-right: 2% !important;}
	.pr3 {padding-right: 3% !important;}
	.pr4 {padding-right: 4% !important;}
	.pr5 {padding-right: 5% !important;}
	.pr10 {padding-right: 10% !important;}

	.pl1 {padding-left: 0% !important;}
	.pl1 {padding-left: 1% !important;}
	.pl2 {padding-left: 2% !important;}
	.pl3 {padding-left: 3% !important;}
	.pl4 {padding-left: 4% !important;}
	.pl5 {padding-left: 5% !important;}
	.pl10 {padding-left: 10% !important;}

	.pt1 {padding-top: 1% !important;}
	.pt2 {padding-top: 2% !important;}
	.pt3 {padding-top: 3% !important;}
	.pt5 {padding-top: 5% !important;}
	.pt6 {padding-top: 6% !important;}
	.pt7 {padding-top: 7% !important;}
	.pt8 {padding-top: 8% !important;}
	.pt9 {padding-top: 9% !important;}
	.pt10 {padding-top: 10% !important;}

	.pb1 {padding-bottom: 1% !important;}
	.pb2 {padding-bottom: 2% !important;}
	.pb3 {padding-bottom: 3% !important;}
	.pb5 {padding-bottom: 5% !important;}
	.pb10 {padding-bottom: 10% !important;}

	/*****************************************
	** EASY MARGIN
	*****************************************/
	.m0 {margin: 0 !important;}
	.m1 {margin: 1% !important;}
	.m2 {margin: 2% !important;}
	.m3 {margin: 3% !important;}
	.m4 {margin: 4% !important;}
	.m5 {margin: 5% !important;}

	.mt0 {margin-top: 0 !important;}
	.mt1 {margin-top: 1% !important;}
	.mt2 {margin-top: 2% !important;}
	.mt3 {margin-top: 3% !important;}
	.mt4 {margin-top: 4% !important;}
	.mt5 {margin-top: 5% !important;}
	.mt10 {margin-top: 10% !important;}

	.ml0 {margin-left: 0 !important;}
	.ml1 {margin-left: 1% !important;}
	.ml2 {margin-left: 2% !important;}
	.ml3 {margin-left: 3% !important;}
	.ml4 {margin-left: 4% !important;}
	.ml5 {margin-left: 5% !important;}
	.ml10 {margin-left: 10% !important;}

	.mr0 {margin-right: 0 !important;}
	.mr1 {margin-right: 1% !important;}
	.mr2 {margin-right: 2% !important;}
	.mr3 {margin-right: 3% !important;}
	.mr4 {margin-right: 4% !important;}
	.mr5 {margin-right: 5% !important;}
	.mr10 {margin-right: 10% !important;}

	.mb0 {margin-bottom: 0 !important;}
	.mb1 {margin-bottom: 1% !important;}
	.mb2 {margin-bottom: 2% !important;}
	.mb3 {margin-bottom: 3% !important;}
	.mb5 {margin-bottom: 5% !important;}
	.mb10 {margin-bottom: 10% !important;}


	/*****************************************
	** LINE HEIGHT
	*****************************************/
	.lh14 {line-height: 14px !important;}
	.lh16 {line-height: 16px !important;}
	.lh18 {line-height: 18px !important;}
	.lh20 {line-height: 20px !important;}
	.lh22 {line-height: 22px !important;}
	.lh24 {line-height: 24px !important;}
	.lh26 {line-height: 26px !important;}
	.lh28 {line-height: 28px !important;}
	.lh30 {line-height: 30px !important;}
	.lh32 {line-height: 32px !important;}
	.lh34 {line-height: 34px !important;}
	.lh36 {line-height: 36px !important;}
	.lh38 {line-height: 38px !important;}
	.lh40 {line-height: 40px !important;}


	/*****************************************
	** PERCENTAGE WIDTH
	*****************************************/
	.w3 {width: 3% !important;}
	.w4 {width: 4% !important;}
	.w5 {width: 5% !important;}
	.w7 {width: 7% !important;}
	.w10 {width: 10% !important;}
	.w12 {width: 12% !important;}
	.w15 {width: 15% !important;}
	.w18 {width: 18% !important;}
	.w20 {width: 20% !important;}
	.w22 {width: 22% !important;}
	.w24 {width: 24% !important;}
	.w25 {width: 25% !important;}
	.w28 {width: 28% !important;}
	.w30 {width: 30% !important;}
	.w31 {width: 31% !important;}
	.w32 {width: 32% !important;}
	.w35 {width: 35% !important;}
	.w40 {width: 40% !important;}
	.w41 {width: 41% !important;}
	.w45 {width: 45% !important;}
	.w46 {width: 46% !important;}
	.w47 {width: 47% !important;}
	.w48 {width: 48% !important;}
	.w49 {width: 49% !important;}
	.w50 {width: 50% !important;}
	.w55 {width: 55% !important;}
	.w60 {width: 60% !important;}
	.w70 {width: 70% !important;}
	.w75 {width: 75% !important;}
	.w80 {width: 80% !important;}
	.w85 {width: 85% !important;}
	.w90 {width: 90% !important;}
	.w95 {width: 95% !important;}
	.w96 {width: 96% !important;}
	.w97 {width: 97% !important;}
	.w100 {width: 100% !important;}
	

ועל זה נאמר – וואו!

הסבר על reset.css +

אז למה אנחנו צריכים reset.css?

ישנן הרבה סיבות טובות להכין קובץ reset.css ובמיוחד קובץ כמו שהכנו… הנה כמה מהן

  • קוד הCSS הנ"ל עוזר לצמצם את ההבדלים בין הדפדפנים השונים
  • קוד הCSS הנ"ל עוזר לצמצם את ההבדלים בין גרסאות דפדפנים שונים
  • הוספנו המון קיצורי CSS שיעזרנו לנו לחסוך בשורות קוד
  • ריכזנו את כל קיצורי הCSS אל מקום אחד שקל לערוך ולנהל
  • קובץ זה מקל עלינו בעת כתיבת התבנית כי להתייחס לפקודות CSS קצרות.

מוכנים לעבודה – אל הפרק הבא!

סיימנו להכין את תשתית הCSS לתבנית הוורדפרס שלנו (נכון שזה היה קל?). בפרק הבא נתחיל בעיצוב הקובץ הראשי שלנו על פי קובץ הPSD אשר הצגתי בפרק ברוכים הבאים ועוד. ושם מתחילים להגביר את הקצב. היום יום שבת ומחר מתחיל שבוע עבודה חדש ועמוס. הירשמו אל רשימת התפוצה שלנו כך שתקבלו הודעה בעת פרסומו של החלק הבא במדריך! פרגנו עם LIKE אם אהבתם. נתראה בקרוב…

בברכה, שגיב SEO
  • אהבתם? שתפו!