What is Responsive Design? How to implement a responsive web page?


⭐ Introduction to the column

Front-end Getting Started Tour: Explore the wonderful world of Web development Remember to click the link above or on the right to subscribe to this column Oh Geometry will take you on a front-end journey

Welcome to the front-end introductory tour! This column is tailored for those friends who are interested in web development and have just stepped into the front-end field. Whether you are a complete novice or have some basic developers, here will provide you with a systematic and friendly learning platform. In this column, we will update it every day in the form of questions and answers, presenting selected front-end knowledge points and answers to frequently asked questions. Through the question-and-answer format, we hope to more directly respond to readers' questions about front-end technology, and help everyone gradually build a solid foundation. Whether it's HTML, CSS, JavaScript, or a variety of commonly used frameworks and tools, we'll explain concepts in simple terms and provide practical examples and exercises to reinforce what you've learned. At the same time, we will also share some practical tips and best practices to help you better understand and use various technologies in front-end development.

insert image description here

Not only that, we also regularly launch some practical project tutorials, so that you can apply the knowledge you have learned to actual development. Through the practice of actual projects, you will be able to better understand the workflow and methodology of front-end development, and develop your ability to solve problems and develop independently. We believe that only by continuous accumulation and practice can we truly master front-end development technology. So get ready for the challenge and bravely embark on this front-end introductory journey! Whether you're looking for a career transition, upskilling or personal interest, we're committed to providing you with the highest quality learning resources and support. Let's explore the wonderful world of web development together! Join the front-end introductory journey and become an excellent front-end developer! Let's set sail on the front-end journey


⭐ Responsive Design

Responsive design is an approach to web design that aims to make a website provide the best user experience across different devices and screen sizes. The goal of responsive design is to enable the layout and content of web pages to automatically adjust according to the characteristics of the access device to ensure that the website can be well rendered on various devices, including desktop computers, tablets and mobile phones.

The main principles of responsive design include:

  1. Elastic Grid Layout : Use relative units (such as percentages) rather than fixed units (such as pixels) to create layouts that allow content to adapt to different screen sizes.

  2. Media query : Use CSS3 media query function to apply different CSS styles according to screen width and other properties to adapt to different devices.

  3. Elastic images and media : Use CSS technology to ensure that image and media elements can be adaptively scaled according to the screen size to avoid the problem of images being too large or too small.

  4. Fluid Layout : Make text content automatically adjust layout on different screen sizes to ensure readability and user-friendliness.

  5. Optimized Navigation : Redesign the navigation menu to fit smaller screen devices and possibly use an accordion menu or side navigation.

  6. Test and tweak : Make sure your site works well in every situation by testing and tweaking it on different devices.


⭐ How to implement a responsive web page?

To implement a responsive web page, follow these steps:

1. Elastic Grid Layout

Use relative units (such as percentages) to lay out your web pages rather than fixed units (pixels). For example, use percentages to define the width of web pages and the width of columns so that they adapt to the screen size.

.container {
    
    
    width: 100%;
}

.column {
    
    
    width: 50%;
    float: left;
}

2. Media queries

Use CSS media queries to apply different styles based on screen width. Here is an example, when the screen width is less than 768px, the text color changes to red:

@media screen and (max-width: 768px) {
    
    
    p {
    
    
        color: red;
    }
}

3. Elastic images and media

Make sure images and media elements scale adaptively to the screen size. The maximum width of an image can be limited using the property in CSS max-width.

img {
    
    
    max-width: 100%;
    height: auto;
}

4. Flow layout

Use relative units to set text size and line height to ensure good readability of text on different screen sizes.

p {
    
    
    font-size: 16px;
    line-height: 1.5;
}

5. Optimized navigation

Redesigned navigation menu to fit small screen devices. Techniques such as accordion menus, side navigation, or drop-down menus can be used.

<!-- 折叠菜单示例 -->
<div class="mobile-menu">
    <button class="menu-toggle">菜单</button>
    <ul class="menu">
        <li><a href="#">首页</a></li>
        <li><a href="#">关于我们</a></li>
        <li><a href="#">服务</a></li>
        <li><a href="#">联系我们</a></li>
    </ul>
</div>

6. Testing and tuning

Finally, make sure your responsive pages work well in every situation by testing and tweaking them on different devices. Use browser development tools to emulate the screen sizes of different devices and ensure that your pages have good accessibility and user experience in each case.

Responsive design is an ongoing process that requires constant optimization and improvement to ensure adaptation to new devices and screen sizes. Here are some additional tips to consider when developing responsive web pages:

7. Image optimization

Use appropriately sized images and provide multiple image versions for different screen sizes. This can be done via <picture>the element or srcsetattribute.

<picture>
    <source media="(min-width: 1200px)" srcset="large-image.jpg">
    <source media="(min-width: 768px)" srcset="medium-image.jpg">
    <img src="small-image.jpg" alt="响应式图片">
</picture>

8. Font optimization

Choose an appropriate font and use @font-faceto load a custom font. Make sure font file sizes are reasonable for faster page loads.

@font-face {
    
    
    font-family: 'CustomFont';
    src: url('custom-font.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

body {
    
    
    font-family: 'CustomFont', sans-serif;
}

9. Progressive Enhancement

Use the principles of progressive enhancement to ensure that pages still work correctly on older devices that don't support certain advanced features. Gradually add more advanced features to provide a richer user experience.

10. Go mobile-first

Consider starting your design and development with mobile devices, and gradually adding functionality and layout to accommodate larger screens. This helps ensure that your web pages look great on small screens and gradually scale to larger devices.

11. User Testing

Ultimately, conducting user testing is key to ensuring the success of responsive design. Please test your pages several times on different devices and consider user feedback to improve the user experience.

By using these techniques together, you can create a responsive web page that adapts to various devices and screen sizes, provides a great user experience, improves accessibility, and ensures that your website performs smoothly in all situations.


⭐ Written at the end

This column is suitable for a wide range of readers, suitable for front-end beginners; or partners who have never studied the front-end and are interested in the front-end, or back-end students who want to better show themselves and expand some front-end knowledge points during the interview process, so If you have a front-end foundation and follow this column to learn, it can also help you to check and fill in the gaps to a great extent. Since the blogger himself does the content output, if there are any flaws in the article, you can contact me on the left side of the homepage , we make progress together, and at the same time recommend several columns for everyone, interested partners can subscribe: In addition to the columns below, you can also go to my homepage to see other columns;

Front-end games (free) This column will take you into a world full of creativity and fun. By using the basic knowledge of HTML, CSS and JavaScript, we will build various interesting page games together. Whether you're a beginner or have some front-end development experience, this column is for you. We'll start with the basics and guide you step-by-step through the skills you need to build web games. Through practical cases and exercises, you will learn how to use HTML to build page structure, use CSS to beautify the game interface, and use JavaScript to add interactive and dynamic effects to the game. In this column, we'll cover various types of mini-games, including maze games, arkanoid, snake, minesweeper, calculator, airplane wars, tic tac toe, puzzles, mazes, and more. Each project guides you through the building process in clear and concise steps, with detailed explanations and code examples. At the same time, we will also share some optimization tips and best practices to help you improve page performance and user experience. Whether you are looking for an interesting project to exercise your front-end skills, or are interested in web game development, the front-end small game column will be your best choice. Click to subscribe to the front-end game column

insert image description here

Vue3 transparent tutorial [from zero to one] (paid) Welcome to the Vue3 transparent tutorial! This column aims to provide you with comprehensive Vue3-related technical knowledge. If you have some Vue2 experience, this column can help you master the core concepts and usage of Vue3. We'll walk you through building a complete Vue application from scratch, step by step. Through actual cases and exercises, you will learn how to use Vue3's template syntax, component development, state management, routing and other functions. We will also introduce some advanced features, such as Composition API and Teleport, etc., to help you better understand and apply the new features of Vue3. In this column, we'll walk you through each project in concise steps, with detailed explanations and sample code. At the same time, we will also share some common problems and solutions in Vue3 development to help you overcome difficulties and improve development efficiency. Whether you want to learn Vue3 in depth or need a comprehensive guide to building front-end projects, the Vue3 transparent tutorial column will become your indispensable resource. Click to subscribe to the Vue3 transparent tutorial [from zero to one] column

insert image description here

TypeScript Getting Started Guide (Free) is a column designed to help you get started quickly and master TypeScript-related technologies. Through concise and clear language and rich sample code, we will explain the basic concepts, syntax and features of TypeScript in depth. Whether you are a beginner or an experienced developer, you can find a learning path that suits you here. From core features such as type annotations, interfaces, and classes to modular development, tool configuration, and integration with common front-end frameworks, we will cover all aspects comprehensively. By reading this column, you will be able to improve the reliability and maintainability of JavaScript code, and provide better code quality and development efficiency for your own projects. Let's embark on this wonderful and challenging TypeScript journey together! Click to subscribe to the TypeScript Getting Started Guide column

insert image description here

Guess you like

Origin blog.csdn.net/JHXL_/article/details/132442378