如果用户屏幕
$(document).ready(function() {
if ((screen.width>1024)) {
// if screen size is 1025px wide or larger
$(".yourClass").css('display', 'none'); // you can also use $(".yourClass").hide();
}
elseif ((screen.width<=1024)) {
// if screen size width is less than 1024px
$(".yourClass").css('display', 'block'); // here you can also use show();
}
});
如果我的浮动 div 类名称是 sharecontent,我应该像下面这样替换上面的脚本吗?如果是的话,它不起作用。
$(document).ready(function() {
if ((screen.width>1024)) {
// if screen size is 1025px wide or larger
$(".sharecontent").css('display', 'none'); // you can also use $(".yourClass").hide();
}
elseif ((screen.width<=1024)) {
// if screen size width is less than 1024px
$(".sharecontent").css('display', 'block'); // here you can also use show();
}
});
我也尝试用 window.width 替换 screen.width 但仍然没有成功:(
Use 媒体查询 http://www.css3.info/preview/media-queries/。你的 CSS 代码是:
@media screen and (max-width: 1024px) {
.yourClass {
display: none !important;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)