Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Containing a text in an oval shaped area

Tags:

html

css

I have a html page which looks like the following:

enter image description here

I want to display some text on the left pane, but the problem is that the text should be inside the oval shaped area only. How do I achieve this? Note that the oval shaped image is the background image, however if required, I can also use a <img> tag for it if it would help. One lame way is to use <p> tags with padding, but that is not an efficient way, so kindly suggest some good methods.

EDIT: HTML:

<div id="leftStage" class="rounded-corners">
  <div id="questionDisp" align="center">

  </div>
</div>

CSS:

#leftStage {
position: relative;
width: 34%;
height:86%;
float: left;
}
#questionDisp {
display:none;
}

JS: (When the appropriate function is called: )

$("#questionDisp").fadeIn(1000);
$("#questionDisp").html(quesArr.q1);  //data read from xml

EDIT: What I need is a div or something above the oval background, & the text should fit in it. I am getting the text from an xml file, so it is not that I have a fixed text size to be displayed

like image 730
gopi1410 Avatar asked Jun 06 '12 06:06

gopi1410


4 Answers

There's actually a pure CSS/XHTML code generator on csstextwrap that does exactly what you want.

EDIT:

The concept here is to float <div>'s on either side of your text so that your content is forced to "flow" in between them. By setting the width of your floated <div>'s, you can create a wide variety of cascading "stencils."

See concept illustrated here: fiddle

like image 56
Funktr0n Avatar answered Nov 15 '22 21:11

Funktr0n


If it is background-image then use the position:absolute with proper margins (top and left), and set the width less than that the oval background-image. Then display property 'block'.

like image 42
RAN Avatar answered Nov 15 '22 21:11

RAN


Maybe you could try the jQuery plugin Text Fill

also see: https://stackoverflow.com/a/688362/753676

like image 31
Daniel Ruf Avatar answered Nov 15 '22 21:11

Daniel Ruf


I removed my answer since only the left float worked.

If you paste this code: it'll show you exactly how it works. I did a border-radius instead of creating a circle png.

<div style="width:250px;height:230px; border-radius:125px;background:#efefef;padding-top:20px; text-align:center">
The code for my<br /> fix isn't pretty but it should<br />work It's not automatic, but it<br /> does the job that you need it<br /> to do.
</div>
like image 23
Brian Noah Avatar answered Nov 15 '22 19:11

Brian Noah