Search code examples
csslegendfieldsetlegend-properties

Fancy fieldset legend


I am trying to html'ify a design in which a video has a border around it, and on the border a title. The perfect way to accomplish this is with a fieldset and legand tag, however, I need to get fancy with the styling, anyone have an idea of how to accomplish this, while maintaining compatibility with ie7+, firefox, and chrome??

Fame 1: Desired look of one frame

Frame 2: Desired look of second frame


Solution

  • You can do something like this - DEMO

    HTML

    <div class="wrapper">
        <div class="content">
            <h2> Some lorem ipsum text title </h2>
        </div>
    </div>
    

    CSS

    .wrapper {
        margin: 25px;
        background: #000;
        height: 300px;
        padding: 5%;
    }
    
    .content {
        border: 1px solid #fff;
        width: 100%;
        height: 100%;
        position: relative;
        text-align: center;
    }
    
    h2 {
        color: yellow;
        font: bold 16px sans-serif;
        display: inline-block;
        padding: 0 25px;
        position: relative;
        top: -12px;
        background: #000;
    }