Jump to content

Recommended Posts

hello,

 

Let´s get straight to the point.

I have a couple of div´s

<div id="container">

<div id="page1">

<div id="page2">

<div id="page3">

<div id="page4">

<div id="page5">

<div id="page6">

 

If someone gets to page like 5 through my js code, I only want to show page5 and  container.

Soo, in css I want to select everything except container and page5.

I can't manually type in the pages because, there will be adding daily more pages.

 

note: if my english is not right or see some grammer errors, please correct me.

 

kind regards,

"mrbean"

Link to comment
https://forums.phpfreaks.com/topic/264400-multiple-not-selectors/
Share on other sites

  • 2 weeks later...

You can do this by adding an ID to your <body> tag, indicating what page you are on:

 

Ex: page 1 body tag

<body id="page_1">

 

page 5 body tag

<body id="page_5">

 

Then you give each of the containers a common class name:

<div id="page1" class="pagediv">
<div id="page2" class="pagediv">
<div id="page3" class="pagediv">
<div id="page4" class="pagediv">
<div id="page5" class="pagediv">
<div id="page6" class="pagediv">

 

Then you can set your CSS up like this:

.pagediv
{
  display:none;
}

#page_1 #page1
{
  display:block;
}

#page_2 #page2
{
  display:block;
}

#page_3 #page3
{
  display:block;
}
#page_4 #page4
{
  display:block;
}
#page_5 #page5
{
  display:block;
}

 

By doing this, you hide all the .pagedivs, and show #page1 on the div that has a body#page_1, #page2 on body#page2, and so on.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.