How to write text on css border?

method one:

1. First, open the html editor, create a new html file, for example: index.html.

2, in the index.html <body> tag, enter html code:

<div style="margin-top: 30px;width: 200px;height:80px;border: 1px solid blue;">

<div style="position: absolute;left: 30px;top: 15px;">文字</div>

</div>

3, the browser run index.html page, then realized the border opening corner display text.

 

 

 

 

Method Two:

This is accomplished by the relative positioning of the elements in a way exactly at the border on the div to achieve

1
position : relative ;

Exemplified below

  1. Creating Html element

    1
    2
    3
    4
    < div >
         < span  class = "title" >我是边框上的文字</ span >
         < span >我是边框内的文字</ span >
    </ div >
  2. Set css styles

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    div{
         width : 200px ;
         height : 100px ;
         padding : 5px  30px ;
         margin : 50px ;
         border : 4px  solid  #ebcbbe ;
    }
    span.title{
         display : block ;
         width : 150px ;
         height : 30px ;
         position : relative ;
         top : -15px ;
         text-align center ;
         background white ;
    }
  3. Observe the display

 

Method three:

<the fieldset>
<Legend> text </ Legend>
<P> kkkk </ P>
</ the fieldset>
This trip

 

 

 

Guess you like

Origin www.cnblogs.com/Antwan-Dmy/p/11798950.html