Author Topic: Restrict styllesheet.css to one single table or table cell  (Read 5791 times)

0 Members and 1 Guest are viewing this topic.

Offline Fere

  • Newbie
  • *
  • Posts: 19
  • echo "Hello world!"
    • View Profile
    • www.aribrushart.ro
Restrict styllesheet.css to one single table or table cell
« on: January 17, 2009, 11:36:44 PM »
OK guys don't ban me, but I really need an answer to this question even though it's not related directy with 4images, but it is for a site that uses bouth 4images and phpBB. Here's the exact same post on phpBB comunnity forum on which I haven't yet received an answer:

Quote



After six hours of investigating site behavior and reading forum topics I discovered that I must purge cache or disable it at all to see anny kind of change in style. I was really puzzled why even with all the files from template deleted the forum was working fine ...

After that, I tryed again my modifications and I have got it working. I've returned to acidtechgreen style and modified it on ColorizeIt to best fit my own site. The colour scheme looks gorgeous. I'm really happy with the result.

Allthough the frame works I've got one big problem:

Because the styllesheet.css affects all the page including my own design every link (text/imge) has an ofset of 2 pixels. Forum table needs it, site table doesn't so the solution would be to restrict styllesheet .css only to the center table wich is depicted in the last image. The problem is that I've done some research on google but I can't find anny solution...

Waiting for your solutions. Thanks!

Edited:
Because offseting ocurs only on links(image buttons in my case) I thought that other solution could be to create a new class in stylesheet.css for buttons or links, don't know which one of them, with offset pading or whatever set to zero. Problem is that CSS is not my speciality and I need someone to help me with the code.

Here's the script from between head tags that drives the buttons:
Code: [Select]

    <script language="Javascript" type="text/javascript">
      <!--
     
      function button_toggle(button, bsrc)
      {
        button.src = bsrc;
      }
     
      //-->
    </script>


and here's the code from body:

Code: [Select]

<table  width="477" border="0" cellspacing="0" cellpadding="0">
 <tr height="200">
  <td width="95" >

      <a href="http://www.example.com">
      <img src="./images/b1a.gif" border="0" style="width: 95px; height: 200px;"
           onmouseover="button_toggle(this, './images/b1b.gif');"
           onmouseout="button_toggle(this, './images/b1a.gif');"/></a>

  </td>
 </tr>
</table>










Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Restrict styllesheet.css to one single table or table cell
« Reply #1 on: January 18, 2009, 02:23:50 AM »
If I'm not mistaken each element inherit style from it's parent element, unless new style specified in the child element.

So, what you need to do is either don't use "global" style for elements (i.e. DIV {...}, TABLE {...}) but use custom classes for each element.
Also, if you "have to" use global style, you can create a custom classes and use them to override global style.


Take a look at this example:
Code: [Select]
<head>
  <style>
    BODY{
      background: #F9F8D2;
      color: green;
    }
    DIV{
      background-color: red;
      color: blue;
    }
    .custom_div{
      text-decoration: line-through;
    }
    .custom_div2{
      background-color: transparent;
      color: black;
    }
    .custom_div3{
      background-color: white;
      color: black;
    }
    .custom_div4{
      background-color: inherit;
      color: inherit;
      font-wieght: inherit;
    }
  </style>
</head>
<body>
  <pre>
Text without DIV:
BODY{
  background: #F9F8D2;
  color: green;
}
<div>Text in DIV without class specified. This is "global" style for background and text color for all DIV. All DIV will use this style unless overriden.
DIV{
  background-color: red;
  color: blue;
}
</div>
<div class="custom_div">Text in DIV with custom_div class, colors are used from "global" style for DIV:
.custom_div{
  text-decoration: line-through;
}
</div>
<br />
<div class="custom_div2">Text in DIV with custom_div2 class. Since background color is "transparent" it will be the same as in parent, in this case as in BODY:
.custom_div2{
  background-color: transparent;
  color: black;
}
</div>
<div class="custom_div3">Text in DIV with custom_div3 class. This class overrided background and font colors from "global" style for DIV:
.custom_div3{
  background-color: white;
  color: black;
}
</div>
<br />
<div class="custom_div4">Text in DIV with custom_div4 class:
.custom_div4{
  background-color: inherit;
  color: inherit;
  font-wieght: inherit;
}
  </div>
</pre>
  <br />
  <div><div class="custom_div3">Text in DIV with custom_div3 class inside a DIV without any specific style class (uses global DIV style)</div></div>
  <br />
  <div><div.custom_div4>Text in DIV with custom_div4 class inside a DIV with "global" DIV style</div></div>
</body>
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)