【问题标题】:Displaying of different prompt message in different screen resolutions using html [closed]使用html以不同的屏幕分辨率显示不同的提示信息[关闭]
【发布时间】:2017-01-26 20:25:37
【问题描述】:

例如:单击按钮时,在桌面版屏幕中应显示提示消息为“Hi”。 .在移动屏幕尺寸中单击时相同,它应显示提示消息为“Hello”。

【问题讨论】:

  • 可以使用bootstrap的modal。它适用于各种屏幕。
  • 你之前尝试过的。也显示一些代码。
  • × 这是一个警告盒子。

标签: javascript angularjs html twitter-bootstrap css


【解决方案1】:

你可以这样做:

var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
var height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;

$('#btn').on('click', function() {
  if (width > 480 && height > 800) {
    alert('hi');
  } else {
    alert('hello');
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input type="button" id="btn" value="Click me" />

【讨论】:

    【解决方案2】:

    检查this 回答。然后在获得屏幕的宽度后,您可以

    getElementById("my_element").innerHTML() 并设置任何你想要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-06
      • 2017-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多