MultiWeb:基于Web响应式能力的多布局适配项目

用户可借助该项目学习Web多布局适配方案,实现应用在多设备上的良好体验。核心功能包括字体图片大小调整、宫格布局、轮播布局及自定义弹窗,通过媒体查询等技术动态适配不同屏幕尺寸。

Branch1Tags0

Web-Based Responsive Layout Development

Overview

This sample demonstrates how to implement common web effects, such as font size adjustment, image size adjustment, grid layout, carousel layout, and custom dialog box, based on web capabilities for multi-device adaptation, such as relative unit, media query, and window event. Such integrated web capabilities can provide a good user experience on multiple devices.

Preview

BreakPoint sm md lg
Final effect

Project Directory

├──WebProject                           // Web project
├──entry/src/main/ets/
│  ├──entryability
│  │  └──EntryAbility.ets               // Entry ability
│  ├──entrybackupability  
│  │  └──EntryBackupAbility.ets  
│  └──pages              
│     └──Index.ets                      // Page entry
└──entry/src/main/resources             // Static resources of the application

How to Use

This project is a Web multi-example, which realizes that the font and image sizes can be automatically adjusted to appropriate dimensions on different device sizes. Meanwhile, this project has made multi-layout adaptations for common scenarios such as carousels, grids, and pop-ups. Developers can run this program on different devices to view the layout effects.

How to Implement

  1. Use media query to set element attributes, such as font size and image size.
  2. Dynamically adjust the size of each carousel image and the carousel distance at a time to implement different carousel effects.
  3. Use media query to set different numbers of columns and spacing at different breakpoints to implement different grid effects.
  4. Use media query to set different size of dialog boxes at different breakpoints.

Permissions

N/A

Constraints

  1. The sample app is supported only on Bar phone, Bi-fold phone(Mate X series) and Tablet running the standard system.
  2. The HarmonyOS version must be HarmonyOS 5.0.5 Release or later.
  3. The DevEco Studio version must be DevEco Studio 5.0.5 Release or later.
  4. The HarmonyOS SDK version must be HarmonyOS 5.0.5 Release SDK or later.

Introduction

用户可借助该项目学习Web多布局适配方案,实现应用在多设备上的良好体验。核心功能包括字体图片大小调整、宫格布局、轮播布局及自定义弹窗,通过媒体查询等技术动态适配不同屏幕尺寸。

Customize your domain