Text in Border CSS HTML

后端 未结 8 2128
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-22 05:56

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

\"border

Is this possible to do with HTML + CSS

8条回答
  •  别那么骄傲
    2020-11-22 06:25

    I know a bit late to the party, however I feel the answers could do with some more investigation/input. I have managed to create the situation without using the fieldset tag - that is wrong anyway as if I'm not in a form then that isn't really what I should be doing.

    /* Styles go here */
    
    #info-block section {
        border: 2px solid black;
    }
    
    .file-marker > div {
        padding: 0 3px;
        height: 100px;
        margin-top: -0.8em;
        
    }
    .box-title {
        background: white none repeat scroll 0 0;
        display: inline-block;
        padding: 0 2px;
        margin-left: 8em;
    }

    This can be viewed in this plunk:

    Outline box with title

    What this achieves is the following:

    • no use of fieldsets.

    • minimal use if CSS to create effect with just some paddings.

    • Use of "em" margin top to create font relative title.

    • use of display inline-block to achieve natural width around the text.

    Anyway I hope that helps future stylers, you never know.

提交回复
热议问题