Skip to content

jquery: Optimize footer display on mobile devices#486

Merged
mgol merged 6 commits intojquery:mainfrom
HermitShamiko:optimization
Feb 3, 2026
Merged

jquery: Optimize footer display on mobile devices#486
mgol merged 6 commits intojquery:mainfrom
HermitShamiko:optimization

Conversation

@HermitShamiko
Copy link
Contributor

@HermitShamiko HermitShamiko commented Jan 18, 2026

When the screen size is larger than 480px, follow the display style of the PC and place the books in a single line.
befofe:
FY~}1 K0JH$Z~)}M)}@TJ6J
after:
~2@W}0KC0Q@~~)P$UH{NCOS

Optimize footer display on mobile devices
Fixed a bug that caused overflow when the width was too small.
Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I don't think it's the best solution, though. What flex mostly does here is making float: left ineffective, more so than any real flex algorithm.

footer .books li has override styles for max-width: 700px. I checked and 3 books don't fit on the smallest phone screens (like first iPhone SE: 320 px wide) but they do for slightly larger screens.

In the interest of maintainability, I'd rather rework the whole footer .books & .footer .books li styles to remove floats and introduce flexbox with CSS gap, and then on the smallest breakpoints - max-width: 480 px - make it stretch instead.

Let me know if you'd like to work on it.

Rewrite the footer.books layout
@HermitShamiko HermitShamiko requested a review from mgol January 22, 2026 03:39
@HermitShamiko
Copy link
Contributor Author

HermitShamiko commented Jan 22, 2026

Thanks for the PR. I don't think it's the best solution, though. What flex mostly does here is making float: left ineffective, more so than any real flex algorithm.

footer .books li has override styles for max-width: 700px. I checked and 3 books don't fit on the smallest phone screens (like first iPhone SE: 320 px wide) but they do for slightly larger screens.

In the interest of maintainability, I'd rather rework the whole footer .books & .footer .books li styles to remove floats and introduce flexbox with CSS gap, and then on the smallest breakpoints - max-width: 480 px - make it stretch instead.

Let me know if you'd like to work on it.
I have tried rewriting the footer.books layout.
The default (700px is the same):

72RMZMTPT3}5(NY3C9$LS1I U~WUQWU$)F(CZZC%S4A X5U

Below 480, it is not limited to one line:

DS){D@@PL (TI1L5JDG7KOM

Looking forward to your further guidance!

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates. This is really close to what I'd like to see, just some tweaks needed and most of them involve removing more code.

}

footer .books li:first-child {
margin-left: 0%;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In regular styles, we have margin-left: 2%. Do we need that? If not, both it and this override could be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the purpose of margin-left: 2% is for visual compensation, because the title of the first book, Learning jQuery Fourth Edition, is rather long, and without a margin-left, the left and right sides might appear visually asymmetrical.Should it be removed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, in the old layout the default margin-left for li elements in the books list is 2.8%, so this 2% for the first child decreases its margin, not increases it.

I think it's best to avoid such adjustments in the flex world. Let's remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will remove the 2% margin😀.

}

footer .books {
flex-wrap: wrap;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed, but does it hurt to also leave it in general styles? Then we wouldn't need any additions to the max-width: 480px breakpoint; the general rules would cover everything.

Fix some issues
@HermitShamiko HermitShamiko requested a review from mgol January 30, 2026 01:55
@HermitShamiko
Copy link
Contributor Author

@mgol I have corrected most of the issues you mentioned. The fixed aspect ratio is no longer enforced below 480px. Finally, whether the margin-left code should be retained requires further judgment from you.

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks a lot cleaner now!

I'll need to test this myself and I'm away from my computer right now, so I'll test this early next week and I'll see if we need any more changes.

min-width: 95px;
margin-left: 2.8%;
margin-bottom: 15px;
flex: 1 0 29%;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why specifically 29% and not 30%?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the footer.books element in the original code has a width of 30%, I found during testing that maintaining 30% results in a display error on screens with dimensions between 770px and 940px.
footer .books li { float: left; width: 30%; min-width: 95px; margin-left: 2.8%; margin-bottom: 15px; line-height: 130%; font-size: 11px; text-align: center; }
61Q1H{~C)JH 7GTO0K3DD{K
The reason for this problem is that width(30%) x 3 + gap(16px) x 3 + first-child(2%) > 100%. Using 29%, it becomes width(29%) x 3 + gap(16px) x 3 + first-child(2%) < 100%. Of course, 29% isn't a very precise number, but it's simpler than using calc() and can display the desired result across all sizes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the restriction is that a needs to be at least as large as the contained image then flex-basis should just be set to 92px instead of a percentage. So, flex: 1 0 92px here.

}

footer .books li {
min-width: 92px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain where this number came from?

Copy link
Contributor Author

@HermitShamiko HermitShamiko Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The width: 92px; here comes from the minimum image size set in the original footer.books.li a img attribute. I didn't change the actual image display size; I only rewrote the layout.
footer .books li a img { display: block; border-radius: 5px; border: solid 1px rgba(255,255,255,0.2); width: 92px; height: 114px; margin: 0 auto 5px; }
I think on devices with smaller screens, the size of the li element can be made to match the size of the img element inside it, so that the CSS can adapt to the screen size.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you set flex above to 1 0 92px as I suggested, this will probably not be needed anymore.

}

footer .books li:first-child {
margin-left: 0%;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more comments

optimize layout
@HermitShamiko
Copy link
Contributor Author

@mgol Oh yes, I forgot to check the margin-left: 2.8% in the old .books li, which caused me to misunderstand the purpose of the 2%.
I've removed the adjustment for widths below 480px for cleaner CSS.

@HermitShamiko HermitShamiko requested a review from mgol February 3, 2026 04:43
Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you!

@mgol mgol merged commit 7201d5b into jquery:main Feb 3, 2026
5 checks passed
@HermitShamiko HermitShamiko deleted the optimization branch February 4, 2026 01:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants