Forums

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

Home Forums CSS Make div disappear with CSS media queries on screen width.

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #43380
    Anonymous
    Inactive

    How do i make a div/image disappear when the screen reaches a certain width using media queries?

    #128239
    Paulie_D
    Member

    Disappear how?

    Remove it from the DOM or just hide it?

    #128259
    Kitty Giraudel
    Participant

    I don’t think he means removing from the DOM. Anyway, that couldn’t be done. But you could hide it.

    @media (max-width: 40em) {
    .element {
    display: none;
    }
    }

    #128288
    Paulie_D
    Member

    >I don’t think he means removing from the DOM. Anyway, that couldn’t be done

    With JS you could…couldn’t you?

    #128291
    devil3682116
    Participant

    @media (max-width: 40em) {
    img {
    visibility:hidden;
    }
    }
    also works…you can simply give the width…here “max-width” means devices less than width of or equal to…

    #128292
    Paulie_D
    Member

    display:none

    is not the same as

    visibility:none

    http://codepen.io/Paulie-D/pen/39b45717797e5d4068d87de01c949386

    #128317
    CrocoDillon
    Participant

    > With JS you could…couldn’t you?

    That would be too easy.

    #128339
    Kitty Giraudel
    Participant

    > With JS you could…couldn’t you?

    Very easily, but that would require JS to do something you could (and have to) do with CSS only (Media Queries).

    #128535
    devil3682116
    Participant

    @Paulie_D : got it! thanks :(

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