Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iframe-can';t使用CSS文件中的溢出来管理滚动条_Css_Iframe - Fatal编程技术网

iframe-can';t使用CSS文件中的溢出来管理滚动条

iframe-can';t使用CSS文件中的溢出来管理滚动条,css,iframe,Css,Iframe,我想在手机上显示滚动条,但在更大的屏幕上(例如,在PC上),我想隐藏这个滚动条 以下是我的HTML代码: <iframe frameborder="0" marginwidth="0" marginheight="0" width="100%" height="750" src="http://meteo.pl/um/php/meteorogram_id_um.php?ntype=0u&id=661"></iframe> 最后我可以看到两个滚动条。 当我以这种方

我想在手机上显示滚动条,但在更大的屏幕上(例如,在PC上),我想隐藏这个滚动条

以下是我的HTML代码:

<iframe frameborder="0" marginwidth="0" marginheight="0" width="100%" height="750" src="http://meteo.pl/um/php/meteorogram_id_um.php?ntype=0u&id=661"></iframe>
最后我可以看到两个滚动条。 当我以这种方式尝试时:

iframe {
overflow-x: hidden!important;
overflow-y: hidden !important;
}
我总是有两个滚动条,所以我不能在CSS文件中管理这个滚动条。为什么

  • 为iframe属性设置一个id
  • 我们需要调用函数的事件,所以要将onload和onresize属性添加到
  • 
    ...
    

    3.最后添加javascript函数,该函数将根据屏幕大小处理滚动的变化:

    <script>
    function f(){
    if(document.body.clientWidth<700)
    
    //condition which checks if the Width of page is less than 700, put your own value here
    
    {document.getElementById("myFrame").setAttribute("scrolling","yes");}
    
    //if yes, than, with help of function .getElementById we fetch element with id="myFrame" and change its attribute’s scrolling value to "yes" (mobile device)
    
    else
    
    {document.getElementById("myFrame").setAttribute("scrolling","no");}
    
    //if the width of the page is not less than 700 (or any),  then scrolling's value is "no" (widescreen resolution)
    
    }
    <script>
    
    
    函数f(){
    
    if(document.body.clientwidth)我可以使用CSS:
    @媒体屏幕和(最小宽度:1280px)控制客户端宽度
    -仅此而已。但在css中管理滚动条真的不可能吗?我需要使用javascript?可以使用css处理滚动,但是您必须根据屏幕大小启用和禁用滚动,因为您的用户可以使用手机和笔记本电脑。要做到这一点,最好的方法是编写一个javascript函数将不断计算屏幕的宽度并相应地采取行动。因此,如果可能的话,告诉我怎么做。忘记“笔记本电脑和手机”。我想知道如何管理CSS文件中的滚动条。在第二种情况下,当您在尝试删除所有内容的同时获得两个滚动条时,只需添加
    scrolling=“no”
    中的
    ,然后在CSS文件中应用
    溢出:隐藏。因此,您将看不到任何滚动条。
    
    <script>
    function f(){
    if(document.body.clientWidth<700)
    
    //condition which checks if the Width of page is less than 700, put your own value here
    
    {document.getElementById("myFrame").setAttribute("scrolling","yes");}
    
    //if yes, than, with help of function .getElementById we fetch element with id="myFrame" and change its attribute’s scrolling value to "yes" (mobile device)
    
    else
    
    {document.getElementById("myFrame").setAttribute("scrolling","no");}
    
    //if the width of the page is not less than 700 (or any),  then scrolling's value is "no" (widescreen resolution)
    
    }
    <script>