开发者

Rails adding phantom whitespace above yield

开发者 https://www.devze.com 2023-04-03 20:09 出处:网络
This is killing me. Application layout: <html> <head> ... </head> <body topmargin=\"0\"><%= yield %></body>

This is killing me.

Application layout:

<html>
  <head>
    ...
  </head>
  <body topmargin="0"><%= yield %></body>
</html>

Home:

<div id="content">...</div>

Yet in the rendered page, across all browsers, there's a line of preformatted whitespace that pushes the content off the top of the window.

Rails adding phantom whitespace above yield

Where is this coming from?

Resolved

Invalid HTML markup (li directly within a开发者_C百科 div) caused all browsers to add a gap at the top. Strange!


You must have an open html tag somewhere, just run your html through a validator and see if it catches any.

http://validator.w3.org/#validate_by_input


Correct your tag:

<%= yield %>


I thing you looking in wrong layout, because you have

<body><%= yield %><body>

but in the screenshot you have

<body topmargin="0">


I had this problem and it stumped me for a few hours. I eventually noticed that the pages causing issues had a file type of "UTF-8 Unicode (with BOM)" I just converted the file to remove this and it worked perfectly.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号