Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS showing a Div in the home page only ?

  • This topic is empty.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #45403

    hello everyone ..

    i’am trying to type a code that let me show a div only in the main page (index) , so if any visitors visits a second page .. the div will disappear.

    BTW i’am doing this on tumblr , so i guess there is an easy way to do it with some {block:thingy} code ?

    #138128
    Jozsef K.
    Participant

    HTML: <body id=”home”>

    CSS: #home .yourdiv {display:none}

    #138131
    Senff
    Participant

    The body on the home page already has a class “home” by default.

    [EDIT: not true — see below.]

    So you could simply do this in your CSS:

    .somediv {display:none;}
    body.home .somediv {display:block;}

    #138133

    unfortunately tumblr is using one templates , not a several pages .. so i can’t use this way because the body class will be applied to all of my blog pages , that’s mean it will appear in all the pages

    #138134
    Senff
    Participant

    Hmm…. I thought it was a default setting for Tumblr to add the class “home” to the main page, but I just noticed that’s not the case. I looked at some old Tumblr thing I once did and it turns out that the home class was added with some nifty jQuery.

    OK well, try this then:

    {block:IndexPage}

    This will only show on the index page.

    {/block:IndexPage}

    #138149

    Senff i tried this code at the first , but for some reason it didn’t do the job

    and more ideas guys :( ?

    #138173
    Senff
    Participant

    @7imaginary: strange — as it’s very basic Tumblr code. I just tried it in my very super basic theme and it does work: http://senff.tumblr.com/

    #138178
    Jozsef K.
    Participant

    Maybe your div has an inline style applied to it, like style=”display:none”

    #138769

    any more suggestion guys ?

    #138775

    i finally found the answer while searching :

    #box{
    display:none;
    }

    .page1 #box{
    display:block;
    }

    Only displayed in first page.

    {CurrentPage} is a tumblr variable that’s hold the page number

    thank all of you guys for helping me :)

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘CSS’ is closed to new topics and replies.