opacity

Discussion in 'HTML' started by windandwaves, Feb 18, 2006.

  1. windandwaves

    windandwaves Guest

    Hi Gurus

    What is the right way to set opacity in css. I use the one below, but it
    gives errors in Firefox:

    opacity:.50; filter: alpha(opacity=50); -moz-opacity: 0.50; margin: 0px;

    TIA

    Nicolaas
    PS I also posted this message to the stylesheet newsgroup
    windandwaves, Feb 18, 2006
    #1
    1. Advertising

  2. windandwaves

    Toby Inkster Guest

    windandwaves wrote:

    > opacity:.50; filter: alpha(opacity=50); -moz-opacity: 0.50; margin: 0px;


    I'm not entirely sure how the margin effects opacity, but this should do
    the trick:

    ..translucent50
    {
    opacity: 0.5; /* CSS 3, Moz, Safari, Konq, Opera 9 */
    filter: alpha(opacity=50); /* Internet Explorer 5.5+ */
    -moz-opacity: 0.5; /* Older Moz */
    -khtml-opacity: 0.5; /* Older Safari, Older Konqueror */
    }

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Feb 18, 2006
    #2
    1. Advertising

  3. windandwaves a écrit :
    > Hi Gurus
    >
    > What is the right way to set opacity in css. I use the one below, but it
    > gives errors in Firefox:
    >
    > opacity:.50; filter: alpha(opacity=50); -moz-opacity: 0.50; margin: 0px;
    >


    From the CSS validator FAQ :


    Why don't my scrollbar properties, filters, etc. validate?

    The CSS Validator validates your style sheet against some profile, e.g.
    CSS Level 1 or CSS Level 2.
    Some browser Vendors however extend these profiles by new properties
    like Microsoft did with the scrollbar-base-color or filter property or
    Mozilla with the -moz-opacity property. The Validator is not aware of
    these properties and using them makes your style sheet invalid in terms
    of the CSS specifications. _Either get rid of those properties or live
    with the fact, that your style sheets don't validate._ _You cannot have
    both._


    --
    Julien CROUZET - DSI Theoconcept
    julien.crouzet@/enlever ca\theoconcept.com
    http://www.theoconcept.com
    Julien CROUZET, Feb 18, 2006
    #3
  4. windandwaves

    Toby Inkster Guest

    Julien CROUZET wrote:

    > _You cannot have both._ [proprietary CSS and valid CSS]


    Actually, you probably can.

    There are numerous documented bugs in browser CSS parsers. By tripping the
    right ones, you should be able to trick the browsers into reading some
    proprietary CSS properties which are really within a CSS comment.

    e.g. IE 5.x for Mac will apply this:

    /* \*/ /* div{property:value;} */

    though a standards-compliant browser should treat it as a comment (as
    indeed all other CSS rendering engines seem to) and the CSS validator
    should pass it OK.

    Not that I'd recommend that in most circumstances.

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Feb 18, 2006
    #4
  5. windandwaves

    Jim Higson Guest

    Toby Inkster wrote:

    > Julien CROUZET wrote:
    >
    >> _You cannot have both._ [proprietary CSS and valid CSS]

    >
    > Actually, you probably can.
    >
    > There are numerous documented bugs in browser CSS parsers. By tripping the
    > right ones, you should be able to trick the browsers into reading some
    > proprietary CSS properties which are really within a CSS comment.
    >
    > e.g. IE 5.x for Mac will apply this:
    >
    > /* \*/ /* div{property:value;} */
    >
    > though a standards-compliant browser should treat it as a comment (as
    > indeed all other CSS rendering engines seem to) and the CSS validator
    > should pass it OK.


    Since standards compliant browsers ignore rules they doesn't understand
    anyway, this seems like validation for it's own sake. And a nightmare to
    maintain.

    > Not that I'd recommend that in most circumstances.


    I agree :)
    Jim Higson, Feb 20, 2006
    #5
  6. On Mon, 20 Feb 2006, Jim Higson wrote:

    > Since standards compliant browsers ignore rules they doesn't
    > understand anyway, this seems like validation for
    > it's own sake.

    [1]

    There's something in what you say. But if your documents are full of
    deliberate non-standard items, you practically lose the ability to use
    the validators and checkers for finding non-deliberate errors.

    I got myself into just that position only yesterday, in putting ruby
    annotation into what was otherwise a valid HTML/4.01 Strict document.
    And did just what I'm warning about - at first I missed a real mistake
    in the markup. (At least in this situation one could validate against
    a custom DTD, and if I decided to go seriously into that, it's what I
    would do. But for a one-off hack...)

    cheers


    [1] news:alt.possessive.its.has.no.apostrophe
    Alan J. Flavell, Feb 20, 2006
    #6
  7. Après mûre réflexion, Toby Inkster a écrit :
    > Julien CROUZET wrote:
    >
    >> _You cannot have both._ [proprietary CSS and valid CSS]

    >
    > Actually, you probably can.
    >


    Actually, I think it's :

    _You cannot have both._ [proprietary CSS and your sheet validates]

    CSS validation, like any validation, is strict like we want it to.


    --
    Julien CROUZET - DSI Theoconcept
    julien.crouzet@/enlever ca\theoconcept.com
    http://www.theoconcept.com
    Julien CROUZET, Feb 21, 2006
    #7
  8. windandwaves

    Jim Higson Guest

    Alan J. Flavell wrote:

    > On Mon, 20 Feb 2006, Jim Higson wrote:
    >
    >> Since standards compliant browsers ignore rules they doesn't
    >> understand anyway, this seems like validation for
    >> it's own sake.

    > [1]
    >
    > There's something in what you say. But if your documents are full of
    > deliberate non-standard items, you practically lose the ability to use
    > the validators and checkers for finding non-deliberate errors.


    I'd only ever do this for CSS. XHTML validation is still important.

    > I got myself into just that position only yesterday, in putting ruby
    > annotation into what was otherwise a valid HTML/4.01 Strict document.
    > And did just what I'm warning about - at first I missed a real mistake
    > in the markup. (At least in this situation one could validate against
    > a custom DTD, and if I decided to go seriously into that, it's what I
    > would do. But for a one-off hack...)


    For CSS, I just run it through a flex/bison parser to test the syntax. Seems
    to work ok. Also, my text editor (kate) is very good at showing bad CSS
    syntax.

    What I like to do, btw is use server-side PHP to generate stylesheets, and
    then run a little shell script to grab the output and turn it back into a
    static file.

    I also have a little Perl script that strips out whitespace and comments, so
    I can write loads of explanations without worrying too much about inflating
    the filesize.

    --
    Jim
    Jim Higson, Feb 21, 2006
    #8
  9. windandwaves

    windandwaves Guest

    Jim Higson wrote:
    > Alan J. Flavell wrote:
    >
    >> On Mon, 20 Feb 2006, Jim Higson wrote:
    >>
    >>> Since standards compliant browsers ignore rules they doesn't
    >>> understand anyway, this seems like validation for
    >>> it's own sake.

    >> [1]
    >>
    >> There's something in what you say. But if your documents are full of
    >> deliberate non-standard items, you practically lose the ability to
    >> use the validators and checkers for finding non-deliberate errors.

    >
    > I'd only ever do this for CSS. XHTML validation is still important.
    >
    >> I got myself into just that position only yesterday, in putting ruby
    >> annotation into what was otherwise a valid HTML/4.01 Strict document.
    >> And did just what I'm warning about - at first I missed a real
    >> mistake in the markup. (At least in this situation one could
    >> validate against a custom DTD, and if I decided to go seriously into
    >> that, it's what I would do. But for a one-off hack...)

    >
    > For CSS, I just run it through a flex/bison parser to test the
    > syntax. Seems to work ok. Also, my text editor (kate) is very good at
    > showing bad CSS syntax.
    >
    > What I like to do, btw is use server-side PHP to generate
    > stylesheets, and then run a little shell script to grab the output
    > and turn it back into a static file.


    what editor do you use for writing the PHP. I like to edit my css in a css
    editor, but if I turn it into a PHP file I can not...

    > NIcolaas
    windandwaves, Feb 23, 2006
    #9
  10. windandwaves wrote:

    <snip>
    > what editor do you use for writing the PHP. I like to edit my css in a css
    > editor, but if I turn it into a PHP file I can not...


    I like Crimson Editor(Win32 freeware), beaucoup syntax highlighting
    files and you can make custom ones as well

    http://www.crimsoneditor.com/


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Feb 23, 2006
    #10
  11. windandwaves

    Jim Higson Guest

    windandwaves wrote:
    >>
    >> What I like to do, btw is use server-side PHP to generate
    >> stylesheets, and then run a little shell script to grab the output
    >> and turn it back into a static file.

    >
    > what editor do you use for writing the PHP. I like to edit my css in a
    > css editor, but if I turn it into a PHP file I can not...


    Kate, which is part of KDE.
    Any standards it doesn't support with highlighting, I make my own
    highlighting spec and send into the project. Not very difficult at all.
    Jim Higson, Feb 26, 2006
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nebojsa Dinic

    JPanel transparency (opacity)

    Nebojsa Dinic, Apr 16, 2004, in forum: Java
    Replies:
    0
    Views:
    3,314
    Nebojsa Dinic
    Apr 16, 2004
  2. DU
    Replies:
    13
    Views:
    922
  3. Sentient Fluid

    Opacity

    Sentient Fluid, Apr 22, 2005, in forum: HTML
    Replies:
    0
    Views:
    564
    Sentient Fluid
    Apr 22, 2005
  4. Jim Higson

    What is -khtml-opacity for?

    Jim Higson, Mar 4, 2006, in forum: HTML
    Replies:
    3
    Views:
    9,706
    Toby Inkster
    Mar 5, 2006
  5. Just Me

    2005 Menu DynamicMenuItem opacity

    Just Me, Jan 21, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    297
    Just Me
    Jan 21, 2007
Loading...

Share This Page