Why isn't Modernizr working for me?

醉酒当歌 提交于 2019-11-28 10:31:00

You probably are forgetting to style the new HTML5 elements as block-level elements. By default, browsers treat any unknown element as an inline element (display:inline) which makes it difficult to do much with them.

Newer browsers are slowly treating the new HTML5 elements as stable, meaning they start giving them default styling like display:block for the header element, for instance. But, most browsers on the market today don’t have those default styles for HTML5 elements, so you’ll need to provide them.

Here’s a quick sample bit of CSS to do that:

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
  display: block;
}

Adding that CSS to your main.css should fix your styling issue.

I had the same issue when I was trying to use a CDN and it wasn't working (I might have had the wrong link). The test I found was to put

.borderradius body {
  background: #c00;
}

in your main.css and see if the background turns red. If it is modernizr, is working.

EDIT: I've also found that the script must be inserted at the top of the HTML document. Putting it at the bottom, as suggested for better loading speed of pages, doesn't work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!