چگونه میتوان طراحی وبسایتهای واکنشگرا و سازگار با موبایل را بدون نوشتن کدهای CSS پیچیده انجام داد؟
آیا فریم ورکهایی وجود دارند که کلاسهای آماده CSS را برای توسعهدهندگان وب ارائه کنند؟
بوتاسترپ چه کلاسها و اجزای آمادهای برای طراحی بخشهای مختلف صفحات وب دارد؟
چگونه میتوان با بوتاسترپ، فرمهای ورود اطلاعات را با سرعت بالا و به شکل مدرن طراحی کرد؟
چگونه میتوان طراحی صفحات وب را با استفاده از بوتاسترپ بهینه کرد تا در تمام دستگاهها به بهترین نحو نمایش داده شوند؟
در پایان از هنرجو انتظار میرود
طراحی کامل ساختار یک صفحه وب (شامل هدر، بدنه و فوتر) با استفاده از سیستم شبکهبندی (Grid System) بوتاسترپ، بهطوریکه طرحبندی در اندازههای مختلف صفحه نمایش (موبایل، تبلت، دسکتاپ) بهدرستی واکنش نشان دهد.
انتخاب و بهکارگیری کلاسهای کمکی (Utility Classes) مانند کلاسهای رنگ، فاصله (Margin/Padding)، سایهها و تایپوگرافی برای استایلدهی سریع و استاندارد به عناصر بدون نیاز به نوشتن CSS دستی برای موارد متداول.
ساخت یک نوار ناوبری (Navbar) کاربردی و زیبا که شامل لینکها، دکمهها و قابلیتهای واکنشگرا باشد و همچنین طراحی یک فوتر ساختاریافته.
مهارت در پیادهسازی اجزای رابط کاربری مانند کروسل (تصاویر اسلایدی) و آکاردئونها برای ارائه اطلاعات به شیوهای جذاب و پویا.
ساخت فرمهای ثبتنام یا تماس با استایلدهی کامل بوتاسترپ.
تغییر و لغو استایلهای پیشفرض بوتاسترپ با استفاده از روشهای سفارشیسازی برای هماهنگ کردن ظاهر وبسایت با برند یا نیازهای خاص پروژه.
استاندارد عملکرد
کلاسهای آماده بوتاسترپ را برای تعیین سبک عناصر مختلف صفحه مانند دکمهها، فرمها و منوها و ... به کار ببرد و توانایی طراحی واکنشگرای صفحه را در دستگاههای مختلف داشته باشد.
صفحه ۱۴۷
تعریف فریم ورک
فریمورک (Framework) یک چارچوب نرمافزاری از پیش طراحیشده است که به منظور سرعت بخشیدن به فرایند طراحی و توسعه وبسایتها و اپلیکیشنهای وب بهکار میرود. یک فریم ورک با ارائۀ مجموعهای از ابزارها، کتابخانهها و الگوهای آماده، به توسعهدهندگان امکان میدهد که تنها روی ویژگیها و عملکردهای خاص پروژه تمرکز کنند و از کارهای تکراری و ابتدایی دوری کنند.
Bootstrap چیست؟
بوتاسترپ یک فریمورک متن باز برای طراحی ظاهر سایت است که شامل مجموعهای از کدهای آماده نوشتهشده با زبانهای Css، Html و Java Script است. توسعهدهندگان بهجای اینکه از صفر همه چیز را بنویسند از این کدهای آماده استفاده میکنند.
ویژگیهای Bootstrap: بوتاسترپ دارای ویژگیهای متعددی در زمینه طراحی صفحات وب است که باعث محبوبیت آن در میان توسعهدهندگان و طراحان وب شده است. این ویژگیها به شرح زیر است:
طراحی واکنشگرا (Responsive Design): بوتاسترپ دارای یک سیستم گرید 12 ستونی است که امکان طراحی واکنشگرا را برای دستگاههای مختلف فراهم میکند.
اجزای از پیش طراحیشده (Components): بوتاسترپ شامل اجزای مختلفی مانند دکمهها، فرمها، منوی ناوبری، کاردها، مدالها و نوار جستوجو است که بهصورت آماده قابل استفاده هستند.
پشتیبانی از جاوااسکریپت: بوتاسترپ حاوی کتابخانههای جاوااسکریپت برای ایجاد تعاملات و انیمیشنها در بخشهای مختلف صفحه است.
پشتیبانی از مرورگرها: بوتاسترپ با اکثر مرورگرهای مدرن مانند Chrome، Firefox، Safari و Edge سازگار است.
مستندات جامع: سایت رسمی بوتاسترپ (getbootstrap.com) دارای مستندات کامل برای آموزش نحوۀ استفاده از اجزا و کلاسهای بوتاسترپ است.
کاربردهای Bootstrap
طراحی وبسایتهای واکنشگرا: طراحی و توسعه وبسایتهای شرکتی، فروشگاهی، وبلاگها و غیره.
ایجاد رابطهای کاربری جذاب: طراحی رابطهای کاربری زیبا و مدرن برای وبسایتها و اپلیکیشنهای وب.
پروژههای MVP (minimum viable product): ساخت نمونههای اولیه وبسایتها (MVP) و ارزیابی ایدههای طراحی.
طراحی فرمها: طراحی فرمهای زیبا و واکنشگرا توسط کلاسهای آماده بوتاسترپ.
صفحه ۱۴۸
بهکارگیری بوتاسترپ در صفحه وب
برای استفاده از امکانات بوتاسترپ در یک صفحه وب، ابتدا باید فایل HTML پایه ایجاد شود و سپس فایلهای CSS و جاوااسکریپت بوتاسترپ به آن الحاق شود. فایل پایه شامل برچسبهای <!DOCTYPE html>، <html>، <head>، متاتگهای viewport، <title> و <body> است.
کلاسها و کامپوننتهای بوتاسترپ
کلاسهای بوتاسترپ مجموعهای از استایلهای از پیش تعریف شده هستند که امکان طراحی سریع و راحت اجزای رابط کاربری صفحات وب را فراهم میکنند. این کلاسها که با استفاده از CSS ایجاد شدهاند، به توسعهدهنده وب کمک میکنند که با نوشتن کدهای CSS کمتر، عناصری کاربرپسند و واکنشگرا را به صفحه وب اضافه کند.
صفحه ۱۴۹
کامپوننتهای بوتاسترپ عناصر از پیش طراحی شدهای هستند که امکان طراحی سریع و آسان رابط کاربری وبسایتها را فراهم میکنند. توسعهدهندۀ وب میتواند به کمک این عناصر آماده، بدون نوشتن کدهای CSS و JavaScript، عناصر کاربرپسند و واکنشگرا را به صفحه وب اضافه کند. از جمله کامپوننتهای بوتاسترپ میتوان به دکمه، نوار ناوبری¹، کروسل²، آکاردئون³ و مُدال⁴ اشاره نمود. این بخش به معرفی کلاسها و کامپوننتهای بوتاسترپ میپردازد.
کلاسهای Utility : کلاسهای Utility در بوتاسترپ، بهطور ویژه برای استایلدهی عناصر صفحه استفاده میشوند و بهطور مستقیم با HTML و CSS کار میکنند. برای استفاده از این کلاسها نیازی به جاوااسکریپت نیست. کلاسهای آماده بوتاسترپ برای تعیین رنگ، اندازه عناصر، فواصل، خط دور، سایه و غیره قابل استفاده هستند.
کلاسهای رنگ: کلاسهای رنگ بوتاسترپ به دو دستۀ رنگهای زمینه و رنگ متن تقسیم میشوند. هر یک از کلاسهای رنگ دارای مفهوم و رنگ مشخصی هستند. کلاسهای رنگ زمینه و متن به ترتیب دارای پیشوند bg و text هستند. برخی از این کلاسها در جدول زیر گردآوری شده است:
جدول ۱: کلاسهای رنگ Bootstrap
کلاس رنگ زمینه
کلاس رنگ متن
مفهوم
bg-primary
text-primary
رنگ اصلی
bg-secondary
text-secondary
رنگ ثانویه
bg-success
text-success
رنگ موفقیت
bg-danger
text-danger
رنگ خطر
bg-warning
text-warning
رنگ هشدار
bg-info
text-info
رنگ اطلاعات
bg-light
text-light
رنگ روشن
bg-dark
text-dark
رنگ تیره
صفحه ۱۵۰
کلاسهای تعیین اندازه (Sizing)
بوتاسترپ دارای دو مجموعه کلاس *-w و *-h برای تعیین پهنا و ارتفاع عناصر است. پارامتر * میتواند جایگزین اعداد 25، 50، 75 و 100 و عبارت auto شود. اختصاص کلاس w-75 برای یک عنصر باعث میشود که پهنای عنصر برابر 75% پهنای عنصر والد باشد. کلاسهای w-auto و h-auto پهنا و ارتفاع یک عنصر را به اندازۀ محتوای آن تنظیم مینمایند.
Page 146
Learning unit 1
Have you ever thought about this
How can you design responsive, mobile-friendly websites without writing complex CSS?
Are there frameworks that give web developers ready-made CSS classes?
What ready-made classes and components does Bootstrap have for designing the parts of web pages?
How can you design data-entry forms quickly and in a modern style with Bootstrap?
How can you optimize web page design with Bootstrap so that pages look their best on all devices?
By the end, the student is expected to
Design the complete structure of a web page (header, body, and footer) with Bootstrap's grid system (Grid System), so that the layout responds correctly at different screen sizes (phone, tablet, desktop).
Choose and use utility classes (Utility Classes), such as color, spacing (Margin/Padding), shadow, and typography classes, to style elements quickly and in a standard way without writing CSS by hand for common cases.
Build a useful, attractive navigation bar (Navbar) with links, buttons, and responsive features, and design a structured footer.
Be skilled at building user interface components such as carousels (slide images) and accordions to present information in an engaging, dynamic way.
Build sign-up or contact forms fully styled with Bootstrap.
Change and override Bootstrap's default styles with customization techniques, to match the website's look to a brand or to the needs of the project.
Performance standard
Use Bootstrap's ready-made classes to style page elements such as buttons, forms, and menus, and be able to design pages responsively for different devices.
Page 147
What a framework is
A framework (Framework) is a predesigned software structure used to speed up designing and developing websites and web apps. By providing a set of tools, libraries, and ready-made patterns, a framework lets developers focus only on the specific features and functions of the project and avoid repetitive, basic work.
What is Bootstrap?
Bootstrap is an open-source framework for designing the look of a site, consisting of a set of ready-made code written in CSS, HTML and JavaScript. Instead of writing everything from zero, developers use this ready-made code.
Features of Bootstrap: Bootstrap has many features for designing web pages that have made it popular among web developers and designers. They are:
Responsive Design: Bootstrap has a 12-column grid system that makes responsive design possible for different devices.
Pre-designed Components: Bootstrap includes various components such as buttons, forms, the navigation menu, cards, modals and the search bar that can be used ready-made.
JavaScript support: Bootstrap includes JavaScript libraries for creating interactions and animations in different parts of the page.
Browser support: Bootstrap works with most modern browsers, such as Chrome, Firefox, Safari, and Edge.
Thorough documentation: Bootstrap's official site (getbootstrap.com) has complete documentation on how to use its components and classes.
Uses of Bootstrap
Designing responsive websites: designing and building company sites, shops, blogs, and so on.
Creating attractive user interfaces: designing beautiful, modern user interfaces for websites and web apps.
MVP projects (minimum viable product): building first versions of websites (MVP) and testing design ideas.
Designing forms: designing beautiful, responsive forms with Bootstrap's ready-made classes.
Page 148
Using Bootstrap in a web page
To use Bootstrap's features in a web page, first create a basic HTML file and then link Bootstrap's CSS and JavaScript files to it. The basic file contains the tags <!DOCTYPE html>, <html>, <head>, the viewport meta tag, <title>, and <body>.
Bootstrap classes and components
Bootstrap classes are a set of predefined styles that make it quick and easy to design the user interface of web pages. Built with CSS, they help web developers add user-friendly, responsive elements to a web page while writing less CSS.
Page 149
Bootstrap components are predesigned elements that make it quick and easy to design a website's user interface. With these ready-made elements, a web developer can add user-friendly, responsive elements to a web page without writing CSS and JavaScript. Bootstrap components include the button, the navigation bar¹, the carousel², the accordion³, and the modal⁴. This part introduces Bootstrap's classes and components.
Utility classes: Bootstrap's utility classes are used specifically to style page elements and work directly with HTML and CSS. Using these classes needs no JavaScript. Bootstrap's ready-made classes can set color, element size, spacing, borders, shadows, and so on.
Color classes: Bootstrap's color classes are of two kinds, background colors and text colors. Each color class has its own meaning and color. Background and text color classes start with bg and text. Some of them are listed in the table below:
Table 1: Bootstrap color classes
Background color class
Text color class
Meaning
bg-primary
text-primary
Primary color
bg-secondary
text-secondary
Secondary color
bg-success
text-success
Success color
bg-danger
text-danger
Danger color
bg-warning
text-warning
Warning color
bg-info
text-info
Info color
bg-light
text-light
Light color
bg-dark
text-dark
Dark color
Page 150
Sizing classes
Bootstrap has two sets of classes, *-w and *-h, for setting the width and height of elements. The * parameter can be replaced by the numbers 25, 50, 75 and 100 and the word auto. Giving the class w-75 to an element makes the width of the element 75% of the width of the parent element. The classes w-auto and h-auto set the width and height of an element to the size of its content.