如何让这个Javascript代码对任何屏幕都做出响应?

时间:2016-09-18 19:11:49

标签: javascript

我一直试图让这段代码响应,但没有成功。自动调整使得图表过于平坦,如果我使用高度和宽度,它只适用于某些屏幕。

任何想法?

高度和宽度

<!-- TradingView Widget BEGIN -->
<script type="text/javascript"
src="https://d33t3vvu2t2yu5.cloudfront.net/tv.js"></script>
<script type="text/javascript">
new TradingView.widget({
"width": 800,
"height": 600,
"symbol": "INDEX:MERV",
"interval": "D",
"timezone": "Etc/UTC",
"theme": "White",
"style": "1",
"locale": "es",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"allow_symbol_change": true,
"hideideas": true,
"show_popup_button": true,
"popup_width": "1000",
"popup_height": "650"
});
</script>
<!-- TradingView Widget END -->

自动调整大小

<!-- TradingView Widget BEGIN -->
<script     type="text/javascript"
src="https://d33t3vvu2t2yu5.cloudfront.net/tv.js"></script>
<script type="text/javascript">
new TradingView.widget({
"autosize": true,
"symbol": "INDEX:MERV",
"interval": "D",
"timezone": "Etc/UTC",
"theme": "White",
"style": "1",
"locale": "es",
"toolbar_bg": "#f1f3f6",
"enable_publishing": false,
"allow_symbol_change": true,
"hideideas": true,
"show_popup_button": true,
"popup_width": "1000",
"popup_height": "650"
});
 </script>
<!-- TradingView Widget END -->

Thaks !!

1 个答案:

答案 0 :(得分:0)

使用自动调整大小但尝试将图表放在具有已定义的最大宽度和最大高度的容器中(或根据媒体查询定义不同的宽度/高度)。