SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot
    Join Date
    Mar 2012
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSS vs. PHP Slideshow

    Hi all,

    I will be making a slideshow, and although I was already aware that it can be done via PHP, I recently discovered that it can also be done with CSS.

    Initially, I was planning to do the slideshow in PHP, but now that I know it can also be done in CSS, I'm confused as to which route I should take.

    As I've recently entered the world of CSS, when I realized the slideshow can be done in CSS, this made me want to do the slideshow in CSS--mainly because I'm intrigued by CSS and am just finding CSS to have so many delightful surprises.

    However, upon further thought, I questioned myself as to whether or not it would actually be better to stick to PHP rather than CSS for the slideshow. The main reason I am thinking that PHP would actually be preferable in this regard is because in PHP, I will not have to worry about browser compatibility or display issues (unless I'm mistaken about this).

    I do not know if this reason is valid enough, or whether it is in fact better to do the slideshow in PHP opposed to CSS.

    I'd really appreciate hearing the advice that anyone here has to offer on this: would it be preferable to do a slideshow in CSS or PHP?

    Thanks!

    - Pam

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,112
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    PHP and CSS are not alternatives to each other. PHP happens on your web server, and CSS happens in your web browser. So your browser doesn't know anything about what happens in PHP. As far as it is concerned, you just send it some images and some CSS styles for presenting those images on the page. If you don't use CSS, the page will be completely plain.

    You can do a simple slideshow with CSS, or a more complex one with JavaScript. The only use for PHP in this situation is how you organize and serve up the images when the page is loaded.

    Perhaps let us know what kind of slideshow you want and we can make suggestions.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  3. #3
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,791
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    This is a case of hammering with a screwdriver.
    PHP can write the mark up, and I suppose output the CSS for a slide show, but PHP itself doesn't make the sideshow.

    As ralph said you can style your mark up ( which will probably be a UL, OL, or series of nested DIVs) with CSS or js to get the desired slide show effect. And while using CSS3 may cut down on crossbrowser friendliness, it may eliminate the need for js for those "complex" effects.

    Technically speaking, you could do a sideshow in pure HTML ( static) and CSS3 with no .js IF you hand coded all the content, as opposed to having PHP build and serve it as needed. This would SUCK for slow bandwidth, tho.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,112
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    This is a cool slider powered by JS, but which also slides thanks to CSS3 if JS is off:

    http://wowslider.com/wordpress-galle...ck-v-demo.html

    (The CSS3 version won't work in all browsers, though.)
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  5. #5
    Life is not a malfunction gold trophysilver trophybronze trophy
    TechnoBear's Avatar
    Join Date
    Jun 2011
    Location
    Argyll, Scotland
    Posts
    6,085
    Mentioned
    255 Post(s)
    Tagged
    5 Thread(s)
    Quote Originally Posted by ralph.m View Post
    This is a cool slider powered by JS, but which also slides thanks to CSS3 if JS is off:

    http://wowslider.com/wordpress-galle...ck-v-demo.html

    (The CSS3 version won't work in all browsers, though.)
    That's really nifty - except it doesn't have a pause button. Am I just not looking carefully enough?
    Take plenty of exercise walk round and round the garden
    or
    sign up now for the Isle of Jura 10K or Half Marathon!

  6. #6
    SitePoint Zealot
    Join Date
    Mar 2012
    Posts
    110
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the helpful information, Ralph and Ray!

    Quote Originally Posted by ralph.m View Post
    PHP and CSS are not alternatives to each other. PHP happens on your web server, and CSS happens in your web browser. So your browser doesn't know anything about what happens in PHP. As far as it is concerned, you just send it some images and some CSS styles for presenting those images on the page. If you don't use CSS, the page will be completely plain.

    You can do a simple slideshow with CSS, or a more complex one with JavaScript. The only use for PHP in this situation is how you organize and serve up the images when the page is loaded.

    Perhaps let us know what kind of slideshow you want and we can make suggestions.
    Quote Originally Posted by dresden_phoenix View Post
    This is a case of hammering with a screwdriver.
    PHP can write the mark up, and I suppose output the CSS for a slide show, but PHP itself doesn't make the sideshow.

    As ralph said you can style your mark up ( which will probably be a UL, OL, or series of nested DIVs) with CSS or js to get the desired slide show effect. And while using CSS3 may cut down on crossbrowser friendliness, it may eliminate the need for js for those "complex" effects.

    Technically speaking, you could do a sideshow in pure HTML ( static) and CSS3 with no .js IF you hand coded all the content, as opposed to having PHP build and serve it as needed. This would SUCK for slow bandwidth, tho.
    This slideshow will be a very simple slideshow with each image simply fading/dissolving into the next one after a constant specified duration. Each image would be a link as well. It would be nice to have the slideshow pause at the current slide upon hover over, but not essential as long as I'm able to have forward/backward arrows.

    What I had previously mistakenly thought was a PHP slideshow turns out to actually have Javascript as I now see after more closely inspecting the code! The only reason I had previously been considering using that one is because I had thought it was entirely PHP.

    So given this new information from you guys, I suppose the correct thing I should be asking about is "CSS vs. Javascript Slideshow".

    Despite Javascript's (and Jquery's especially) very nice effects when it comes to this kind of thing and other things, I still have this kind of anti-Javascript way of thinking for the reason that the visitor may have Javascript disabled. I do not know if it is correct for me to have this mindset or if it is an ancient mentality?

    Quote Originally Posted by ralph.m View Post
    This is a cool slider powered by JS, but which also slides thanks to CSS3 if JS is off:

    http://wowslider.com/wordpress-galle...ck-v-demo.html
    That is a cool slider! Thanks, I've bookmarked it as I'm quite certain it will come in handy for different future projects.

    As a side question, since PHP is still in the air here, for things that you can do in either HTML or PHP, is it preferable to use HTML in such cases instead of PHP? And if so, would this reason be because using HTML rather than PHP would be faster for the visitor as they won't have to wait for processing from the server, as well as being easier on the server? An example of what I mean is:

    HTML
    Code:
    <html>Hello world</html>
    vs.

    PHP
    Code:
    <?php echo "Hello world"; ?>
    Thanks!

    - Pam

  7. #7
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,112
    Mentioned
    448 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by TechnoBear View Post
    it doesn't have a pause button.
    An unfortunate limitation indeed. So the search for the perfect slider goes on ... (if there is such a thing, as I'm not too keen on sliders at the bet of time).


    Quote Originally Posted by Pamela1991 View Post
    I still have this kind of anti-Javascript way of thinking for the reason that the visitor may have Javascript disabled. I do not know if it is correct for me to have this mindset or if it is an ancient mentality?
    No, it's a very healthy mentality.

    The important thing to consider is what happens if JS is off. If the content is still accessible, then it's fine, IMHO. For example, imagine a gallery of thumbnails that expand and hover over the page when clicked. With JS off, the thumbnails should still appear, and when you click on you get taken to the enlarged version on a separate page. Perfectly acceptable.

    Likewise, if you have images in a slider, with JS off you should at least be able to manually scroll sideways to see the other images. (This can often easily be set up via CSS if the slider code doesn't come with this feature.)

    for things that you can do in either HTML or PHP, is it preferable to use HTML in such cases instead of PHP? And if so, would this reason be because using HTML rather than PHP would be faster for the visitor as they won't have to wait for processing from the server, as well as being easier on the server?
    In my experience, PHP is very fast, so I don't see a problem in using it ... as long as it's not over used. The hello world example probably is overkill. I mainly use PHP for "includes", where common information like the HTML for your header, footer and menu is stored in one place and pulled onto each page. Then you can modify them in one place and not have to update each page.
    Facebook | Google+ | Twitter | Web Design Tips | Free Contact Form

    Forum Usage: Tips on posting code samples, images and more

    Forrest Gump: "IE is like a box of chocolates: you never know what you're gonna get."

  8. #8
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You use php to write the html of a web page. Often from a database interaction.
    So apart from includes giving you a bit of re-usable, edit once use many times, code, you need a reason to use php to write the html. PHP isn't a substitute for html. It's an extra step in creating the html. In the case of a database driven site, it's a must. But for an ordinary web site it is usually an extra step.


Tags for this Thread

Bookmarks

Posting Permissions

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