简体   繁体   中英

Can't get CSS to load

I can't seem to get a css file to apply its styling to a form. It is quite frustrating now because as far as I know it should work!

In my head I have

<link href="/stylesheets/formtastic.css?1290524609" media="screen" rel="stylesheet" type="text/css" /> 

and in the body I have:

<form action="/agents" class="formtastic agent" id="new_agent" method="post">

The formtastic.css file should apply styling to the form. It's contents are viewable here: formtastic.css

Any suggestions or fixes?

The problem was that the following code was not inserted in the form:

<% f.inputs do %>

This creates the html and now the css works.

ie the html missing was

您是否不需要将该数字转换为querysting var?

<link href="/stylesheets/formtastic.css?math=1290524609" media="screen" rel="stylesheet" type="text/css" /> 

Are you using this with Rails? If so, you could simply put this in your header:

<%= formtastic_stylesheet_link_tag %>

Also, have you run both bundle install and rails generate formtastic:install (for Rails 3, use ./script/generate formtastic for Rails 2)?

Are you sure the path is correct? if you check source with firebug check the link tag and see if its contents are a 404 error. It may be an issue with your root-relative path.

This is only a guess as I can't see how your site is structured.

Are you sure you have to begin with a forward slash ? (/)

Cause it's mean it's at the root of your domain.

Tried <link href="stylesheets/formtastic.css?1290524609" media="screen" rel="stylesheet" type="text/css" /> ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM