Ananas
Ananas

Reputation: 135

Footer CSS isn't being applied

When I write this, the word Hello appears in the top of my page instead of the bottom:

<footer> Hello </footer>

Here is the important part of my CSS file:

.footer{
    position:fixed;
    bottom:0;
    left:0;
    height:100px;
    background: black;
}

I really don't know what's wrong. I'm working under Ruby on Rails, and I'm using Pdfkit to transform my html page into pdf, but I don't think this matters.

Upvotes: 3

Views: 3270

Answers (2)

user3872094
user3872094

Reputation: 3351

In CSS replace .footer with footer and it will work and the working fiddle is here

fiddle

And just for your clarification.

In html we create tags and some of them have attributes like class and id. And below shows how you can assign CSS.

if class is attribute then you use the .

<div class="new"/>
CSS would be 
.new{}

if attribute is id then you use #

<div id="new"/>
CSS would be
#new{}

if css is directly on tag with no attriutes, directly use the tag. (This is where you were getting stuck)

<div/>
CSS would be
div{}

happy coding!!!!

Upvotes: 3

4dgaurav
4dgaurav

Reputation: 11496

Demo

footer is tag in your html not a class so

footer {
    position:fixed;
    bottom:0;
    left:0;
    height:100px;
    width: 100%;
    background: black;
}

Upvotes: 9

Related Questions