GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Wrapping an unordered list into multiple columns? (https://gfy.com/showthread.php?t=950459)

Angry Jew Cat - Banned for Life 01-27-2010 04:35 AM

Wrapping an unordered list into multiple columns?
 
How do I? So the list goes so far down, then wraps around again?

So if I wanted to display an alphabetically ordered list, across 3 columns, they would appear like this.
A_______D________G
B_______E________H
C_______F________I

Know what I mean?

georgeyw 01-27-2010 05:35 AM

info from a db?

easily done in a few different ways - whynot use css - far easier and cleaner.

total num rows / ceil 3

gives number of rows for each column

load up info in an array

1____________(num = column1 + num rums)____________(nm = col2 + num rows)

etc......

lots of ways to do it

RazorSharpe 01-27-2010 05:43 AM

Quote:

Originally Posted by Angry Jew Cat (Post 16787042)
How do I? So the list goes so far down, then wraps around again?

So if I wanted to display an alphabetically ordered list, across 3 columns, they would appear like this.
A_______D________G
B_______E________H
C_______F________I

Know what I mean?

like this?
http://sdezine.com/jewcat.html

RazorSharpe 01-27-2010 06:13 AM

or ....
http://sdezine.com/jewcat2.html

StaceyJo 01-27-2010 06:46 AM

Quote:

Originally Posted by RazorSharpe (Post 16787228)

Great ! :thumbsup:thumbsup

Angry Jew Cat - Banned for Life 01-29-2010 02:07 AM

Quote:

Originally Posted by RazorSharpe (Post 16787266)

Yes, that is how I'd like it, what I'm wrapping is a list of tags from wordpress. Maybe I should have mentioned that in the first post. I was just curious if their was a control via CSS which would automatically wrap the list into a new column, and display it like so across a specific number of columns.

JD 01-29-2010 02:16 AM

float the li left/right and assign it a width that's about 1/3rd of the area it'll be in and they'll fall in line.

Angry Jew Cat - Banned for Life 01-29-2010 02:22 AM

Quote:

Originally Posted by JD (Post 16793992)
float the li left/right and assign it a width that's about 1/3rd of the area it'll be in and they'll fall in line.

might be harassing you in a few

JD 01-29-2010 02:44 AM

Quote:

Originally Posted by Angry Jew Cat (Post 16794003)
might be harassing you in a few

be gentle I'm a virgin :helpme

Voodoo 01-29-2010 02:50 AM

Tables. Lots of Tables. Nested Tables inside other Nested Tables.

Angry Jew Cat - Banned for Life 01-29-2010 02:51 AM

Quote:

Originally Posted by Voodoo (Post 16794034)
Tables. Lots of Tables. Nested Tables inside other Nested Tables.

That sounds like an awful big headache to me.

Angry Jew Cat - Banned for Life 01-29-2010 02:52 AM

Quote:

Originally Posted by JD (Post 16794025)
be gentle I'm a virgin :helpme

Don't worry, I've been taking it easy on the sauce tonight dumpling. :1orglaugh

Thanks.

bns666 01-29-2010 03:17 AM

nice tip, needed something like this awhile ago.

redwhiteandblue 01-29-2010 03:28 AM

Quote:

Originally Posted by JD (Post 16793992)
float the li left/right and assign it a width that's about 1/3rd of the area it'll be in and they'll fall in line.

That'll sort them into rows not columns.

fris 01-29-2010 07:12 AM

Quote:

Originally Posted by Angry Jew Cat (Post 16793977)
Yes, that is how I'd like it, what I'm wrapping is a list of tags from wordpress. Maybe I should have mentioned that in the first post. I was just curious if their was a control via CSS which would automatically wrap the list into a new column, and display it like so across a specific number of columns.

I would make a custom tag cloud

http://briancray.com/2009/09/04/word...-php-function/

modify it to fit your needs

JD 01-29-2010 02:30 PM

Quote:

Originally Posted by redwhiteandblue (Post 16794058)
That'll sort them into rows not columns.

right, but with what he's getting the data from there's not much choice to do it into columns. that would require multiple UL's

cyco_cc 01-29-2010 02:35 PM

Quote:

Originally Posted by Voodoo (Post 16794034)
Tables. Lots of Tables. Nested Tables inside other Nested Tables.

If you're not nesting at least 5 tables deep, you're doing it wrong, right?! :winkwink:

borked 01-29-2010 03:26 PM

why can't you do it in a table? Why does it have to be an <UL>?

From a mysql query, let's say you retrieve 20 results (for nice round numbers for this eg) and you want 4 columns.

Then you know there will be 5 rows.

Code:

for ($i=0; $i<$numRows; $i++) {

  echo "<tr>";

  for ($k=0; $k<$numCols; $k++) {
    $key = ($k * $numRows) + $i;
    echo "<td>".$content[$key]."</td>
  }
 
  echo "</tr>";
}


The code above will fit your 2x3, 3x4, 3x3, 4x5 anything stuff. It just won't handle things having eg 21 results - you need standard code to add cell padding for that.

Kind of like taking a horse to water, but you can't make it drink ;)

borked 01-29-2010 03:37 PM

yup, this works nice

Code:

<?php
$content = array(
'a',
'b',
'c',
'd',
'e',
'f',
'g',
'h',
'i',
'j',
'k',
'l',
'm',
'n',
'o',
'p',
'q',
'r',
's',
't',
);

$numRows = 4;
$numCols = 5;

for ($i=0; $i<$numRows; $i++) {

  echo "<tr>";

  for ($k=0; $k<$numCols; $k++) {
    $key = ($k * $numRows) + $i;
    echo "<td>".$content[$key]."</td>";
  }

  echo "</tr>\n";
}
?>


Voodoo 01-29-2010 05:14 PM

Pure CSS:
Code:

<ul style="float: left; width: 21em; margin: 20px 0 1em 0; padding: 0; list-style: none; font-size: 1em; line-height: 1.3em;">
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Cake</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Pie</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Cookies</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Candy</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Pudding</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Ice Cream</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Chocolate</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Vanilla</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Cherry</li>
</ul>


Angry Jew Cat - Banned for Life 01-29-2010 05:32 PM

Quote:

Originally Posted by Voodoo (Post 16796706)
Pure CSS:
Code:

<ul style="float: left; width: 21em; margin: 20px 0 1em 0; padding: 0; list-style: none; font-size: 1em; line-height: 1.3em;">
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Cake</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Pie</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Cookies</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Candy</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Pudding</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Ice Cream</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Chocolate</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Vanilla</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Cherry</li>
</ul>


This is essentially the same thing me and JD went over last night, and is what I have decided to settle on for the moment. While it sorts into rows and not columns, it will still do, because everything else is far to complicated for my code-illiterate ass... :thumbsup

The Truth Hurts 01-29-2010 05:37 PM

Quote:

Originally Posted by Voodoo (Post 16796706)
Pure CSS:
Code:

<ul style="float: left; width: 21em; margin: 20px 0 1em 0; padding: 0; list-style: none; font-size: 1em; line-height: 1.3em;">
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Cake</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Pie</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Cookies</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Candy</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Pudding</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Ice Cream</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Chocolate</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Vanilla</li>
  <li style="float: left; width: 7em; margin: 0; padding: 0; list-style: none;">Cherry</li>
</ul>


wow... not solving the problem, and defeating half the purpose of css all rolled into one.
:upsidedow

Voodoo 01-29-2010 07:25 PM

Quote:

Originally Posted by The Truth Hurts (Post 16796764)
wow... not solving the problem, and defeating half the purpose of css all rolled into one.
:upsidedow

Apparently, you don't quite understand.

The code I posted was not a full solution. It was an example of the columns. The inline-css is just for demonstration purposes. Obviously, someone would remove this and put it in their stylesheet.

The other thing that would need to be done is some php for/if/while loops to get the data into colunns, not rows, similar to what bork posted, but not using tables.

Try again.

The Truth Hurts 01-29-2010 07:55 PM

Quote:

Originally Posted by Voodoo (Post 16796937)
Try again.

No need....


PS, AJC.. you can handle this with jquery...
see: http://codeasily.com/jquery/multi-co...st-with-jquery

JD 01-29-2010 08:26 PM

Quote:

Originally Posted by borked (Post 16796365)
why can't you do it in a table? Why does it have to be an <UL>?

From a mysql query, let's say you retrieve 20 results (for nice round numbers for this eg) and you want 4 columns.

Then you know there will be 5 rows.

Code:

for ($i=0; $i<$numRows; $i++) {

  echo "<tr>";

  for ($k=0; $k<$numCols; $k++) {
    $key = ($k * $numRows) + $i;
    echo "<td>".$content[$key]."</td>
  }
 
  echo "</tr>";
}


The code above will fit your 2x3, 3x4, 3x3, 4x5 anything stuff. It just won't handle things having eg 21 results - you need standard code to add cell padding for that.

Kind of like taking a horse to water, but you can't make it drink ;)

it's coming from WP so there's not quite as much room code wise

Hotrocket 01-29-2010 10:21 PM

I use this hack to display Categories in 2 columns, maybe you can apply it to Tags too?
http://www.blogohblog.com/10-wordpre...e-even-easier/
(2nd tutorial on the list)

MetaMan 01-29-2010 11:00 PM

BAH NOOBS

<style type="text/css">
#dog {
width: 750px;
float: left;
}
#dog ul {
margin: 0;
padding: 0;
float: left;
}
#dog li {
list-style-type: none;
float:left;
padding: 0;
margin: 0;
width: 250px;
}
.dogin {
width: 250px;
float: left;
}
</style>


<body>
<div id="dog">
<ul>

<div class="dogin">
<li>A</li>
<li>B</li>
<li>C</li>
</div>

<div class="dogin">
<li>D</li>
<li>E</li>
<li>F</li>
</div>

<div class="dogin">
<li>G</li>
<li>H</li>
<li>I</li>
</div>

</ul>
</div>
</body>
</html>

The Truth Hurts 01-30-2010 12:02 AM

Quote:

Originally Posted by MetaMan (Post 16797382)
BAH NOOBS

1.. that wouldn't validate in 100 years..
2... that's manually breaking up the list, which isn't what he 's looking to do...
3... who's the noob?

MetaMan 01-30-2010 12:40 AM

Quote:

Originally Posted by The Truth Hurts (Post 16797434)
1.. that wouldn't validate in 100 years..
2... that's manually breaking up the list, which isn't what he 's looking to do...
3... who's the noob?

1. i know the guy for years and have helped him for free many times, solving many of his problems
2. i know he has never gaven a fuck if it validates because it is his own page just as long as he gets helped
3. i call him noob like he calls me scammer as a joke
4. manually insert your own foot into your ass
5. mind your own business noob

MetaMan 01-30-2010 12:48 AM

Quote:

Originally Posted by The Truth Hurts (Post 16797434)
1.. that wouldn't validate in 100 years..
2... that's manually breaking up the list, which isn't what he 's looking to do...
3... who's the noob?

validating is for noobs like you who cant code cross browsers. no elements are broken so it does not affect the way a search engine will read your page.

you can wave your "validation panty flag" high and mighty all you want but at the end of the day when that code is viewed by the engine it makes 0 difference.

i bet your mom gets real impressed when you code a shit page and it validates but is broken in every browser. good for you...

noob.

The Truth Hurts 01-30-2010 01:13 AM

I was hand coding cross browser identical pages before you handed out your first order of supersized fries.

Next time when someone points out one of your many mistakes, maybe try and learn from it instead of responding like a child.

MetaMan 01-30-2010 09:09 AM

Quote:

Originally Posted by The Truth Hurts (Post 16797484)
I was hand coding cross browser identical pages before you handed out your first order of supersized fries.

Next time when someone points out one of your many mistakes, maybe try and learn from it instead of responding like a child.

the internet didnt exist before i was hand coding multiple browsers.

i love how you avoided my point about validation because you have trouble admitting you are wrong.

next time someone points out your flawed thinking learn from it.

potter 01-30-2010 09:50 AM

Quote:

Originally Posted by MetaMan (Post 16797933)
the internet didnt exist before i was hand coding multiple browsers.

i love how you avoided my point about validation because you have trouble admitting you are wrong.

next time someone points out your flawed thinking learn from it.

Dude, face it. You're not supposed to put a div inside of a list. In fact, a lot of browsers will even break the list if there is something like that in it. The only reason what you're saying MIGHT work in all the browsers is because of an inherent flaw in the way they currently render having a block level element inside of a list like that. Meaning, eventually - they will not render correctly.

In fact, the whole idea of what you're doing makes the list completely irrelevant and useless. He could pull out all the list code and just use the divs and it would still render the same. Not only are you breaking and voiding the list item to ALL major browsers, but you're negating the whole reason for him to be putting it into a list in the first place.

Sorry dude, but you're code is wrong, let alone invalid. The End.

potter 01-30-2010 09:52 AM

And what you want to do is possible with CSS3. However most browsers don't support it yet, so by using it you'd be loosing the rendering for every one of your visitors.

The Truth Hurts 01-30-2010 09:52 AM

Quote:

Originally Posted by MetaMan (Post 16797933)
the internet didnt exist before i was hand coding multiple browsers.

i love how you avoided my point about validation because you have trouble admitting you are wrong.

next time someone points out your flawed thinking learn from it.




I didn't avoid yout point.
It was as flawed as your code.
Simple.

Although your code may have worked..
It wasn't what he asked for.
He specifically asked for an AUTOMATIC solution...
Yours was a MANUAL hackjob.
There is a difference.

MetaMan 01-30-2010 10:07 AM

Quote:

Originally Posted by potter (Post 16798010)
Dude, face it. You're not supposed to put a div inside of a list. In fact, a lot of browsers will even break the list if there is something like that in it. The only reason what you're saying MIGHT work in all the browsers is because of an inherent flaw in the way they currently render having a block level element inside of a list like that. Meaning, eventually - they will not render correctly.

In fact, the whole idea of what you're doing makes the list completely irrelevant and useless. He could pull out all the list code and just use the divs and it would still render the same. Not only are you breaking and voiding the list item to ALL major browsers, but you're negating the whole reason for him to be putting it into a list in the first place.

Sorry dude, but you're code is wrong, let alone invalid. The End.

i never said it validated properly. i was trying to make a quick fix.

it does render properly though and that is my point. and there is no "eventually". i can bet we come back in 5 years and it will still render.

explain to me why it make the list irrelevant? the SE will see it is a list and organize its content.

my point about validation is people over worry about the wrong things when it comes to it. yes i should have written a better code but lets talk about this:

you can have a site that validates but have over 1000 extra divs.

maybe we should start a new thread about this. i want to find out peoples views on validation. The Truth Hurts can come in there and bash me there. we are kinda crowding this thread now.

MetaMan 01-30-2010 10:09 AM

Quote:

Originally Posted by The Truth Hurts (Post 16798017)
I didn't avoid yout point.
It was as flawed as your code.
Simple.

Although your code may have worked..
It wasn't what he asked for.
He specifically asked for an AUTOMATIC solution...
Yours was a MANUAL hackjob.
There is a difference.

lol it was. but why not say this. your post was an obvious jab at me thinking i was hating when indeed i was not.

i never read AUTOMATIC solution in this thread. please post where it says that. or else i would have tried something different.

i actually wanted to hear your opinion on validation.

The Truth Hurts 01-30-2010 10:29 AM

Quote:

Originally Posted by MetaMan (Post 16798056)
lol it was. but why not say this. your post was an obvious jab at me thinking i was hating when indeed i was not.

Your post starts off with "BAH NOOBS"...
sounds a bit like hating...

Quote:

Originally Posted by MetaMan (Post 16798056)
i never read AUTOMATIC solution in this thread. please post where it says that. or else i would have tried something different.

see:
Quote:

Originally Posted by Angry Jew Cat (Post 16793977)
I was just curious if their was a control via CSS which would automatically wrap the list into a new column, and display it like so across a specific number of columns.

Quote:

Originally Posted by MetaMan (Post 16798056)
i actually wanted to hear your opinion on validation.

I try and validate everything as much as possible.
Doesn't mean it always does. doesn't mean i don't make use of hacks when necessary.

MetaMan 01-30-2010 10:34 AM

Quote:

Originally Posted by The Truth Hurts (Post 16798096)
Your post starts off with "BAH NOOBS"...
sounds a bit like hating...

see:

I try and validate everything as much as possible.
Doesn't mean it always does. doesn't mean i don't make use of hacks when necessary.

was just a joke with him not a personal attack. its like when you got a buddy you have known for years and you tell him he is a complete idiot. :) everyone is so uppity around here lately cant even joke around anymore.

AHH ok my bad didnt notice it. i was just trying to help out.

i just find alot of people misuse the reasoning behind validation. thats all i was trying to point out. i dont even run my pages through validation anymore im sure you dont as much either. after you have been coding for a while and do things "proper" it becomes less useful i find.

i think it is a bad stepping stone for people who just validate and think pages are proper. im sure you have seen many pages where it validates and the code hurts your brain. same with the SEs. :)

fris 02-16-2010 06:46 AM

Quote:

Originally Posted by Angry Jew Cat (Post 16787042)
How do I? So the list goes so far down, then wraps around again?

So if I wanted to display an alphabetically ordered list, across 3 columns, they would appear like this.
A_______D________G
B_______E________H
C_______F________I

Know what I mean?

i know this is an old post, but I found this yesterday

http://csswizardry.com/2010/02/mutip...-using-one-ul/


All times are GMT -7. The time now is 11:00 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123