Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: PHP and CSS

  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    311
    Thanks
    0
    Thanked 1 Time in 1 Post

    PHP and CSS

    how can I change the style of this code to align 10px to the right?

    PHP Code:
    echo " <span class=\"leftfloat\">$artist_name_next[$i] </span>" 
    I tried adding Style='left:10px;' but that didn't take.

    Any suggestions. CSS and PHP together give me a headache sometimes

  • #2
    Regular Coder thesmart1's Avatar
    Join Date
    Dec 2005
    Posts
    369
    Thanks
    7
    Thanked 3 Times in 3 Posts
    I think you need to set a positioning type:

    position:relative;

    (Or instead of relative you could use absolute, fixed, or float, depending on what you need. See W3Schools' artice on this for more information.)

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,095
    Thanks
    11
    Thanked 101 Times in 99 Posts
    PHP and CSS have nothing to do with each other, PHP outputs HTML with may include CSS but its not a PHP issue, view the source of the PHP output (the HTML) and debug that instead.

    PS: if $i is not an integer you need to add some braces or concatenate (I suggest using braces anyway)
    PHP Code:
    <?php
    echo " <span class=\"leftfloat\">{$artist_name_next[$i]} </span>";  
    ?>
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    New to the CF scene
    Join Date
    Apr 2007
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, PHP is not the problem, for that matter you could just say
    PHP Code:
    <span class="leftfloat"><?php echo($artist_name_next[$i]);?></span>
    If you want to move it to the right by 10px without using absolute positioning you should give it a margin-left:10px; in the CSS.
    Last edited by Umang; 04-21-2007 at 01:15 PM. Reason: typo


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •