Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Varying widths according to size of screen

5 views
Skip to first unread message

bit-n...@hotmail.com

unread,
Jul 23, 2017, 2:28:25 PM7/23/17
to
If I have some search results, say, like you get on an E-commerce site, I would like the number of items per line vary according to the size of the screen - eg. if there are 10 say, handbags, if the screen width is short, I would like there to be 4 handbags on the first 2 lines, and 2 on the last one. But if the screen is BIG - then there should be 5 on each line. How do I architect this? (if it's a table they're in, then - tables have <tr>s, not just <td>s, ie. you have to TELL it where each row ends...)

...I'm not sure this is the right group, or the HTML one, or the CSS one, or the MySQL one.... but this LOOKS most appropriate :)


Thanks.

J.O. Aho

unread,
Jul 23, 2017, 3:30:24 PM7/23/17
to
On 07/23/17 20:28, bit-n...@hotmail.com wrote:
> If I have some search results, say, like you get on an E-commerce site, I would like the number of items per line vary according to the size of the screen - eg. if there are 10 say, handbags, if the screen width is short, I would like there to be 4 handbags on the first 2 lines, and 2 on the last one. But if the screen is BIG - then there should be 5 on each line. How do I architect this? (if it's a table they're in, then - tables have <tr>s, not just <td>s, ie. you have to TELL it where each row ends...)
>
> ...I'm not sure this is the right group, or the HTML one, or the CSS one, or the MySQL one.... but this LOOKS most appropriate :)

No, you are in the completely wrong group, you should try CSS group and
they tell you how to make div's float.


--

//Aho

Richard Damon

unread,
Jul 23, 2017, 3:33:07 PM7/23/17
to
The correct answer is you likely want to ask in an CSS group (or as a
fallback an HTML one) for the best answer, and part of the answer is
that you DON'T build the results with a table. Formatting via a table
directives is an ancient method, with the problems like you are
experiencing.

Mark Lloyd

unread,
Jul 24, 2017, 11:26:01 AM7/24/17
to
You want your code to be responsive to the width of the user's screen
(or, preferably, browser window). There's a problem in that PHP runs on
the server and doesn't normally have access to that information.

I use this and have Javascript set a cookie with the window width (and
height). This can be retrieved and used in PHP. There's still a problem
in that the cookie won't be available until the next page load, but that
can be triggered in JS.

Modern browsers also have a CSS setting for columns, which you might be
able to use.

--
Mark Lloyd
http://notstupid.us/

"The deepest sin against the human mind is to believe things without
evidence." -- Thomas Henry Huxley (1825-1895)
0 new messages