12th Design of user interface design Adaptive UI layout

Source: Internet
Author: User

1. Overview

With the growing popularity of mobile phones and tablet devices, developers have to consider the presence of MVC sites on mobile devices.

This chapter includes programs that run on multiple devices (screen resolution, css,html), and the design of a mobile-side web program.

2. Main content

  2.1 Programs running on multiple devices (screen resolution, css,html)

The default MVC project template supports desktop browsers that run in a Panorama view.

You can use @media queries to develop styles for different resolutions.

CSS3 allows the design to be considered based on the maximum screen width.

/*Landscape phone to portrait tablet up to 768px*/@media (max-width:767px){#container {/*Layout specific CSS*/} }  /*Portrait tablet to landscape and desktop (width between 768 and 980px)*/@media (min-width:768px) and (MAX-WIDTH:979PX) and (orientation:portrait){#container {/*Layout specific CSS*/} }  /*Large Desktop*/@media (min-width:980px){#container {/*Layout specific CSS*/} }

If you want to fit a smaller screen, you should create a mobile-friendly template page.

The jquery Mobile platform package provides a unified way to manage different mobile platforms using the same code.

  2.2 Designing a mobile-side web Program

You can support a variety of mobile browsers by modifying the Global.asax file.

namespacemvcapplication { Public classMvcApplication:System.Web.HttpApplication {protected voidApplication_Start () { DisplayModeProvider.Instance.Modes.Insert (  0, new  defaultdisplaymode ("Windows") {Contextcondition = (context = context.) Getoverriddenuseragent (). IndexOf ("Windows", StringComparison.OrdinalIgnoreCase) >= 0 )             });             Arearegistration.registerallareas ();             Webapiconfig.register (globalconfiguration.configuration);             Filterconfig.registerglobalfilters (globalfilters.filters);             Routeconfig.registerroutes (routetable.routes);             Bundleconfig.registerbundles (Bundletable.bundles);         Authconfig.registerauth (); }     } }

3. Summary

①asp.net MVC4 has several ways to support mobile users. You can create overloaded views for multiple devices, or you can develop for a single device.

System.Web.Mvc.VirtualPathProviderViewEngine.DisplayModeProvider can determine the source based on the request and return the corresponding custom-made view.

② there is another way to design a mobile-accessible site, which is to use viewport <meta> tags and CSS @media queries. You can group development styles based on the maximum and minimum width of the screen.

The ③jquery Mobile Library allows the use of tags (markup) to provide additional functionality to the client browser. If you encounter an unsupported browser, you can also downgrade to an alternative method.

12th Design of user interface design Adaptive UI layout

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.