简体   繁体   English

HTML div的最大大小

[英]html div with max size

I have a simple web page containg a single div element holding a leaflet map, and some javascript code. 我有一个简单的网页,其中包含一个包含传单地图的div元素和一些JavaScript代码。

On mobile devices, I'd like the div element to fill the entire screen. 在移动设备上,我希望div元素填充整个屏幕。 But, on larger screens such as PC screens, I'd like the div element to have a maximum size of, say, 800x600 pixels. 但是,在较大的屏幕(例如PC屏幕)上,我希望div元素的最大尺寸为800x600像素。 Otherwise, the leaflet will become too slow. 否则,传单将变得太慢。

How do I go about to implement that? 我该如何实施?

You can try this... 你可以试试这个...

<style type="text/css">
 div{
   width: 800px;
   height: 600px;
 }
 @media only screen and (max-width: 767px){
  div{
    width: 100%;        
  }
 }
</style>

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

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