• 0

CSS Not Loading


Question

Hi guys, I'm starting a Ruby on Rails web app for my class but I can't get my CSS to work.

Here is my HTML:


<!DOCTYPE html>
<html>
<head>
<title>Welcome</title>
<meta charset='utf-8'>
<link href='~/css/styles.css' rel='stylesheet'>
<link href='http://fonts.googleapis.com/css?family=Arvo:400,700' rel='stylesheet' type='text/css'>
</head>
<body>
<div id='wrapper'>
<div id='header'>
<h1>Welcome</h1>
</div>
<div id='content'>
<h2>The new magic number is 80</h2>
</div>
<div id='footer'>
<h4>Daniel </h4>
</div>
</div>
</body>
</html>
[/CODE]

And here is my CSS:

[CODE]
wrapper, header, content, footer {
display: block;
}
#wrapper{
width:66%;
margin:auto;
}

#header{
background-color:#FFCA00;
font-family: 'Arvo', serif;
font-weight: 700;
font-size: 22px;
color: #A68300;
border-bottom:solid 1px #FFE273;
}
#content{
background-color: #FFD740;
font-size: 16px;
font-family: 'Arvo', serif;
font-weight: 400;
color: #A68300;
margin:12px 0;
float:left;
}

#footer{
background-color:#FFCA00;
font-size: 12px;
font-family: 'Arvo', serif;
font-weight: 400;
color: white;
border-top:solid 1px #FFE273;
}

[/CODE]

What is wrong with it? I have validated both files and they seem to be OK.

Thank you!

Link to comment
https://www.neowin.net/forum/topic/1056240-css-not-loading/
Share on other sites

11 answers to this question

Recommended Posts

  • 0

Get rid of the ~/ as people have said. Which version of Rails are you using, what environment are you running in, and where are your CSS files located?

Rails 3.1 introduced a new asset pipeline, your assets generally go in /app/assets rather than /public/assets. Also, use stylesheet_link_tag so you can utilize the asset pipeline (it will locate the asset for you and minify/compress it if in production mode).

  • 0

Just a note since I stumbled across this while searching for something else.

All of the answers in this thread are correct for HTML. However with RoR you are better off using the stylesheet link tag.

<%= stylesheet_link_tag :all %> will link all stylesheets in public/stylesheets.

or,

<%= stylesheet_link_tag "style" %>

This will generate <link href="/stylesheets/style.css?1337517391" media="screen" rel="stylesheet" type="text/css" />

notice the ?1337517391? The main benefit of using the link tags are the provided cache busting techniques. This is simply the timestamp of the file. If you modify your CSS file it will update the timestamp thus forcing any browsers caching CSS to update.

There are link tags for images and javascript files as well which provide the same benefits.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • HomeBank 5.10.1 by Razvan Serea HomeBank is a free software (as in "free speech" and also as in "free beer") that will assist you to manage your personal accounting. It is designed to easy to use and be able to analyse your personal finance and budget in detail using powerful filtering tools and beautiful charts. If you are looking for a completely free and easy application to manage your personal accounting, budget, finance then HomeBank should be the software of choice. HomeBank also benefits of more than 19 years of user experience and feedback, and is translated by its users in around 56 languages. Highlights: Cross platform, supports GNU/Linux, Microsoft Windows, Mac OS X Import easily from Intuit Quicken, Microsoft Money or other software Import bank account statements (OFX, QIF, CSV, QFX) Duplicate transaction detection Automatic cheque numbering Various account types : Bank, Cash, Asset, Credit card, Liability Scheduled transaction Category split Internal transfer Month/Annual budget Dynamic powerful reports with charts Automatic category/payee assignment Vehicule cost HomeBank 5.10.1 changelog: change: the input field helper icon + fixed some spacing inconsistency change: transaction, added some missing input tooltips and reworked existing change: category, payee and tag window add input now have a tooltip and button change: split window, refactored the layout change: split window, add display of memo and date wish : #2106800 budget report option to exclude transfers from unbudgeted line bugfix: prevent deletion of non pending transaction when rejecting bugfix: transaction warning for no rate faultly showing in transfer bugfix: report missing space for filter tooltip icon bugfix: budget report missing filter tooltip bugfix: manage account closed icon was hidding budget icon bugfix: #2154771 view transcations requires hitting Escape or X twice to close dialog bugfix: #2154337 transfer to/from closed account with different currency don't show the amount bugfix: #2154234 scheduled transaction recurring pattern daily value limited to 100 bugfix: #2149897 view split for closed accounts bugfix: #2148561 global time chart do not shows current period by default bugfix: #2148456 the main screen Total Chart is no longer showing an overall total bugfix: #2147497 editing a transaction resets scroll position bugfix: #2147377 balance mixup with transaction same day sort by amount bugfix: #2147052 quarter are wrong when fiscal year is jan 1 bugfix: #2147048 all events for the month are late but today is only the 1st bugfix: #2144993 impossible to search for transactions by value for values >999,99 bugfix: #2144698 adding new Category/Payee/Tags requires hitting -Enter- bugfix: #2144419 QIF Account name detection fail on import bugfix: #2142349 can't delete account groups bugfix: #2139409 account maximum limit is not fully used (example credit card) bugfix: #2133783 transfers shouldn't add to dashboard top spending reports Download: HomeBank 5.10.1 | 20.5 MB (Open Source) Download: 3rd party packages (macOSX. Ubuntu...etc) View: HomeBank Website | Support | Features | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Same, price was right for my Home, laptop, phone. Works great!
    • Brave and Firefox. I’ve been using them as my primary browsers for a while now, perfect combo
    • They want Ring 0 access. Should be a hard no. A middle ground needs to be found.
  • Recent Achievements

    • Experienced
      JayZJay went up a rank
      Experienced
    • Reacting Well
      Sir_Timbit earned a badge
      Reacting Well
    • Week One Done
      rubentuben8 earned a badge
      Week One Done
    • Week One Done
      ARaclen earned a badge
      Week One Done
    • Week One Done
      jojodbn earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      524
    2. 2
      PsYcHoKiLLa
      232
    3. 3
      Edouard
      135
    4. 4
      ATLien_0
      88
    5. 5
      Steven P.
      83
  • Tell a friend

    Love Neowin? Tell a friend!