Jump to content

Multiple not selectors


mrbean

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.