facebook

CSS Formatting with media designator

  1. MyEclipse Archived
  2.  > 
  3. Web Development (HTML, CSS, etc.)
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #247114 Reply

    rogue_dev
    Member

    I have the following CSS snippet

    @media print {
    /* Document Body */
    body {
      color: #000000;
      background-color: #ffffff;
      font-family: arial, helvetica, sans-serif;
    }
    }

    Pressing CTRL-SHIFT-F for format produces:

    @media
    print
    {
    /* Document Body */
    body {
      color: #000000;
      background-color: #ffffff;
      font-family: arial, helvetica, sans-serif;
    }
    }

    Pressing CTRL-SHIFT-F again produces:

    @media print { /* Document Body */
      body {
        color: #000000;
        background-color: #ffffff;
        font-family: arial, helvetica, sans-serif;
     }
    }

    In addition all blank lines are removed, rather than a blank line between classes.

    #247124 Reply

    Riyad Kalla
    Member

    Using 4.1, I got this after formatting your first sample:

    
    @media print { /* Document Body */
        body {
            color: #000000;
            background-color: #ffffff;
            font-family: arial, helvetica, sans-serif;
        }
    }
    
    #247137 Reply

    rogue_dev
    Member

    Ecplise 3.1, MyEcplise 4.1.0GA.

    Ok, in your code snippet, place the cursor just after the curly brace after the word print. Press ENTER (this will place the comment on its own line). Then CTRL-SHIFT-F. This happens consistently on my system.

    At any rate, the comment should be just above the class name on its own line, not following the curly brace. And there should be a blank line between classes. This would follow the formatting already used if the media designator is not there.

    With my live CSS file (over 500 lines, 50+ classes), I also get a strange visual effect. During the time that the formatter is working, the “body {” line disappears. Once the formatter has finished it appears again. Ths is on a 2.4GHz machine with 1G RAM.

    #247141 Reply

    Riyad Kalla
    Member

    Press enter after curley

    
    @media print {
        
    /* Document Body */
    body {
      color: #000000;
      background-color: #ffffff;
      font-family: arial, helvetica, sans-serif;
    }
    }
    

    format

    
    @media
    print
    {
    /* Document Body */
    body {
        color: #000000;
        background-color: #ffffff;
        font-family: arial, helvetica, sans-serif;
    }
    }
    

    BUT, if I format again, I get:

    
    @media print { /* Document Body */
        body {
            color: #000000;
            background-color: #ffffff;
            font-family: arial, helvetica, sans-serif;
        }
    }
    

    I will file this, but first please provide us with the exact way the file “should” look, I want to make sure we have a test case.

    #247150 Reply

    rogue_dev
    Member

    Ok, the way it “should” look is the way that it formats without a media designator. Except that everything is indented one level:

    @media print
    {
      /* comment */
      class_name
      {
        key: value;  /* comment */
        key: value;
      }
    
      /*
        multi-line
        comment
      */
      class_name
      {
        key: value;
        key: value;
      }
    }

    Note that I prefer curly braces to start on their own line 🙂

    #247263 Reply

    rogue_dev
    Member

    Another thing.

    If I have my CSS organized into sections, then I usually put a comment naming the section

    /*
      ***********************
      table cells
      ***********************
    */
    
    /* this is a number cell */
    .table_cell_number
    {
      text-align: right;
    }

    After a format, this becomes

    /*
      ***********************
      table cells
      ***********************
    */ /* this is a number cell */
    .table_cell_number
    {
      text-align: right;
    }

    I think that the formatter should respect blank lines between successive comment blocks.

    #247267 Reply

    Riyad Kalla
    Member

    I believe this is already filed, if not, I’ll file it.

Viewing 7 posts - 1 through 7 (of 7 total)
Reply To: CSS Formatting with media designator

You must be logged in to post in the forum log in