/    Sign up×
Community /Pin to ProfileBookmark

Round corners using DIVS (no tables or images)

I made a script that produces pure HTML to get a round corner effect.
get the code from the url below and please leave feedback if you find something which could be done better, im sure there is ? …

[URL=http://www.phpmyborder.com]http://www.phpmyborder.com[/URL]

Its also published in the PHP community: [URL=http://phpmyborder.users.phpclasses.org/browse/package/2681.html]Phpclasses.org[/URL]

to post a comment
PHP

26 Comments(s)

Copy linkTweet thisAlerts:
@chazzyNov 25.2005 — can you increase or decrease the angle?
Copy linkTweet thisAlerts:
@phpmyborderauthorNov 25.2005 — nope, at the moment it cant, but in theori it is possible..but it will take alot more divs to make it...
Copy linkTweet thisAlerts:
@chazzyNov 25.2005 — now why exactly would someone want to use this, as opposed to just using images for the left and right sections?
Copy linkTweet thisAlerts:
@SpectreReturnsNov 25.2005 — Or perhaps even using css:-moz-round or whatever it is.

[EDIT] Oh, and you should change the extension on the file to .class.php instead of .class.
Copy linkTweet thisAlerts:
@bokehNov 25.2005 — now why exactly would someone want to use this, as opposed to just using images for the left and right sections?[/QUOTE]Is that a serious question?
Copy linkTweet thisAlerts:
@SheldonNov 26.2005 — i think is a good idea.
Copy linkTweet thisAlerts:
@chazzyNov 26.2005 — Is that a serious question?[/QUOTE]

yes, it is.

all of my personal projects, if i need round corners for something, i usually just make the image up. i think based on the amount of markup he's using to generate the borders, my images might end up being smaller in size and they cache. markup doesn't cache.
Copy linkTweet thisAlerts:
@bokehNov 26.2005 — i think based on the amount of markup he's using to generate the borders, my images might end up being smaller in size and they cache.[/QUOTE]If you disect the markup each corner is approx 400 bytes and could be even smaller if he used a style [I]class[/I] rather than embeded CSS.

In the case of an image though a seperate request is needed. This causes a round trip to the server even if the image is cached just to check the image remains unchanged. Even if the image is not sent the request headers alone come to some 700 bytes as follows:[code=html]http://bokehman.com/corner_image.png

GET /corner_image.png HTTP/1.1
Host: bokehman.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5
Accept: image/png,*/*;q=0.5
Accept-Language: en,es;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://bokehman.com/filename

HTTP/1.x 304 Not Modified
Date: Sat, 26 Nov 2005 16:52:22 GMT
Server: Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.7g PHP/5.0.4
Last-Modified: Tue, 22 Nov 2005 23:29:01 GMT
Etag: "1003d-50b-c4c71345"
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive[/code]


In my opinion the case against this method is completely different. If one uses css to produce the curved corner the result is severely alaised, something which is much easier to control with an image.
Copy linkTweet thisAlerts:
@NogDogNov 26.2005 — It's a little dodgy, semantically: a bunch of nested divs, most of which have no meaningful content. It's still pretty cool, though. ?

Maybe in a few more years CSS3 will be implemented and actually supported by browsers, allowing us to do this much more easily.
Copy linkTweet thisAlerts:
@chazzyNov 26.2005 — If you disect the markup each corner is approx 400 bytes and could be even smaller if he used a style [I]class[/I] rather than embeded CSS.

In the case of an image though a seperate request is needed. This causes a round trip to the server even if the image is cached just to check the image remains unchanged. Even if the image is not sent the request headers alone come to some 700 bytes as follows:[code=html]http://bokehman.com/corner_image.png

GET /corner_image.png HTTP/1.1
Host: bokehman.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5
Accept: image/png,*/*;q=0.5
Accept-Language: en,es;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://bokehman.com/filename

HTTP/1.x 304 Not Modified
Date: Sat, 26 Nov 2005 16:52:22 GMT
Server: Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.7g PHP/5.0.4
Last-Modified: Tue, 22 Nov 2005 23:29:01 GMT
Etag: "1003d-50b-c4c71345"
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive[/code]


In my opinion the case against this method is completely different. If one uses css to produce the curved corner the result is severely alaised, something which is much easier to control with an image.[/QUOTE]


So, are you trying to say that bandwidth is so much of an issue that it can't send a 700byte graphic without problems? I've never had an issue like that before, honestly. It may exist, but I've never run into it. Then again, I've never dealt with graphic heavy websites.
Copy linkTweet thisAlerts:
@bokehNov 26.2005 — So, are you trying to say that bandwidth is so much of an issue that it can't send a 700byte graphic without problems? I've never had an issue like that before, honestly. It may exist, but I've never run into it. Then again, I've never dealt with graphic heavy websites.[/QUOTE]Not at all. It was you that broght up the bandwith issue. That comment was in response to you saying i think based on the amount of markup he's using to generate the borders, my images might end up being smaller in size[/QUOTE]My point is that cannot be true because the request headers alone just to get a 304 are bigger than that piece of mark-up.
Copy linkTweet thisAlerts:
@SpectreReturnsNov 26.2005 — But images are oh-so-much more sexy!
Copy linkTweet thisAlerts:
@SheldonNov 26.2005 — But images are oh-so-much more sexy![/QUOTE]

Hahahaha, Sexy baby Yeeerrrr...
Copy linkTweet thisAlerts:
@chazzyNov 27.2005 — Not at all. It was you that broght up the bandwith issue. That comment was in response to you saying[/quote]
i never brought up bandwidth before the last post, i brought up cache. i'd rather load up an image once and leave it in cache than reload 300 bytes of markup 50 times (though this paradigm may change anyways...)

My point is that cannot be true because the request headers alone just to get a 304 are bigger than that piece of mark-up.[/QUOTE]
it depends on how it's loaded, but sure. understood. you're still talking about a vey insubstantial amount of network traffic.
Copy linkTweet thisAlerts:
@bokehNov 27.2005 — i never brought up bandwidth.[/QUOTE]I guess I thought that was your slant when you posted this: the amount of markup... my images... smaller in size[/QUOTE]Have you got a link to somewhere you have done this with images. I'd be interested to take a look at your mark-up.
Copy linkTweet thisAlerts:
@phpmyborderauthorNov 27.2005 — Thanks everybody, i really preciate all the feedback!


I would just like to give some few comments.


[B]Why would somebody like to use this kind of borders ([URL=http://www.phpmyborder.com]PhpMyBorder[/URL]):[/B]

  • - That could be a lot of reasons, but first of all, it requires verry little code in your php to get the round corner effect, making your code cleaner.


  • eg. when using the default colors...

    <?=$pmb -> begin()?>

    blabla your content...

    <?=$pmb -> end()?>

    Any alternatives that is shorter in code ?

    Yes, i know that its quite a lot of divs in the output HTML, but who do actually care about that? I mean, the code works and at it is fast at the same time.

  • - People would like to save time spent on Photoshop. In stead of using time in photoshop, painting corners, changing colors, saving gifs, uploading new gifs, testing, etc..etc... and then starting over again if the result didn't look as nice as ecspected... With this script just change the color in the script and voila, done...


  • - The page is faster rendered than using images and tables, especially for people vising the site over seas. They will also notive drastic improvments on resonsetime (long responsetime). Divs reqires only one request, not one for each corner. Yes, i know about the caching function of images, but many people turn this off as well, and forcing update of images at every request, to be sure they have the newest versions at all time, but also to save diskspace.



  • [B]Why is images better[/B]

  • - Sure, in some cases images are better. Because divs (at least my script) is very limited, if you would like diffrent radius on corners, thicker edges, patterns on the corners (zigzag), etc etc... images are more flexible. Its difficult to change the style of the border except the colors with divs, small changes would make alot of new divs...especially if the radius gets bigger on the corners...


  • - It may have a better compatibility. Using tables and images (gifs) would have better support by some browser i belive, specially old ones.






  • [B]In general[/B]

    Actually i made a first version of PhpMyBorder using images. Thats is, the script generated the needed gifs and cached them on the server. It worked, but the script didn't work on all servers because of limited priviliges of the php engine running the scripts (safe-mode), e.g caching the gifs could be problematic because of no-write access on the server... The script also became very dirty and needed more setup (config) before use, e.g to specify where the script was located on the server, relative to doc-root because the virtualpath of doc-root in many cases was diffrent than the realpath etc etc...

    Even with a solution with images and tables/divs, its requiered a minimum of code to create the sceleton... e.g a table with 9 cells, or e.g 5 divs or more to position each corered image. Eighter way, you will get some HTML overhead.


    And yes, PhpMyBorder could use stylesheet, but to be able to set fill and edgecolor dynamicly, it reqires at least some inline styling. But alot of the styling-code is static and could indeed be saved in a stylesheet. I have tried it, and it works fine, but to make the script as simple as possible to use, i decided to go with inline styling only (at least for now...)


    In [URL=http://www.w3.org/Style/CSS/current-work]CSS3 [/URL] there will be a similar effect (round corner on boxes), but who knows when the standard will be completed, and not at least, when will it have a wide supportby clientbrowsers...




    Im working with and extension of PhpMyBorder, to make it support/generate more kind of effects... like 3D and shadows... but im still not sure of how the result is going to be yet...



    Keep giving me constructive feedback like this, ill read all of it with great interest, and it may as well improve the script...
    Copy linkTweet thisAlerts:
    @bokehNov 27.2005 — If you are going to get fanatical about drawing images with CSS take a look at this: [URL=http://www.designdetector.com/tips/CSSPencilsDemo.php]CSS pencils[/URL]
    Copy linkTweet thisAlerts:
    @LiLcRaZyFuZzYNov 27.2005 — Maybe in a few more years CSS3 will be implemented and actually supported by browsers, allowing us to do this much more easily.[/QUOTE]
    I'll be grandpa the day this will happen! :p
    Copy linkTweet thisAlerts:
    @SpectreReturnsNov 28.2005 — I love how many don't support CSS2 yet.
    Copy linkTweet thisAlerts:
    @chazzyNov 28.2005 — I guess I thought that was your slant when you posted this: Have you got a link to somewhere you have done this with images. I'd be interested to take a look at your mark-up.[/QUOTE]

    all of my work has been for internal use only. i've mostly worked at places that don't care about their look or hire professional graphics designers to do what they need.

    and personally, i prefer using nested div/span/p elements and no rounded corners. i guess no one i've ever worked with have cared so much that they wanted rounded edges.

    heck, areas are for showing items (books, dvd's, games, etc) like bookcases (which have sharp edges) not for sitting on like chairs (which are round)
    Copy linkTweet thisAlerts:
    @NogDogNov 28.2005 — Hmmm...crazy thought: what about using PHP GD library functions to create rounded-corner blocks using images created on-the-fly? ?
    Copy linkTweet thisAlerts:
    @LiLcRaZyFuZzYNov 28.2005 — If you are going to get fanatical about drawing images with CSS take a look at this: [URL=http://www.designdetector.com/tips/CSSPencilsDemo.php]CSS pencils[/URL][/QUOTE]
    wow! :eek:
    Copy linkTweet thisAlerts:
    @SheldonNov 28.2005 — 
    If you are going to get fanatical about drawing images with CSS take a look at this: CSS pencils[/quote]


    wow! :eek:[/QUOTE]


    Same here, thats cool,


    Hmmm...crazy thought: what about using PHP GD library functions to create rounded-corner blocks using images created on-the-fly? [/quote]

    Now theres an idea, proberly more server load, but oh wouldnt it make it cool, the only thing is the average use wouldnt notice anything different, But the customization wouyld be wonderful.
    Copy linkTweet thisAlerts:
    @SheldonNov 28.2005 — Maybe in a few more years CSS3 will be implemented and actually supported by browsers, allowing us to do this much more easily.[/quote]I'll be grandpa the day this will happen! :p[/QUOTE]

    At the rate i drinkand smoke i doubt i will still be able to use a computer when CSS3 is commonly supported, hell as SpectureReturns stated CSS2 isn't even fully supported.
    Copy linkTweet thisAlerts:
    @phpmyborderauthorDec 02.2005 — To my big surprise, i must say, I have become nominated to the monthly "Inovation Award" for this script.

    The reason is that i published a script in November at this site, and through feedback and constructive comments from members at this forum (this thread) I have been able to optimize it and made it better.

    Thanks folks here at WebDeveloper.com PHP forum!


    [url=http://phpmyborder.users.phpclasses.org/vote.html][b] All the nomiees[/b] [/url]


    More about the my script [url=http://phpmyborder.users.phpclasses.org/browse/package/2681.html]here[/url],


    some examples.

    version2

    [img]http://phpmyborder.com/images/phpmyborder2.gif[/img]



    version1

    [img]http://phpmyborder.com/images/phpmyborder1.gif[/img]
    Copy linkTweet thisAlerts:
    @SpectreReturnsDec 02.2005 — May I ask why you posted it in here - AND a new thread?
    ×

    Success!

    Help @phpmyborder spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...