简体   繁体   English

创建Wordpress网站的移动版本

[英]Creating mobile version of the Wordpress site

We have website that was developed for desktops and now I've been blessed with a task of creating mobile version of it. 我们有一个专为台式机开发的网站,现在我很荣幸能够创建它的移动版本。 The mobile design might be quite different from desktop version and the website is build on Wordpress. 移动设计可能与台式机版本完全不同,并且网站基于Wordpress构建。 Now I'm not sure what would be best approach: 现在我不确定什么是最好的方法:

  1. shall I stick to CSS changes only (as much as possible) and use media queries to target smaller screens? 我应该只坚持CSS更改(尽可能多)并使用媒体查询来定位较小的屏幕吗? I'm worried about large images still being downloaded even if these are display:none. 我担心即使显示为“大”也无法下载大图像。 There is also quite a bit of JS happening on every page and this JS will not be used in mobile version of the site so I would have to build in additional checks possibly etc. Any other possbile problems with this approach? 每个页面上也有很多JS发生,并且该JS不会在网站的移动版本中使用,因此我可能必须进行其他检查,等等。这种方法还有其他可能的问题吗?

  2. server side code should detect if its mobile browser and should return custom html? 服务器端代码应检测其移动浏览器,并应返回自定义html? Any other possbile problems with this approach? 此方法还有其他可能的问题吗?

  3. mixture of two above? 以上两种的混合物?

  4. any other options? 还有其他选择吗?

If anyone has experience with similar project and could point me to what proffered solution would be that would be great. 如果有人在类似项目上有经验,并且可以指出解决方案,那将是很棒的。

I am a big fan of the Responsive Theme Wordpress has. 我是Wordpress响应主题的忠实拥护者。 It is very customizable, and will allow you to use one site for both Mobile and Desktop. 它是非常可定制的,将允许您将一个站点同时用于移动和桌面。

https://wordpress.org/themes/responsive https://wordpress.org/themes/responsive

Use media queries as much as possible for layout changes. 尽可能使用媒体查询来更改布局。 For you JS, create yourself a small breakpoint handler that will trigger the js to run or stop. 为您的JS创建一个小的断点处理程序,该处理程序将触发js运行或停止。

I think a lot of people don't realize that a 2x image compressed is smaller than a 1x image compressed. 我认为很多人没有意识到压缩的2倍图像小于压缩的1倍图像。 So, if you use compression for you images, you will actually get a better network performance using just large images. 因此,如果对图像使用压缩,则仅使用大图像实际上会获得更好的网络性能。 How much of that image gets displayed is a potential issue that can cause negative performance, but I imagine that it's insignificant. 显示多少图像是一个可能导致性能下降的潜在问题,但我认为这并不重要。

Are you using completely different UI for mobile than for desktop or is is just a different positioning of elements? 您在移动设备上使用的UI与在桌面设备上使用的UI完全不同,还是元素的定位不同? If you have to support two templates then you will want o think about Adaptive(responsive from the server), where the server will determine based on the UserAgent which template to send to the client. 如果必须支持两个模板,则需要考虑Adaptive(服务器响应),服务器将根据UserAgent确定将哪个模板发送给客户端。 UserAgent wont really get you much except for the type of Browser the client has. 除了客户端具有的浏览器类型外,UserAgent不会真正给您带来很多好处。 To figure out the dimensions of the device's screen you will need to know the dimensions or use a service like WURFL. 要弄清楚设备屏幕的尺寸,您需要知道尺寸或使用WURFL之类的服务。

If you can do all of your UI change in one template using media queries then it might be best to start working on this from a Mobile First approach and basically start from scratch on your mobile look of the site and then figure out how you can re-position the elements on the page to match as close as possible to the current desktop look. 如果您可以使用媒体查询在一个模板中完成所有UI更改,那么最好从Mobile First方法开始进行此工作,并且基本上从头开始了解网站的移动外观,然后弄清楚如何重新-将页面上的元素放置在尽可能接近当前桌面外观的位置。 Using the Responsive vs Adaptive approach will eliminate the need for UserAgent detection and you will only work with the width of the device. 使用自适应与自适应方法将消除对UserAgent检测的需要,并且您将仅使用设备的宽度。

Thinking of Responsive in "Mobile" vs "Desktop" is really limiting and causes a bit of confusion. 在“移动”与“台式机”中对响应式的思考实际上是有局限性的,并且会引起一些混乱。 Mobile should refer to devices that change location. 移动设备应指代更改位置的设备。 Try using names like small, medium, and large to describe the layouts(breakpoints) for your Responsive Page. 尝试使用小,中和大等名称来描述响应页面的布局(断点)。

Finally, there is not preferred way of doing "Responsive." 最后,没有首选的方式来执行“响应式”。 Each site will have it's own requirements that need to be met. 每个站点都会有自己需要满足的要求。 It is up to you to learn as much as possible and create the preferred way for your needs. 您需要学习尽可能多的知识,并根据自己的需要创建首选的方式。

You could always use: 您可以随时使用:

 <meta name = "viewport" content = "width = device-width">

in your header. 在您的标题中。 Then the whole site will resize to fit the mobile device. 然后,整个站点将调整大小以适合移动设备。

All your js should still work on mobile devices. 您所有的js仍应可在移动设备上运行。 It would just be 'flash' that wouldn't. 只是“闪光”而不会。

The site isn't "responsive" with this but, depending on the site and how much interaction etc the visitor needs, sometimes this is adequate and simple? 网站对此并不“响应”,但是根据网站以及访问者需要多少交互等,有时这是否足够简单?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM