EDVARD TOTH

EDVARD TOTH

art | design | technology | entertainment

Menu
  • Posts
  • News
  • About
  • Games
    • Casino Games
      • Catch you on the flipside
      • Gamblit Gallery
      • Big expo, much wow
      • Expo Schmexpo
      • Deal or No Deal
      • Chasing Goldilocks
      • TriStation launched!
      • I know what you did at G2E
      • Model G launched!
      • Gaming expo of the undead
      • The skill of being lucky
      • Gamblit interactive table games
      • Gamblit mobile games
    • Mobile & Casual Games
      • BINGO Blitz
      • Solitaire and Prizes
      • Serf Wars
      • Action AllStars
      • Tiki Resort
      • MonkWerks
      • Snood
    • Console Games
      • Jak X Combat Racing
      • Jak 3
      • The Incredibles
      • Spongebob Squarepants: BFBB
      • True Crime: Streets of L.A.
      • Ghostworld / Fishdemo
      • Star Wars: Demolition
      • Vigilante 8: Second Offense
    • Perihelion
  • Design
    • Design Gallery
    • The Teal Sphere
    • Gamblit Gallery
    • Solitaire and Prizes
  • Art
    • The Witch
    • Banshee Waifu
    • Dark Architecture
    • AI-dventures in a Strange Realm
    • The Teal Sphere
    • Gamblit Gallery
    • Archive Gallery
    • Vintage Pixel Gallery
    • Photography
    • Korn video
  • AI
    • The Witch
    • Weavy course launched
    • All-In-Wan Video Workflow
    • Weavy launched
    • Kartel.AI is now live
    • The Tower
    • Starter Character Workflow
    • Banshee Waifu
    • Dark Architecture
    • AI-dventures in a Strange Realm
    • pAIn & gAIn
    • AI-pocalypse
    • The Teal Sphere
    • Warhammer 40k + Midjourney 5
  • Technology
  • Contact
  • ©
Menu

Rounded corners using nothing but CSS

Posted on May 21, 2008December 4, 2015 by edvardtoth

Rounded corners structure

Recently I was working on iPhone-specific web-based login pages, and for the sake of consistency I wanted to mimic the rounded-corner look of the iPhone interface. I looked around for solutions, but everything I could find either used images, Javascript or both, which seemed like serious overkill for this purpose.

Long story short, I ended up putting (hacking?) together my own solution, one which relies solely on CSS to render the rounded corners, using the structure shown in the image to the right. The end result looks something like THIS and it works in both IE and Firefox.

I think it’s a fairly elegant way to do this, and I’m pretty sure somebody else somewhere must have figured this out already (considering the number of people who are significantly better at CSS than I am) but since I couldn’t find anything similar out there, I decided to share it here.

The complete CSS/HTML template is as follows:

<style type="text/css">

/* classes for rounded corners */

.crntop, .crnbottom {
    display:block; 
    background:transparent; 
    font-size:1px;
}
.crn1, .crn2, .crn3, .crn4, .crn5, .crn6 {
    display:block; 
    overflow:hidden;
}
.crn2, .crn3, .crn4, .crn5, .crn6 {
    background:#b80000; 
    border-left:1px solid #000000;
    border-right:1px solid #000000;
}
.crn1 {
    height:1px; 
    margin:0 9px; 
    background:#000000;
}
.crn2 {
    height:1px; 
    margin:0 6px;
    border-width:0 3px;
}
.crn3 {
    height:1px; 
    margin:0 4px;
    border-width:0 2px;
}
.crn4 {
    height:1px; 
    margin:0 3px;
    border-width:0 1px;
}
.crn5 {
    height:2px; 
    margin:0 2px;
    border-width:0 1px;
}
.crn6 {
    height:3px; 
    margin:0 1px;
    border-width:0 1px;
}

</style>

<div class="container">

<span class="crntop"><span class="crn1"></span><span class="crn2">
</span><span class="crn3"></span><span class="crn4"></span><span class="crn5"></span><span class="crn6"></span></span>

<div class="content">CSS-only rounded corners</div>

<span class="crnbottom"><span class="crn6"></span><span class="crn5"></span><span class="crn4"></span><span class="crn3"></span>
<span class="crn2"></span><span class="crn1"></span></span>

</div>

Spread the word

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to email a link to a friend (Opens in new window) Email
  • More
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Bluesky (Opens in new window) Bluesky

Like this:

Like Loading...

6 thoughts on “Rounded corners using nothing but CSS”

  1. Robert Mathison says:
    October 22, 2008 at 12:41 am

    That’s really impressive.

    Loading...
  2. nice says:
    February 8, 2009 at 7:09 pm

    Great job, I love this css tricks.

    Loading...
  3. Malcolm says:
    February 13, 2009 at 9:37 pm

    Although I haven’t tried it, the CSS selector -webkit-border-radius supposedly works on the iPhone. See http://www.westciv.com/iphonetests/
    For mozilla, use -moz-border-radius.
    For IE, use conditional comments to include the great CSS you have developed above.
    However, I don’t think the above selectors will validate.

    Loading...
  4. Ivan says:
    February 28, 2009 at 6:30 am

    First let me congratulate you because I can see you spent quite a few hours doing that and the effect is indeed absolutely nice, I’ll give you that. Secondly, I just think you were better off using just images, you just killed the whole idea of semantic HTML, I happen to think what you did is nonsense.

    Loading...
  5. edvardtoth says:
    February 28, 2009 at 6:58 am

    Thanks for the feedback, I’m not sure if I should feel complimented or feel insulted, haha.

    Nobody disputes that in general it makes way more sense to use images and/or JavaScript, but – like the description says – it was inspired by one of those odd cases where neither made much sense.

    Yeah, the practical utility of this solution is pretty limited so just accept it for what it is: a neat trick. 😉

    Loading...
  6. Truth says:
    October 18, 2011 at 9:01 pm

    Ivan,

    I think you’re a dick.

    Loading...

Leave a Reply

Your email address will not be published. Required fields are marked *

  • September 8, 2025 Isometric Banana Workflow
  • June 9, 2025 Weavy launched
  • June 2, 2025 Kartel.AI is now live
  • March 6, 2025 Lip-sync test with Sonic
  • January 18, 2025 Testing Nvidia's Sana model
  • November 3, 2024 The Cultist - a GenAI test using Invoke
  • January 16, 2024 The Lich - a GenAI case study
  • March 24, 2023 Warhammer 40k + Midjourney 5
  • January 11, 2023 ROG releases Aimlab-themed mouse!
  • December 9, 2022 Aimlabs.com launched!
  • March 20, 2021 ...and third time's the charm at the EKG Slot Awards!
  • March 2, 2020 Won another EKG Slot Award!
  • March 17, 2019 Won an EKG Slot Award!
  • November 7, 2018 Brew Caps is coming!
  • October 4, 2018 See you at the 2018 G2E!
(C) 2023 Edvard Toth
%d