如何限制浏览器的最小可调整大小宽度?

时间:2018-08-19 07:32:06

标签: javascript html css bootstrap-4

My website's minimum width vs GitHub's

在所附图像中,我正在比较我的网站和GitHub的最小可重新调整宽度。如何强制我的网站具有像GitHub这样的强制最小宽度?

我已经尝试将此代码合并到页面的相应CSS文件中:

body {
    min-width: 600px; 
    width: auto !important;
    width: 600px; 
}

很遗憾,没有区别,我的浏览器仍然可以调整大小,使其小于600px限制。

编辑:当前的答案仍然没有运气。

2 个答案:

答案 0 :(得分:0)

在chrome到devtools中,然后单击以下图标:

enter image description here

然后,您可以在其中单击“响应式”,并可以根据需要调整浏览器的大小。

此代码将限制用户调整大小:

        <tbody>
          @foreach ($chests['chest'] as $exerciseName => $daysArray)
              <tr>
                  <td>{{ $exerciseName }}</td>
            @foreach ($daysArray as $day)

                  <td >{{  $day }}</td>
            @endforeach
                  <td>{{ $chests['hints'][$exerciseName][0] }}</td>
              </tr>
          @endforeach

          </tbody>
var size = [window.width,window.height];  //public variable

$(window).resize(function(){
    window.resizeTo(size[0],size[1]);
});

在此代码段中无效,因为该代码段位于iframe中。但是应该可以在您的应用程序中使用,但其中包括JQuery。

答案 1 :(得分:0)

!important宽度样式使以下宽度样式变得多余,因此也可能根本不存在。 注意:如果内容大于最小宽度,则min-width属性无效。

相关问题