简体   繁体   English

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

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

I confess that I have a poor knowledge in php and js, but I'm trying to innovate and make a descent website.我承认我对 php 和 js 的了解很差,但我正在尝试创新并制作一个血统网站。 So I made 2 different slides, one for desktop and one for mobile, got a shortcode and i'm trying to put that in a html widget using a js screen width detection and mentioning it in the php code.因此,我制作了 2 张不同的幻灯片,一张用于桌面,一张用于移动,得到了一个简码,我正在尝试使用 js 屏幕宽度检测将其放入 html 小部件中,并在 php 代码中提及它。 Maybe its wrong in lots of levels but as I said I have no knowledge about that, so obviously didn't work and the code just gave me a blank widget.也许它在很多层面都是错误的,但正如我所说,我对此一无所知,所以显然没有用,代码只是给了我一个空白小部件。 What am I doing wrong?我究竟做错了什么?

    <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]');
    }

?>

The error message is:错误信息是:

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

My friend @ChristophKern helped me and I realize it was simpler than I though, I just used html and css instead js and php.我的朋友@ChristophKern 帮助了我,我意识到它比我更简单,我只是使用 html 和 css 代替 js 和 php。 The full code is:完整的代码是:

<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]

Thank you Chris and Funk Forty Niner for the time spend to help me <3感谢 Chris 和 Funk Forty Niner 花时间帮助我 <3

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

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