Text in Border CSS HTML

后端 未结 8 2242
佛祖请我去吃肉
佛祖请我去吃肉 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:34

    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/

提交回复
热议问题