views:

130

answers:

6

Is it possible to make this box's corner round with same html tags. without using any other tag and border-radius property and javascript. but i can use css classes and background images. and box height should be depend on content of <p>grr</p>

Width of Box and height of <h2> is fixed , but I need height of content flexible.

<h2>Nulla Facilisi</h2>
<p>
   Phasellus at turpis lacus. Nulla hendrerit lobortis nibh. 
   In lectus erat, blandit non feugiat vel, accumsan ac dolor. 
   Etiam et ligula vel tortor tempus vehicula porttitor ut ligula. 
   Mauris felis odio, fermentum vel
</p>

alt text

Edit : What is the best possible way to achieve this without css border-radius property which is not supported by internet explorer?

+2  A: 

You can put a background in the H2, which is like 10px in height and the fixed width that has the top corners positioned top.

Then in the p tag place the opposite image positioned bottom.

Something like:

<h2 style=background-image: url(''); background-repeat: no-repeat; background-position: 0 0;">Nulla Facilisi</h2>
<p style=background-image: url(''); background-repeat: no-repeat; background-position: 100% 0;">
   Phasellus at turpis lacus. Nulla hendrerit lobortis nibh. 
   In lectus erat, blandit non feugiat vel, accumsan ac dolor. 
   Etiam et ligula vel tortor tempus vehicula porttitor ut ligula. 
   Mauris felis odio, fermentum vel
</p>
Dustin Laine
but i need all corner round. what image i have to put in <p></p> and what happened if content of <p></p> would increased
metal-gear-solid
The image should be the full width and have the top corners in one image and the bottom corners in the other image. The P element will grow as much as you want and the background-image will remain positioned at bottom.
Dustin Laine
you mean "top corners in one image" is this for <h2>? and "bottom corners in the other imag" for <p></p>"
metal-gear-solid
Yes, that is exactly it.
Dustin Laine
+1  A: 

Karate Corners

Basically, you have an image that represents the corners, then you place them using position:absolute; and background-position. The only downside is that you need a special case for IE6 (since it doesn't like transparent pngs) and you have to add 4 extras <div>s for each box, but it works really well and isn't that complicated.

Here's my code for 5 px corners, using a 10x10 image of a circle:

CSS:

.round{
    position:relative;
}

.round .corner{
    background: url('corners.png') no-repeat;
    position:absolute;
    width:5px;
    height:5px;
    font-size:0%;
}
.round .tl{
    top: 0px;
    left: 0px;
    background-position: 0 0;
}
.round .tr{
    top: 0px;
    right: 0px;
    background-position: -5px 0;
}
.round .bl{
    bottom: 0px;
    left: 0px;
    background-position: 0 -5px;
}
.round .br{
    bottom: 0px;
    right: 0px;
    background-position: -5px -5px;
}

HTML:

<div class="round">
  <p>Content goes here</p>
  <div class="corner tl"></div>
  <div class="corner tr"></div>
  <div class="corner bl"></div>
  <div class="corner br"></div>
</div>
Brendan Long
For transparent PNGs is IE use one of the available hacks in a conditional style sheet. Using background-position can eliminate the need for absolute positioning. See my answer.
Dustin Laine
There are hacks to make transparent pngs work in IE 6, it's easier (and loads better) if you just use 4 gifs though for IE 6.
Brendan Long
Agree, but I think he does not want to change the markup.
Dustin Laine
+1  A: 

Try this post otherwise: http://dimox.net/cross-browser-border-radius-rounded-corners/ (not mine)

Or the jQuery plugin for rounded corners: http://plugins.jquery.com/project/corners

WmasterJ
both solution needs javascript. I want to do only with css and images
metal-gear-solid
+1  A: 

Read Rounded Corners Roundup and pick a solution that best fits your needs.

DisgruntledGoat
+1  A: 

If the box is a set width you can use a top and bottom image to create the effect. Otherwise you will need javascript and/or CSS that isn't fully supported yet (or at all in IE6/7).

Kevin
+1  A: 

You know you can use a htc hack to get border-radius support in IE

border-radius.htc from Google Code

I haven't used it myself yet but it's supposedly supported in IE6, 7, and 8. So the following should cover everything.

.rounded {
-webkit-border-radius: 9px;  /* safari-chrome */ 
 -moz-border-radius: 9px;   /* firefox */ 
 border-radius: 9px;  /* opera */ 
 behaviour:url(border-radius.htc); /* IE hack */ 
 }
Syntax Error
HTC and javascript is same thing. please read my question
metal-gear-solid
I read your question correctly the first time. You didn't state the reasons why you were against js, and while htc files contain js, in practice they are not used the same. Since this was tagged semantic-markup I thought it deserved a mention.
Syntax Error
HTC and javascript both need javascript enabled. Why i need without JS because client need this
metal-gear-solid
Just in case anyone else reads this, I have since tried border-radius.htc on a couple of different sites. Be warned that it is very fickle, I didn't have much luck with it.
Syntax Error