CSS - Is THIS Possible?

Discussion in 'HTML' started by Roy Schestowitz, Dec 5, 2004.

  1. In my CSS I included the following:


    #Div_png_top {
    font-size: 40px;
    text-align: center;
    position:fixed;
    top:10px;
    right: 300px;
    background:url(/IMG/blog_css/up.png) no-repeat top left;
    width:50px;
    height:50px;
    }


    My question is: can the line

    right: 300px;

    be replaced so that the object always appears in the _center_? I tried many
    things to no avail.

    Thanks in advance,
    Roy
    Roy Schestowitz, Dec 5, 2004
    #1
    1. Advertising

  2. Roy Schestowitz wrote:
    > In my CSS I included the following:
    >
    >
    > #Div_png_top {
    > font-size: 40px;
    > text-align: center;
    > position:fixed;
    > top:10px;
    > right: 300px;
    > background:url(/IMG/blog_css/up.png) no-repeat top left;
    > width:50px;
    > height:50px;
    > }
    >
    >
    > My question is: can the line
    >
    > right: 300px;
    >
    > be replaced so that the object always appears in the _center_? I tried many
    > things to no avail.
    >
    > Thanks in advance,
    > Roy


    Try putting <center> and </center> tage before and after the div in your
    markup!

    --
    http://www.paradisa.net - my site, visit it!
    King of Red Lions, Dec 5, 2004
    #2
    1. Advertising

  3. Roy Schestowitz

    Spartanicus Guest

    Roy Schestowitz <> wrote:

    >#Div_png_top {
    > font-size: 40px;
    > text-align: center;
    > position:fixed;
    > top:10px;
    > right: 300px;
    > background:url(/IMG/blog_css/up.png) no-repeat top left;
    > width:50px;
    > height:50px;
    >}
    >
    >My question is: can the line
    >
    >right: 300px;
    >
    >be replaced so that the object always appears in the _center_? I tried many
    >things to no avail.


    It can only be done properly if you set the width as a percentage of the
    containing block's width, for example:

    width:20%;right:40%;left:40%;

    It needs to total to 100%.

    --
    Spartanicus
    Spartanicus, Dec 5, 2004
    #3
  4. King of Red Lions wrote:

    >> position:fixed;


    > Try putting <center> and </center> tage before and after the div in your
    > markup!


    The center element is deprecated and should not used. It would have no
    effect anyway given the CSS applied.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Dec 5, 2004
    #4
  5. Roy Schestowitz wrote:

    > My question is: can the line
    > right: 300px;
    > be replaced so that the object always appears in the _center_?


    right: 50%; /* Half the containing block */
    margin-right: -25px; /* Half the width of the element */

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
    David Dorward, Dec 5, 2004
    #5
  6. Thank you David and Spartanicus for good suggestions. I didn't know
    percentages were legal in CSS, but now I know they are...

    Roy
    Roy Schestowitz, Dec 6, 2004
    #6
    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. Markus
    Replies:
    1
    Views:
    457
    Markus
    Nov 22, 2005
  2. M Hedges
    Replies:
    4
    Views:
    858
    M Hedges
    Feb 15, 2004
  3. Erik Harris

    CSS: Two background images possible?

    Erik Harris, Mar 4, 2004, in forum: HTML
    Replies:
    17
    Views:
    55,554
    Erik Harris
    Mar 5, 2004
  4. Replies:
    4
    Views:
    282
    Kenny McCormack
    Feb 21, 2006
  5. Replies:
    10
    Views:
    473
    Chris Gonnerman
    Dec 14, 2007
Loading...

Share This Page