这是纯粹的 CSS 方式,但是......从我最喜欢的主题中,尝试响应式 jQuery 规则:
/*
Responsive jQuery is a tricky thing.
There's a bunch of different ways to handle
it, so be sure to research and find the one
that works for you best.
*/
/* getting viewport width */
var responsive_viewport = $(window).width();
/* if is below 481px */
if (responsive_viewport < 481) {
} /* end smallest screen */
/* if is larger than 481px */
if (responsive_viewport > 481) {
} /* end larger than 481px */
/* if is above or equal to 768px */
if (responsive_viewport >= 768) {
}
/* off the bat large screen actions */
if (responsive_viewport > 1030) {
}
或者您可以通过添加 style="" 属性并格式化您在其中的媒体查询将其硬编码到模板文件中。这只会使该模板中的那个 div 受媒体查询影响。