0

So suppose I have the following code:

td.topnav_link {
  padding: 5px 5px 5px 5px;
  background-color: #5babd7;
  border: 1px solid #578baf;
  cursor: default;
}

@media screen and (max-width: 500px) {
  #id_topnav_link_menu.topnav_link {
    display: block;
  }
  #id_topnav_link_about.topnav_link {
    display: hidden;
  }
  #id_topnav_link_contact.topnav_link {
    display: hidden;
  }
}

and

<td class="topnav_link" id="id_topnav_link_contact">
<a href="/contact/">contact</a>
</td>

should the "about" and "contact" not become hidden when I resize the browser down? (It does not for me when testing in a variety of browsers)

(Note: Yes, I realize I am using a td where I should not, but I am slowly converting an old layout of mine to be more CSS and more mobile)

4
  • You can't use display: none/block on table cells. Commented Aug 14, 2013 at 9:55
  • 1
    @Itay Itai: Well you can use display: none on table cells, but instead of block it should be table-cell. Commented Aug 14, 2013 at 9:57
  • @BoltClock♦: You are right. I was mistaken. Commented Aug 14, 2013 at 9:59
  • You should definitely avoid tables for layout on mobile sites. Mobile browsers have drastically different rules for handling tables. Commented Aug 14, 2013 at 10:03

1 Answer 1

3

There's no hidden value for display. It should be none. But as it is a cell, you should use visibility, which will hide the cell, but the space will still remain there:

@media screen and (max-width: 500px) {
  #id_topnav_link_menu.topnav_link {
    display: block;
  }
  #id_topnav_link_about.topnav_link {
    visbility: hidden
  }
  #id_topnav_link_contact.topnav_link {
    visbility: hidden
  }
}

Here's a list of possible values: https://developer.mozilla.org/en-US/docs/Web/CSS/display

Sign up to request clarification or add additional context in comments.

3 Comments

Sorry for mistaking you, as BoltClock♦ has told me, you can give it display: none but display: block should be replaced with display: table-cell.
I think if you set display: block on a cell it will be computed as table-cell, like inline on float is computed as block anyway.
My problem has been solved. Can't believe I made that error :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.