Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text in Border CSS HTML

Tags:

html

css

I'd like to have a div that looks like this:

border example

Is this possible to do with HTML + CSS? I will also be animating this div with jQuery. When the div is hidden I would like the title and the top line to show.

like image 337
Alex Bliskovsky Avatar asked Oct 11 '11 19:10

Alex Bliskovsky


People also ask

How do you put a border around text in HTML CSS?

For the four borders, we need four <fieldset> elements, each containing a <legend> element inside. We add the text that will appear at the borders inside the <legend> elements. To begin, we stack the <fieldset> elements on top of each other in a grid cell and give them borders.

Can you give text a border in CSS?

Use the -webkit-text-stroke Property to Apply Borders to Font in CSS. We can use the text-stroke property on a text to apply borders to a font in CSS. We need to use the webkit prefix ahead of the text-stroke property to use the feature. However, it only works on the web-kit based browsers like Safari and Chrome.

How do you write on a border in HTML?

Using Inline Style attribute Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to use the inline property for adding the border. Step 2: Now, place the cursor inside the opening tag of that text around which we want to add the border.


2 Answers

Yes, but it's not a div, it's a fieldset

fieldset {     border: 1px solid #000; }
<fieldset>   <legend>AAA</legend> </fieldset>
like image 189
Bazzz Avatar answered Sep 22 '22 21:09

Bazzz


You can do something like this, where you set a negative margin on the h1 (or whatever header you are using)

div{     height:100px;     width:100px;     border:2px solid black; }  h1{     width:30px;     margin-top:-10px;     margin-left:5px;     background:white; } 

Note: you need to set a background as well as a width on the h1

Example: http://jsfiddle.net/ZgEMM/


EDIT

To make it work with hiding the div, you could use some jQuery like this

$('a').click(function(){     var a = $('h1').detach();     $('div').hide();     $(a).prependTo('body');     }); 

(You will need to modify...)

Example #2: http://jsfiddle.net/ZgEMM/4/

like image 38
Jason Gennaro Avatar answered Sep 21 '22 21:09

Jason Gennaro