Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on May 29, 2021 20:17:35 GMT -8
I combined my "replies" and "views" columns into one, with the descriptor floating left and the count floating right. The problem is, I can only get it to line up correctly with "views" on the top and "replies" on the bottom, but I want it the opposite way. Here's a comparison of what works (left) and what happens when I try to swap the order (right): The code I'm using for the left image: <td class="activity"><span style="font-size:80%; color:#999999;"><span style="float:left;">Views:</span><span style="float:right;">$[thread.views]</span></span><br /><span style="float:left;">Replies:</span><span style="float:right;">$[thread.replies]</span></td> Code I try using for the right image: <td class="activity"><span style="float:left;">Replies:</span><span style="float:right;">$[thread.replies]</span><br /><span style="font-size:80%; color:#999999;"><span style="float:left;">Views:</span><span style="float:right;">$[thread.views]</span></span></td>
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on May 30, 2021 8:17:49 GMT -8
Hi Matte I don't know enough about it to say why there is a difference when you change the sequence. But in my experience, I've found that whenever having issues with floats it's safest to use an empty element with a style attribute so the previous floats can be cleared. We could use an empty div: <div style="clear:both;></div> But since you already have a <br /> we could use that to clear the floats. <br / style="clear:both;"> I've added indentation as well as adding the style attribute to your break so it's a bit easier to keep track of the hierarchy of the elements. Give this a try: <td class="activity"> <span style="float:left;">Replies:</span> <span style="float:right;">$[thread.replies]</span> <br / style="clear:both;"> <span style="font-size:80%; color:#999999;"> <span style="float:left;">Views:</span> <span style="float:right;">$[thread.views]</span> </span> </td>
|
|
Matte
New Member
Posts: 92
inherit
264111
0
Oct 21, 2024 20:35:25 GMT -8
Matte
92
April 2021
matte
|
Post by Matte on May 30, 2021 8:26:39 GMT -8
Thanks, Retread! Your code works perfectly. Clearing the floats is something I had no idea about. Good to know!
|
|
inherit
140147
0
Nov 19, 2024 5:07:22 GMT -8
Nscalerr
Throw me to the wolves and I'll return leading the pack!
3,043
May 2009
nscalerr
|
Post by Nscalerr on May 30, 2021 10:59:05 GMT -8
Btw the br tag should be <br style="clear: both" />.
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on May 30, 2021 11:22:58 GMT -8
Btw the br tag should be <br style="clear: both" />. you don't actually need to close empty tags in HTML5 (br, img, etc) so you can leave off the forward slash entirely. also, Retread — clear:both is for preventing floating elements on either side of the specified element & semantically means to start a new row / line of content. by using clear:both on an element following two floating elements, you ensure that the content floats on the singular row instead of attempting to float with every other preceding element. there are multiple ways to clear (eg: inherit, or if you only have left float, left) so in this case "both" was appropriate as left and right were used, but should be mindful moving forward to use the appropriate value.
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on May 31, 2021 3:41:22 GMT -8
also, Retread — clear:both is for preventing floating elements on either side of the specified element & semantically means to start a new row / line of content. by using clear:both on an element following two floating elements, you ensure that the content floats on the singular row instead of attempting to float with every other preceding element. there are multiple ways to clear (eg: inherit, or if you only have left float, left) so in this case "both" was appropriate as left and right were used, but should be mindful moving forward to use the appropriate value. I'm not sure what you meant to say, but what you did say implies there might be an issue clearing both if only one of float:left or float:left float:right had been used. That simply isn't the case when we want to start fresh and disrespect any (and all) previous floats.
|
|
Kami
Forum Cat
Posts: 40,201
Mini-Profile Theme: Kami's Mini-Profile
#f35f71
156500
0
Offline
Jul 24, 2021 11:48:29 GMT -8
Kami
40,201
July 2010
kamiyakaoru
Kami's Mini-Profile
|
Post by Kami on May 31, 2021 4:37:33 GMT -8
also, Retread — clear:both is for preventing floating elements on either side of the specified element & semantically means to start a new row / line of content. by using clear:both on an element following two floating elements, you ensure that the content floats on the singular row instead of attempting to float with every other preceding element. there are multiple ways to clear (eg: inherit, or if you only have left float, left) so in this case "both" was appropriate as left and right were used, but should be mindful moving forward to use the appropriate value. I'm not sure what you meant to say, but what you did say implies there might be an issue clearing both if only one of float:left or float:left float:right had been used. That simply isn't the case when we want to start fresh and disrespect any (and all) previous floats. i had a lengthier post typed up to this (sorry if you already saw it) but i've decided to remove it. i'll defer to your expertise here. my apologies for interfering unnecessarily, it won't happen again.
|
|
inherit
252032
0
Apr 26, 2024 23:51:41 GMT -8
Retread
Tribbial Pursuit.
5,017
January 2018
retread
|
Post by Retread on May 31, 2021 5:52:24 GMT -8
i had a lengthier post typed up to this (sorry if you already saw it) but i've decided to remove it. I did see it and considered replying to it. But we both would have added a lot of unnecessary clutter. Glad to avoid that. ☮️
|
|