边框 CSS HTML 中的文本 [英] Text in Border CSS HTML

查看:29
本文介绍了边框 CSS HTML 中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个看起来像这样的 div:

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

这可以用 HTML + CSS 来实现吗?我还将使用 jQuery 为这个 div 设置动画.当 div 隐藏时,我希望显示标题和顶行.

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.

推荐答案

你可以做这样的事情,你可以在 h1 上设置一个负的 margin(或任何您正在使用的标题)

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;
}

注意:您需要在 h1

示例:http://jsfiddle.net/ZgEMM/

编辑

为了隐藏div,你可以使用一些像这样的jQuery

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');    
});

(你需要修改...)

示例 2: http://jsfiddle.net/ZgEMM/4/

这篇关于边框 CSS HTML 中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆