Skip navigation
Currently Being Moderated

Best way to make rounded corner box--with blank square in middle for text

May 26, 2012 3:51 PM

I would like to make a rounded corner box that has a blank square area in the middle into which I can put text and a search area. I originally made it in Dreamweaver and cobbled together something that looked reasonably like what I want.

 

My effort can be found at; www.englishjapaneseonlinedictionary.com.

 

You can see the two rounded corner rectangles with the text in the middle.

 

However, after upgrading to CS6 I realized I could now make the rectangle boxes easily in Fireworks. However, when I make the boxes I can't place text in the white rectangle area in the middle as I have on my site.

 

Can someone please give me a hint about how to go about making these boxes in a better way? I gotta be able to place text in the white rectangle area.

 

Should I just make the rectangle in two pieces? The top part, and then the bottom part, and then just place the text in the middle?

 

Thanks for any help.

 

Phil

 
Replies
  • Currently Being Moderated
    May 26, 2012 5:29 PM   in reply to Jane Smith 2300

    FYI my browser blocked a pop-up on page load. If it's important, you may wish to explore alternatives that won't be defeated by pop-up blockers (98% of browsers).

     

    Anyway to answer your question, you can easily do what you want with CSS border-radius and some strategically applied background-colors & borders. 

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Untitled Document</title>

     

    <style type="text/css">

     

    /**outer wrapper**/

    #box-wrapper {

    width:550px;

    overflow:hidden; /**to contain floats**/

    border:1px dotted red;

    }

     

    /** rounded boxes **/

    .box {

    float:left;

    padding:0px;

    width: 250px; /**adjust width as needed**/

    min-height: 150px;

    margin:55px 2px 55px 2px;

    background: #087fb7;

    border: 10px solid #087fb7;

    -moz-border-radius: 22px;

    -webkit-border-radius: 22px;

    border-radius: 22px;

    }

    .box h2 {

    font-size: 16px;

    margin: 0;

    color: #fff;

    text-align: center;

    padding: 12px;

    }

    .box-content {

    font-size:12px;

    background: #FFF;

    padding: 12px;

    }

    </style>

    </head>

     

    <body>

    <div id="box-wrapper">

     

    <div class="box">

    <h2>Heading 2</h2>

    <div class="box-content">

    <p>Here is some content..

    Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor...Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor...</p>

    </div>

    </div>

     

    <div class="box">

    <h2>Heading 2</h2>

    <div class="box-content">

    <p>Here is some content...

    Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor...</p>

    </div>

    </div>

     

    <!--end box-wrapper--></div>

    </body>

    </html>

     

     

    Nancy O.

    Alt-Web Design & Publishing

    Web | Graphics | Print | Media  Specialists 

    http://alt-web.com/

     
    |
    Mark as:
  • Currently Being Moderated
    May 31, 2012 12:25 PM   in reply to Nancy O.

    Thanks for the how to on rounded corners. It makes it so much easier!

    I cannot tell you the frustration of not being able to do this without images.

    I made some changes seen below and added a drop shadow and adjusted the text.

     

    I noticed that in your original and my spinoff from there that in XP the boxes are square instead of having the rounded corners. I only noticed it as I use XP at work while my home computers are Windows 7.

     

    Do you think this is XP? Is there a fix where I would not have to use images to get rounded corners?

     

    XP is still in use in large numbers. I know that will change as people buy a new pc.

    http://www.computerworld.com/s/article/9223094/Users_desert_Windows_XP _in_near_record_numbers

     

     

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

     

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>Rounded Corners</title>

    <style type="text/css">

    body {

    background-color: #D2D2D2;

    }

     

    p {

    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;

    font-size: 1.1em;

    line-height: 1.1em;

    text-align: left;

    margin: 0px;

    padding: 5px;

    }

    h1 {

    padding: 0px;

    font-family: Georgia, "Times New Roman", Times, serif;

    margin-top: 7px;

    margin-right: 0px;

    margin-bottom: 3px;

    margin-left: 0px;

    color: #000;

    }

     

    #wrapper {

    width:380px;

    overflow:hidden;

    margin-right: auto;

    margin-left: auto;

    margin-top: 100px;

    border-top-width: thin;

    border-right-width: thin;

    border-bottom-width: thin;

    border-left-width: thin;

    border-top-style: none;

    border-right-style: none;

    border-bottom-style: none;

    border-left-style: none;

    }

    .box1 {

    float:left;

    padding:0px;

    width: 350px;

    border: 0px solid #000000;

    -moz-border-radius: 22px;

    -webkit-border-radius: 22px;

    border-radius: 22px;

    background-color: #FFB062;

    margin: 15px;

    -webkit-box-shadow: 3px 3px 10px 3px rgba(0, 0, 0, 0.3);

    -moz-box-shadow: 3px 3px 10px 3px rgba(0, 0, 0, 0.3);

    box-shadow: 3px 3px 10px 3px rgba(0, 0, 0, 0.3);

    }

    .box2  {

    color: #000;

    text-align: center;

    margin: 0px;

    padding: 0px;

    }

     

    .box-content {

    -moz-border-radius: 12px;

    -webkit-border-radius: 12px;

    border-radius: 12px;

    margin-right: 10px;

    margin-bottom: 10px;

    margin-left: 10px;

    vertical-align: top;

    padding-top: 5px;

    padding-right: 10px;

    padding-bottom: 5px;

    padding-left: 10px;

    background-color: #FFF;

    }

    </style>

    </head>

     

    <body>

    <div id="wrapper">

      <div class="box1">

      <div class="box2">

        <h1>Rounded Corners</h1>
        <div class="box-content">
          <p>Rounded corners tested in my 2 Windows 7 computers looks the same in IE9 and Firefox 7 and 8.</p>
          <p>Using IE8 in XP (my work pc).<br />
            I see square corners. </p>
        </div>
      </div>
       </div>
      
      <div class="box1">
       <div class="box2">
        <h1>Rounded Corners</h1>
        <div class="box-content">
          <p>Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty. </p>
          <p>Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty</p>
        <!--end box1--></div>
      <!--end box2--></div>
    <!--end box-content--> </div>
      <!--end wrapper--></div>
    </body>
    </html>
     
    |
    Mark as:
  • Currently Being Moderated
    May 31, 2012 1:15 PM   in reply to davidhelp

    davidhelp wrote:

     

    I noticed that in your original and my spinoff from there that in XP the boxes are square instead of having the rounded corners. I only noticed it as I use XP at work while my home computers are Windows 7.

     

    Do you think this is XP? Is there a fix where I would not have to use images to get rounded corners?

     

    XP is still in use in large numbers. I know that will change as people buy a new pc.

    http://www.computerworld.com/s/article/9223094/Users_desert_Windows_XP _in_near_record_numbers

     

    Nothing to do with the operating system (Windows XP). Everything to do with the browser.

     

    Rounded corners without images are part of CSS3 (Cascading Stylesheets).

     

    All modern browsers, including Internet Explorer (IE) 9, understand and correctly display CSS3 rounded corners.

     

    The big exception is IE versions lower than 9. So IE8 and lower will not show CSS-only rounded corners without images.

     

    Unfortunately IE9 will not run on Windows XP (Microsoft's decision to do things that way, presumably to encourage those that care to upgrade to Windows 7).

     

    So on Windows XP, install current versions of Chrome or Firefox and you'll see CSS3 rounded corners (without images).

     

    Unfortunately most people running XP will be running IE7 or IE8 - but then they won't ever be used to rounded corners so why code your pages with images just for older versions of IE? That's a web design approach termed "progressive enhancement" where those with older browsers get an adequate and functional - but not 100% - browsing experience.

     
    |
    Mark as:
  • Currently Being Moderated
    May 31, 2012 1:56 PM   in reply to John Waller

    Other browsers that run on XP include Firefox, Chrome, Safari, Opera.

     

    Nancy O.

     
    |
    Mark as:
  • Currently Being Moderated
    May 31, 2012 2:11 PM   in reply to Nancy O.

    Nancy O. wrote:

     

    Other browsers that run on XP include Firefox, Chrome, Safari, Opera.

    Correct.

     

    I only mentioned a couple of those in my previous post as examples.

     

    In fact, almost every modern browser runs on XP, except for IE9.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 8:14 PM   in reply to John Waller

    I used VMware Workstation and installed Windows XP w/sp3.

    (you can also download Oracle VM VirtualBox - free).

    I took screenshots of the same Rounded Corners in IE6, IE7, IE8 and Firefox 8 in Windows XP seen below.

     

    In Windows 7 64bit, IE8 will show square corners. IE9 will show the rounded corners.

    IE still annoying   : )

     

    rounded_corners_xp_browsers.jpg

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 2, 2012 5:09 PM   in reply to davidhelp

    I found a fix to have rounded corners in older IE versions. I was looking thru a book I have called The CSS Anthology and on page 281 they explained about this PIE file to support older browsers. I googled pie.htc and found the website below.

     

    Download the file called PIE.htc

    http://css3pie.com/documentation/getting-started/

     

    Add this to your website. You can change the file path if you want (place in a subfolder) where it says (PIE.htc):    behavior: url(PIE.htc);

     

    Example:

    .box-content {

    -moz-border-radius: 12px;

    -webkit-border-radius: 12px;

    border-radius: 12px;

    background-color: #FFF;

    behavior: url(PIE.htc);

     

     

              IE6 in XP

    rounded_corners_xp_IE6_fixed_PIE.jpg

             IE7 in XP

    rounded_corners_xp_IE7_fixed_PIE.jpg

     

    Nancy O: I went to your website and found a walkthru that looks like it uses a similiar htc file.

    http://alt-web.com/DEMOS/CSS-Rounded-Corners.shtml

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 2, 2012 5:15 PM   in reply to davidhelp

    I have to caution anyone considering HTC or PIE to be aware of the nasty little side effects.  Clear type is disabled making text look horrible.  Also, HTC doesn't support different radii in the four corners.  It's all or nothing.  Finally, it doesn't work well in complex layouts.  

     

    IE6 has reached its end of life.  Soon IE7 will join it.  I no longer do cartwheels supporting older browsers.  Rounded borders are just eye candy.  They are not critical to site performance or usability so I don't worry about older IE users not seeing them.

     

    Just my 2 cents.

     

    Nancy  O.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 3, 2012 10:13 AM   in reply to Jane Smith 2300

    That's simple, insert a heading or paragraph below the .box-content div...

     

    <div class="box">
    
    <h2>Heading 2</h2>
    
    <div class="box-content">
    <p>Here is some content...
    Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... 
    Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... 
    Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor... 
    Lorem ipsum dolor... Lorem ipsum dolor... Lorem ipsum dolor...</p>
    <!--end box-content--></div>
    
    <h3>Heading 3</h3>
    
    <!--end box--></div>
    
    

     

     

    Nancy O.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points