如何在HR的左右侧div的样式? [英] How to style in HR on left and right hand side of div?

查看:119
本文介绍了如何在HR的左右侧div的样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在现有div中的文本左侧和右侧对HR进行样式设置?

How can I style in an HR to the left and to the right of my text within an existing div?

类似这样:

---标题材料-----------------------------------

--- Header Stuff -----------------------------------

推荐答案

如果要使用HR代码,可以在div上使用负边距将其放置在

If you want to use an HR-tag, you could use negative margins on a div to position it on-top of the hr, to accomplish what you have described.

// HTML
<hr />
<div class="headline">A headline text</div>

// CSS
.headline {
    background-color: #fff;
    position: relative;
    margin: -20px 0 0 20px;
    float: left; 
}

放在一个小提琴中: http://jsfiddle.net/WmbsG/

这篇关于如何在HR的左右侧div的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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