繁体   English   中英

我想制作一个响应式横幅,它会根据分辨率屏幕的 php、js 和 html

[英]I want to make a responsive banner, that changes depending of the resolution screen with php, js and html

我承认我对 php 和 js 的了解很差,但我正在尝试创新并制作一个血统网站。 因此,我制作了 2 张不同的幻灯片,一张用于桌面,一张用于移动,得到了一个简码,我正在尝试使用 js 屏幕宽度检测将其放入 html 小部件中,并在 php 代码中提及它。 也许它在很多层面都是错误的,但正如我所说,我对此一无所知,所以显然没有用,代码只是给了我一个空白小部件。 我究竟做错了什么?

    <script type="text/javascript">
$(document).ready(function () {
  createCookie("width", $(window).width());
});
</script>

<?php
if ($_COOKIE["height"] => 768px) {
    echo do_shortcode('[URIS id=2822]');
} 
    else {
        echo do_shortcode('[URIS id=2883]');
    }

?>

错误信息是:

768px) { echo do_shortcode('[URIS id=2822]'); } else { echo do_shortcode('[URIS id=2883]'); } ?>

我的朋友@ChristophKern 帮助了我,我意识到它比我更简单,我只是使用 html 和 css 代替 js 和 php。 完整的代码是:

<style>
@media only screen and (min-width: 768px) 
{
  #slider-pro-3-2883 
   {
    display: none;
   }
}

@media only screen and (max-width: 767px) 
{
  #slider-pro-3-2822 
   {
    display: none !important;
   }
}
</style>

[URIS id=2822]
[URIS id=2883]

感谢 Chris 和 Funk Forty Niner 花时间帮助我 <3

暂无
暂无

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

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