为什么用<br>定位元素是不好的做法? [英] Why exactly is it bad practice to position elements with <br>?
本文介绍了为什么用<br>定位元素是不好的做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人告诉我使用 br
元素是一个非常糟糕的主意,但是你如何向新手"解释为什么这是不好的做法?
I have been told using br
elements is a very bad idea, but how would you explain to a "newbie" why it's bad practice?
这是一个例子——
<body>
<h1>Welcome to My Website</h1>
<br />
<br />
<br />
<br />
<br />
<a href='/'>Click Here</a>
<br />
<br />
<br />
<br />
<br />
<p> For any inquiries call (999) 999 9999 </p>
</body>
推荐答案
这是一种不好的做法,因为您无法使用 css 更改和控制布局.例如,当你想要做一个 flexbox 或一个流畅的布局时,你仍然有这个换行符.使用 css 进行线路制动:
It is a bad practice because you cannot change and control your layout with css. For example when you want to do a flexbox or a fluent layout you still have this linebreaks in place. Do the line brakes with css using:
display: block;
这篇关于为什么用<br>定位元素是不好的做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文