diff --git a/docs/html/responsive-web-design/blue.png b/docs/html/responsive-web-design/blue.png new file mode 100644 index 000000000..c82c2ff97 Binary files /dev/null and b/docs/html/responsive-web-design/blue.png differ diff --git a/docs/html/responsive-web-design/flexbox-and-grid-layout.md b/docs/html/responsive-web-design/flexbox-and-grid-layout.md index e711a707e..2ca05775e 100644 --- a/docs/html/responsive-web-design/flexbox-and-grid-layout.md +++ b/docs/html/responsive-web-design/flexbox-and-grid-layout.md @@ -5,4 +5,255 @@ sidebar_label: Flexbox and Grid Layout sidebar_position: 3 tags: [html, web-development, flexbox, grid-layout] description: In this tutorial, you will learn how to use Flexbox and Grid Layout to create responsive web designs and build complex layouts in HTML and CSS. ---- \ No newline at end of file +--- + +In this tutorial, you will learn how to use Flexbox and Grid Layout to create responsive web designs and build complex layouts in HTML and CSS. +

+ +![Local Image](https://ishadeed.com/assets/grid-flex/grid-vs-flexbox.png) + +## What is Flexbox? +Flexbox, or the Flexible Box Layout, is a layout model that allows items within a container to be automatically arranged depending on the available space. + +### Basic Syntax +Here is the basic syntax of a Flexbox container: + +```css +.container { + display: flex; + flex-direction: row; /* or column */ +} +``` + +### Example +Let's look at a simple example where we create a flexible layout: + + + +```html + + + + + + Flexbox Example + + + +
+
Box 1
+
Box 2
+
Box 3
+
+ + +``` +
+ + + ![banner](flexbox.png) + + +
+ + +## What is Grid Layout? +Grid is a blueprint for making websites. + +The Grid model allows you to layout the content of your website. Not only that, it helps you create the structures you need for building responsive websites for multiple devices. This means your site will look good on desktop, mobile, and tablet. + +Grid Layout is a two-dimensional layout system for the web. It allows you to create complex layouts using rows and columns. + +### Basic Syntax +Here is the basic syntax of a Grid container: + +```css +.container { + display: grid; + grid-template-columns: repeat(3, 1fr); + grid-template-rows: auto; +} +``` + +### Example +Let's look at a simple example where we create a grid layout: + + +```html + + + + + + + Grid Layout Example + + + + +
+
Box 1
+
Box 2
+
Box 3
+
Box 4
+
Box 5
+
Box 6
+
+ + + +``` +
+ + + ![banner](grid.png) + + +
+ +## Practical Example +Let's create a practical example where we use both Flexbox and Grid Layout to adjust the layout of a simple webpage based on different screen sizes: + + + +```html + + + + + + Responsive Flexbox Layout + + + +
+
Box 1
+
Box 2
+
Box 3
+
+ + +``` +
+ +```html + + + + + + Responsive Grid Layout + + + +
+
Box 1
+
Box 2
+
Box 3
+
Box 4
+
Box 5
+
Box 6
+
+ + +``` +
+ + + ![banner](output.png) + + +
+ +# Resources + - [Fkexbox cheatsheet](https://css-tricks.com/wp-content/uploads/2022/02/css-flexbox-poster.png) + - [Grid cheatsheet](https://css-tricks.com/wp-content/uploads/2022/02/css-grid-poster.png) + +## Conclusion +Flexbox and Grid Layout are essential tools in creating responsive web designs. By understanding and utilizing these techniques, you can ensure that your web pages provide an optimal viewing experience across a wide range of devices and screen sizes. Experiment with different layout properties and combinations to see what works best for your specific design needs. diff --git a/docs/html/responsive-web-design/flexbox.png b/docs/html/responsive-web-design/flexbox.png new file mode 100644 index 000000000..bc90b6c36 Binary files /dev/null and b/docs/html/responsive-web-design/flexbox.png differ diff --git a/docs/html/responsive-web-design/green.png b/docs/html/responsive-web-design/green.png new file mode 100644 index 000000000..d8a9b3e57 Binary files /dev/null and b/docs/html/responsive-web-design/green.png differ diff --git a/docs/html/responsive-web-design/grid.png b/docs/html/responsive-web-design/grid.png new file mode 100644 index 000000000..b42bf30d4 Binary files /dev/null and b/docs/html/responsive-web-design/grid.png differ diff --git a/docs/html/responsive-web-design/introduction-to-responsive-design.md b/docs/html/responsive-web-design/introduction-to-responsive-design.md index 5f4c4bd93..335e35b63 100644 --- a/docs/html/responsive-web-design/introduction-to-responsive-design.md +++ b/docs/html/responsive-web-design/introduction-to-responsive-design.md @@ -5,4 +5,118 @@ sidebar_label: Introduction to Responsive Design sidebar_position: 1 tags: [html, web-development, responsive-web-design] description: In this tutorial, you will learn the basics of responsive web design and how to create responsive websites that work on all devices. ---- \ No newline at end of file +--- + +Responsive Web Design (RWD) is an approach to web development that ensures web pages render well on a variety of devices and window or screen sizes. This is achieved through the use of flexible layouts, flexible images, and CSS media queries. + +A responsive web design will automatically adjust for different screen sizes and viewports. + +Responsive Web Design is about using HTML and CSS to automatically resize, hide, shrink, or enlarge, a website, to make it look good on all devices (desktops, tablets, and phones): + +![banner](https://www.infront.com/wp-content/uploads/2019/10/responsive-websites-700-1.jpg) + +## Setting The Viewport +To create a responsive website, add the following `` tag to all your web pages: + +```html + +``` +This will set the viewport of your page, which will give the browser instructions on how to control the page's dimensions and scaling. + +Here is an example of a web page without the viewport meta tag, and the same web page with the viewport meta tag: + + + + + +
+ +
+ +
+
+ + + +
+ +
+ +
+
+
+ +## Flexible Layouts + +Flexible layouts use relative length units, such as percentages, rather than fixed units like pixels. This allows the layout to adapt to the size of the viewport. + +```html +
+ This div will take up 50% of the width of its container. +
+``` + +## Flexible Images + +Flexible images are also sized in relative units to prevent them from displaying outside their containing element. + +```html +Responsive Image +``` + +## Media Queries + +Media queries are a key component of responsive design. They allow you to apply different styles based on the characteristics of the device, such as its width, height, or orientation. + +```css +@media (max-width: 600px) { + .responsive-class { + font-size: 14px; + } +} +``` + +## Browser Support + +The numbers in the table specify the first browser version that fully supports the feature. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefoxSafariOpera
Flexible Layouts1.012.01.03.17.0
Flexible Images1.012.01.03.17.0
Media Queries21.012.03.54.012.1
+ +## Conclusion + +Responsive Web Design is essential for creating web pages that provide a good user experience across a wide range of devices. By using flexible layouts, flexible images, and media queries, you can ensure your web pages look great no matter the screen size. Always test your designs on multiple devices to ensure compatibility and usability. \ No newline at end of file diff --git a/docs/html/responsive-web-design/media-queries-and-breakpoints.md b/docs/html/responsive-web-design/media-queries-and-breakpoints.md index dec8cf594..b44ff8b8f 100644 --- a/docs/html/responsive-web-design/media-queries-and-breakpoints.md +++ b/docs/html/responsive-web-design/media-queries-and-breakpoints.md @@ -5,4 +5,230 @@ sidebar_label: Media Queries and Breakpoints sidebar_position: 2 tags: [html, web-development, responsive-web-design, media-queries, breakpoints] description: In this tutorial, you will learn how to use media queries and breakpoints to create responsive web designs that adapt to different screen sizes and devices. ---- \ No newline at end of file +--- + +Media queries allow you to apply CSS styles depending on a device's media type (such as print vs. screen) or other features or characteristics such as screen resolution or orientation, aspect ratio, browser viewport width or height, user preferences such as preferring reduced motion, data usage, or transparenc + +## Designing For The Best Experience For All Users +Web pages can be viewed using many different devices: desktops, tablets, and phones. Your web page should look good, and be easy to use, regardless of the device. + +Web pages should not leave out information to fit smaller devices, but rather adapt its content to fit any device: + + + + + +
+ +
+ +
+
+ + + +
+ +
+ +
+
+ + + +
+ +
+ +
+
+
+ + +## What Are Media Queries? +Media queries are a fundamental part of responsive web design. They allow you to apply CSS rules based on the characteristics of the device rendering the content, such as its width, height, orientation, and resolution. + +### Basic Syntax +Here is the basic syntax of a media query: + +```css +@media (condition) { + /* CSS rules */ +} +``` + +### Example +Let's look at a simple example where we change the background color based on the screen width: + + + +```css +/* Default styles */ +body { + background-color: white; +} +/* Styles for screens wider than 600px */ +@media (min-width: 600px) { + body { + background-color: lightblue; + } +} +/* Styles for screens wider than 900px */ +@media (min-width: 900px) { + body { + background-color: lightgreen; + } +} +``` + + + + ![banner](green.png) + + + + + ![banner](blue.png) + + + + + ![banner](white.png) + + + + +## Common Breakpoints +Breakpoints are the points at which your website content will adapt to provide the best possible layout for the user. Here are some common breakpoints: + +- **Small devices (phones, 600px and down):** + ```css + @media (max-width: 600px) { + /* CSS rules for small devices */ + } + ``` + +- **Medium devices (tablets, 600px to 900px):** + ```css + @media (min-width: 600px) and (max-width: 900px) { + /* CSS rules for medium devices */ + } + ``` + +- **Large devices (desktops, 900px and up):** + ```css + @media (min-width: 900px) { + /* CSS rules for large devices */ + } + ``` + +## Advanced Media Queries +Media queries can also be combined to create more complex conditions. For example, you can target devices with a specific orientation or resolution: + +### Orientation +```css +/* Styles for landscape orientation */ +@media (orientation: landscape) { + /* CSS rules for landscape orientation */ +} + +/* Styles for portrait orientation */ +@media (orientation: portrait) { + /* CSS rules for portrait orientation */ +} +``` + +### Resolution +```css +/* Styles for high-resolution screens */ +@media (min-resolution: 2dppx) { + /* CSS rules for high-resolution screens */ +} +``` + +## Practical Example of Orientation +Let's create a practical example where we adjust the layout of a simple webpage based on different screen sizes: + + + +```html + + + + + + Responsive Web Design + + + +
+
Box 1
+
Box 2
+
Box 3
+
+ + +``` +
+ + + +
+ +
+ +
+
+ + + +
+ +
+ +
+
+
+## Conclusion +Media queries and breakpoints are essential tools in creating responsive web designs. By understanding and utilizing these techniques, you can ensure that your web pages provide an optimal viewing experience across a wide range of devices and screen sizes. Experiment with different breakpoints and media query conditions to see what works best for your specific design needs. + +## Conclusion \ No newline at end of file diff --git a/docs/html/responsive-web-design/output.png b/docs/html/responsive-web-design/output.png new file mode 100644 index 000000000..7678079a1 Binary files /dev/null and b/docs/html/responsive-web-design/output.png differ diff --git a/docs/html/responsive-web-design/white.png b/docs/html/responsive-web-design/white.png new file mode 100644 index 000000000..0dda32e73 Binary files /dev/null and b/docs/html/responsive-web-design/white.png differ