Yosef Alnajjar
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    **Author**: @yosefanajjar **Maintainer**: @MohammedYehia # Welcome To The Responsive Design Workshop! This workshop is designed for **helping you out with understanding responsive design** and how to apply it in action using **relative units**, **media queries** and **responsive images** in CSS, throughout the workshop, you will learn about these things and in the end, there will be some helpful **exercise** so you can practice them in a good way. ## What is Responsive Design *Responsive design* is a way to approach designing your applications that is mindful of the fact that users don't all have screens of the same size. With a responsive design, the goal is to make your site beautiful for users on a variety of devices, while minimizing the amount of CSS you need to write. ## How to apply Responsive Design? To start making responsive designs that look good on all screen sizes you should know the following: ### 1. Devices Sizes/Break Points You need to be aware of the devices your users are using so you can target those devices screen sizes within your code as something we call ***breakpoints*** which we will take a look at later in the Media Queries part. A good way to do this is to group all devices of the same kind under one break point that covers them all, for example: - **Phones**: under 600px - **Tablets(Portrait Mode)**: under 900px - **Tablets (LandScape Mode)**: under 1200px - **Desktops/Laptops**: under 1800px - **Big Destops/Screens**: above 1800px Here is a simple graph of how this looks like ![devices sizes](https://i.imgur.com/36eTzkU.jpg) ### 2. Media Queries Media queries are CSS instructions that are important for creating responsive web pages. Media queries allow content to adapt to various screen resolutions, with different CSS instructions being used for different screen sizes ```css= @media screen and (max-width: 600px) { /* Your styles go here */ } ``` **Using media queries**: Using the syntax of the media query above, as you can see you need to specify a breakpoint using `max-width` or `min-width` so your styles can apply for the given width What's the difference between`max-width` and `min-width`? - The `min-width` property sets a minimum browser or screen width that a certain set of styles would apply to. - The `max-width property` does just the opposite. it sets a maximum browser or screen width that a certain set of styles would apply to The `min-width` and `max-width` properties can be used together to create a media query that applies to screens within a rage ```css= @media (min-width: 600px) and (max-width: 900px) { /* Your styles go here */ } ``` The above media query would apply to screens that have a minimum width of 600px and max-width of 900px **Media query example**: ```css= p { font-size: 24px; } @media (max-width: 1200px) { font-size: 16px; } @media (max-width: 600px) { font-size: 14px; } ``` **Try to figure out** what happens to the `p` element font size in the Desktop, tablet and mobile screen? > Basically what happens is that the font size decreases each time our screen size decreases Here is a graph that shows how we would apply media queries to various devices ![media queries sample](https://i.imgur.com/XZNcs1t.jpg) ### 3. Relative Units *Relative units*, as the name suggests, are always relative to the length/size of another property. A relative unit gets sizing from something else. > Most browsers specify a root font-size for the pages (16px) `Percentages %`: it sets the width/font-size of the element relative to its parent's width/font-size `rem`: it's relative to the root (i.e. HTML) element. This means that 1rem corresponds to the same size everywhere on the page (with font sizes and lengths). `em`: this one is a bit tricky, it's relative to the font-size of the element itself when setting lengths but it's relative to the parent element when setting the font-size `vh`: it's relative to the viewport's height (ie. 1vh = 1/100 of the viewport's height) `vw`: it's relative to the viewport's width (ie. 1vw = 1/100 of the viewport's width) **Quick Example**: ```css= div { font-size: 10px; } div p { font-size: 2em; /* 20px */ padding: 1em; /* 20px */ } div p span { font-size: 1rem; /* 16px */ padding: 2rem; /* 16 * 2 = 36px */ } ``` > In the example above we have div element what has a p element inside it and a span element, as you may have noticed that the em unit when setting the font-size it was relative to the parent element but when setting the padding(a length) it was relative to the font-size of the element itself, and the rem was always relative to the root element font-size ### 4. Responsive images There are two approaches to use images in your web page: - Using the `<img />` tag - Setting it as a background for a `div` When using images you want to make sure that they scale up and down or at least scale down so they don't look bad on smaller screens To scale it both up and down, we set the width to 100%: ```css= .responsive-img { width: 100%; } ``` To scale it only down, we set the max-width to 100% ```css= .responsive-img { max-width: 100%; } ``` There is more about responsive images, I just mentioned the basics of it in this workshop, for more checkout [this blog post](https://css-tricks.com/responsive-images-css/) on responsive images ### 5. Responsive Design Strategies **Desktop First** - Start writing CSS for the desktop: large screen - Then, media queries shrink design to smaller screens. **Mobile First** - Start writing CSS for mobile devices: small screen - Then, media queries shrink design to smaller screens **Which one should you use?** It depends on your project and the users devices, for example, mobile-first apps are optimized for the mobile experience and it results in faster web apps and desktop-first is Relatively quick, and it gives you more room for creative layouts. > So you'ed better decide what's best for the project and you and if you have team members you should decide together ![Destop VS Mobile](https://i.imgur.com/3gkoQvX.jpg) ### 6. Testing your media queries We test out our web pages using the dev tools in Chrome or in any browser you prefer, for this small exercise go on any responsive web page to carry on 1. Press `ctrl`+ `shift`+ `i` to open up the dev tools 2. Press on the responsive icon next to the cursor icon 3. Select which device you would like to see your page on 4. Select `Responsive` and resize the window to check for different screens at the same time 5. The colored lines show your media queries when you click on any of them you shall see the media query effect > These may not appear at first so you need to press on the menu next to the cursor and then on show media queries ![dev-tools](https://i.imgur.com/VciFQQ1.gif) In the frame is **w3school's** Band template, you can check the demo [here](https://www.w3schools.com/w3css/tryw3css_templates_band.htm) ## Excercise 1. `Clone` the repo Using the command `git clone <RepoUrl>` 2. `cd` into the folder 3. Go to the media.css file 4. Make the page responsive **Hints**: - You can look at how the result should look like [by clicking this link](https://mediaqueri.es/rwd/) - You probably should go to the styles.css file so you can see how the desktop version is made and that will make it way **much easier on you** to make it responsive! ## Usefull Resources :books: [The CSS Workshop - Relative Units](https://thecssworkshop.com/lessons/relative-units) [GeeksForGeeks - What is the difference between screen and only](https://www.geeksforgeeks.org/what-is-the-difference-between-screen-and-only-screen-in-media-queries/) [The Content Works - Media Queries](https://thecontentworks.uk/media-queries/) [FROONT - 9 basic principles of responsive web design](https://blog.froont.com/9-basic-principles-of-responsive-web-design/) [Smashing Magazine - Responsive Web Design - What It Is And How To Use It](https://www.smashingmagazine.com/2011/01/guidelines-for-responsive-web-design/) [Rithmschool - Responsive Design](https://www.rithmschool.com/courses/intermediate-css-bootstrap/responsive-design)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully