< div>之间的水平规则 [英] Horizontal Rule between <div>'s

查看:145
本文介绍了< div>之间的水平规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我有3个div Content1,Content2,Content3

Right now, I have 3 divs Content1, Content2, Content3

我想添加一个简单的风格化规则来分隔每个内容。这是我正在使用的代码。

I want to add a simple stylized rule to separate the content in each. Here is the code that I am working with.

HTML

     <div id="Content1">
     <p><strong>Content1</strong></p>
     </div>

     <div id="Content2">
     <p><strong>Content2</strong></p>
     </div>

     <div id="Content3">
     <p><strong>Content3</strong></p>
     </div>

我想在Content1和Content2之间以及Content2和Content3之间添加水平规则。

I want to add a Horizontal Rule inbetween Content1 and Content2 and between Content2 and Content3.

我已经包含了一个图片,所以你可以看到我的意思。

I have included an image so you can see exactly what I mean.

谢谢!

推荐答案

不要使用< hr> ,因为它主要是一个语义元素,而不是演示。底边是理想的。例如。 http://codepen.io/pageaffairs/pen/pjbkA

Don't use <hr> for this, as it's chiefly a semantic element rather than presentational. A bottom border is ideal for this. E.g. http://codepen.io/pageaffairs/pen/pjbkA

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

<style media="all">

div {width: 500px; padding-bottom: 10px; }
#Content1, #Content2 {border-bottom: 3px solid #4588ba; margin-bottom:10px;}
div p {background: #4588ba; line-height: 150px; font-size: 2em; font-family: sans-serif; color: white; margin: 0; padding-left: 30px;}

</style>

</head>
<body>

     <div id="Content1">
     <p><strong>Content1</strong></p>
     </div>

     <div id="Content2">
     <p><strong>Content2</strong></p>
     </div>

     <div id="Content3">
     <p><strong>Content3</strong></p>
     </div>

</body>
</html>

这篇关于&lt; div&gt;之间的水平规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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