React项目中html标签下方出现意外空白区域的排查求助
Hey there, I’ve run into this exact annoying issue before—let’s get that random blank space sorted out for you!
What’s Causing the Blank Space?
Looking at your code, the culprit is almost certainly the <iframe> in your SongCard component. By default, browsers treat iframes as inline elements (or inline-block, depending on the browser), and they reserve a small bit of space below them to accommodate text baselines (like the bottom of letters such as "g" or "y"). This space doesn’t show up as a margin/padding in your CSS, which is why you couldn’t spot it in your styles or dev tools.
How to Fix It
Try these steps one by one—most likely the first one will solve your problem:
Make the iframe a block-level element
Update yourSongCard.cssto adddisplay: block;to the iframe styles. This removes the inline baseline spacing:iframe { width: 100%; display: block; /* Add this line */ }Reset default html/body styles
Sometimes browsers add tiny default margins to the<html>or<body>tags that you might miss. Add this to your global CSS file (likeindex.css) to wipe out those defaults:html, body { margin: 0; padding: 0; }Double-check Bootstrap row behavior
You’ve already reset margins/padding on Bootstrap’srowandcol-lg-8, but just to be safe—make sure no parent components are inheriting unexpected spacing. Since you’ve explicitly setmargin: 0; padding: 0;on those classes, this is probably not the issue, but it’s worth confirming if the first two steps don’t work.
Why This Works
By making the iframe a block element, you tell the browser to treat it like a standalone box instead of part of the text flow, so it won’t reserve that baseline space. The html/body reset ensures there’s no hidden default spacing at the root level of your app.
内容的提问来源于stack exchange,提问作者Viet

