[英]Align center to the JQMPage of jqm4gwt when using by PC
I would like to create a application, which can be used by either PC or mobile. 我想创建一个可以被PC或移动设备使用的应用程序。
If the application is used by PC, the screen is too wide, so, I would like to set max-width to the application and align center the JQMPage in PC mode. 如果PC使用该应用程序,则屏幕太宽,因此,我想为该应用程序设置最大宽度,并在PC模式下将JQMPage居中对齐。
If it is used by mobile, it is not need width=device-width. 如果移动设备使用它,则不需要width = device-width。
Now I set the style to JQMPage div, max-width it is work, but I can't align center. 现在我将样式设置为JQMPage div,最大宽度是可行的,但是我无法对齐中心。 How should I do? 我应该怎么做?
There is a way for setting max-width and align center in PC mode only ?? 有一种方法只能在PC模式下设置最大宽度和对齐中心?
jQM pages are absolutely positioned, so you can center them like this: jQM页面是绝对定位的,因此您可以像这样居中:
div[data-role=page] {
max-width: 600px; /* choose appropriate max-width */
left:0;
right:0;
margin-left:auto;
margin-right:auto;
}
If you prefer, you can put this rule within a media query that only takes effect when the screen is wide (then you could add border/shadow etc.): 如果愿意,可以将此规则放在仅在屏幕较宽时才生效的媒体查询中(然后可以添加边框/阴影等):
@media all and (min-width: 600px) {
div[data-role=page] {
max-width: 600px;
left:0;
right:0;
margin-left:auto;
margin-right:auto;
border: 1px solid #ccc !important;
-moz-box-shadow: 2px 2px 12px 2px rgba(100,100,100,0.3);
-webkit-box-shadow: 2px 2px 12px 2px rgba(100,100,100,0.3);
box-shadow: 2px 2px 12px 2px rgba(100,100,100,0.3);
}
}
NOTE: in my example I have used 600px as the max-width. 注意:在我的示例中,我使用600px作为最大宽度。 You should tweak this to the actual value that works for your project. 您应该将此调整为适用于您的项目的实际值。
我认为您想开发自适应网站k ...即使在我的项目中,我也面临着同样的问题,在这里我尝试了这一功能,对我来说很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.