水平线和正确的方式在html,css中编码 [英] horizontal line and right way to code it in html, css

查看:105
本文介绍了水平线和正确的方式在html,css中编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在一些块之后绘制一条水平线,我有三种方法可以做到:

I need to draw a horizontal line after some block, and I have three ways to do it:

1)定义一个类 h_line 并添加css功能,例如

1) Define a class h_line and add css features to it, like

#css
.hline { width:100%; height:1px; background: #fff }

#html
<div class="block_1">Lorem</div> <div class="h_line"></div>

2)使用 hr >

2) Use hr tag

#css
hr { width:100%; height:1px; background: #fff }

#html
<div class="block_1">Lorem</div> <hr />

3)使用

#css
.hline:after { width:100%; height:1px; background: #fff; content:"" }

#html
<div class="block_1 h_line">Lorem</div>

哪种方式最实用?

推荐答案

我会去使用语义标记,使用< hr />

I'd go for semantic markup, use an <hr/>.

除非它只是一个边框你想要的,那么你可以使用填充,边框和边距的组合,以获得所需的边界。

Unless it's just a border what you want, then you can use a combination of padding, border and margin, to get the desired bound.

这篇关于水平线和正确的方式在html,css中编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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