简体   繁体   English

根据屏幕分辨率获得最大结果

[英]max results based on screen resolution

I have a site that lists the best books by popular vote. 我有一个网站通过大众投票列出了最好的书。 The books are stored in a database. 书籍存储在数据库中。 Is there a way to set the $maxresults to the width of the monitor? 有没有办法将$ maxresults设置为显示器的宽度? On larger monitors, this leaves one or two books in the entire bottom row. 在较大的显示器上,这将在整个底行留下一两本书。 I'd like each row to be filled in regardless of the resolution. 我希望无论分辨率如何都可以填充每一行。 Maybe an if statement? 也许是if语句? My code: 我的代码:

  $maxresults = 21;
  if($_GET['page'])
  $page = $_GET['page'];
  else
  $page = 0;
  $currentpage = $page;
  $page = $page*$maxresults;
  $numpages = QuickQuery("SELECT COUNT(id) FROM movies WHERE visible=1");
  $numpages = mysql_result($numpages, 0);
  $numpages = $numpages/$maxresults-1;
  $result = GetBooksByRangeID($page, $maxresults);//Show <maxresults> pages at a time
  DisplayResults($result); 
  ?>

You can do it with javascript. 您可以使用javascript。 Don't be scared, it's not that difficult. 别害怕,这并不困难。

First, chec the screen resolution: http://www.pageresource.com/jscript/jscreen.htm 首先,选择屏幕分辨率: http : //www.pageresource.com/jscript/jscreen.htm

Second, pass more elements to the client side and hide them dynamically - set display="none" or something like that (you may use http://datatables.net/ for example). 其次,将更多元素传递给客户端并动态隐藏它们-设置display =“ none”或类似的内容(例如,您可以使用http://datatables.net/ )。

If you're looking for this to work based on window size, rather than monitor size (ie it should fill the browser window but not run offscreen if the window is smaller than the screen), take a look at the jQuery .width() function ( http://api.jquery.com/width/ ) 如果您要根据窗口大小而不是监视器大小来工作(例如,它应填充浏览器窗口,但如果窗口小于屏幕,则不应该在屏幕外运行),请查看jQuery .width()功能( http://api.jquery.com/width/

If the display of each book is contained in a div, you can just set the style for the div to be float: left . 如果每本书的显示都包含在div中,则只需将div的样式设置为float: left Then the group of them will fill the screen until they run out of room, and then break onto a new line. 然后,他们将填满整个屏幕,直到它们用完为止,然后跳到新的一行。

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

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