简体   繁体   English

仅媒体屏幕向左滚动

[英]Media only screen scroll left

As i am trying to scroll left to right or other way in the menu top given on this image 当我尝试在此图像上给出的菜单顶部中向左或向右滚动时

Issue here is that in mobile it doesn't work that way after clicking it scrolls elsewhere but in web it works perfectly HTML i have done is given below 这里的问题是,在移动设备中, 单击鼠标后它无法滚动到其他位置 ,因此无法正常工作, 但是在网络上,它可以完美地运行我在下面给出的HTML

<div id="Default" class="contentHolder">
    <div class="content cd-tabs-navigation">
        <ul>
            <li><a data-content="HousingVitals" id="HousingVitals1" onclick="scrollDefault(1);" href="#0">Housing Vitals</a></li>
            <li><a data-content="Score" id="Score1" class="selected" onclick="scrollDefault(2);" href="#0">Rating Snapshot</a></li>
            <li><a data-content="locality" id="locality1" onclick="scrollDefault(3);" href="#0">Housing v/s Locality</a></li>
            <li><a data-content="Indicators" id="Indicators1" onclick="scrollDefault(4);" href="#0">Top Indicators</a></li>
            <li><a data-content="Compare" id="Compare1" onclick="initialize();" href="#0">Nearby Housings</a></li>  @*onclick="scrollUpMenu('near')"*@
            <li><a id="liInsights" data-content="Insights" onclick="scrollDefault(6);" href="#0">Key Insights</a></li>
            <li><a id="liDetailscore" data-content="Detailscore" onclick="scrollDefault(7);" href="#0">Detailed Rating</a></li>
            <li><a data-content="Wisometer" id="Wisometer1" onclick="scrollDefault(8);" href="#0">Wiso Meter</a></li>
        </ul>                                    
    </div>
</div>

and java script code is given below here 和Java脚本代码在下面给出

function scrollDefault(x)
    {   
        if(x == 1)
        {
            $('#Default').scrollLeft(0);
        }
        else if(x == 2)
        {
            $('#Default').scrollLeft(50);
        }
        else if(x == 3)
        {   
            $('#Default').scrollLeft(130);
        }
        else if(x == 4)
        {
            $('#Default').scrollLeft(220);
        }
        else if(x == 5)
        {
            $('#Default').scrollLeft(300);
        }
        else if(x == 6)
        {
            $('#Default').scrollLeft(370);
        }
        else if(x == 7)
        {
            $('#Default').scrollLeft(420);
        }
        else if(x == 8)
        {
            $('#Default').scrollLeft(500);
        }
    }

As far I can understand from your question, you are facing problem not only with media query but also about jQuery. 就您的问题而言,据我所知,您不仅面临媒体查询的问题,而且还面临有关jQuery的问题。

For media query please follow this link . 对于媒体查询,请点击此链接

Here you would be able to find a very rich explanation on how to use media query. 在这里,您可以找到有关如何使用媒体查询的非常丰富的说明。

About your current coding problem, first of all you can try to solve this issue using media query CSS. 关于当前的编码问题,首先,您可以尝试使用媒体查询CSS解决此问题。 That will reduce the necessity of writing complex codes. 这将减少编写复杂代码的必要性。 You can try to solve this issue using CSS. 您可以尝试使用CSS解决此问题。

Obviously you can do it with jQuery too. 显然,您也可以使用jQuery。 But you should develop your coding structure a bit. 但是您应该稍微开发一下编码结构。 You had to write redundant if else conditions. 如果没有其他条件,则必须编写多余的内容。 But if you would have kept the values in an associative array..you could have done if more efficiently by searching through that array. 但是,如果将这些值保存在关联数组中,则可以通过搜索该数组来提高效率。

If you are willing to do that then follow this link . 如果您愿意这样做,请点击此链接

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

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