css clearfix_如何使用CSS清除浮点数(clearfix)?
css clearfix
Introduction:
介紹:
Dealing with various elements on a website or web page can sometimes prove to create many problems hence one should be aware of many properties, tricks or ways to cope with those problems. We do not want our website or web page to appear as shabby or unresponsive to the users, therefore fixing every problem or issue becomes highly important. Although it is quite acceptable that one can not know all the properties involved in website or web page development, therefore one must create a habit of looking up for things whenever in doubt or is unsure as to what to be done to solve a particular problem. This article can help many such websites or web page developers out there to tackle such problems and also help them to learn something that they might not have known before or may have known but have forgotten.
處理網站或網頁上的各種元素有時可能會造成許多問題,因此人們應該意識到應對這些問題的許多屬性,技巧或方法。 我們不希望我們的網站或網頁顯得陳舊或對用戶沒有React,因此解決每個問題都變得非常重要。 盡管人們不知道網站或網頁開發中涉及的所有屬性是完全可以接受的,但因此,人們必須養成一種習慣,無論何時有疑問或不確定如何解決特定問題,都應尋找事物。 本文可以幫助許多此類網站或網頁開發人員解決此類問題,還可以幫助他們學習以前可能不知道或可能知道但忘記了的東西。
Briefing:
簡報:
As said in the earlier section that dealing with various elements can prove to be very challenging, therefore this article revolves around one such aspect of the elements that we come across regularly while developing a website or web page and you must be actively aware of this term as well, the term is floating. We use the floating property very often for the placement of various elements throughout our web page, for example, we set an element to float right, we set an image to float left and for various other purposes. But we all know what the floating property is used for right? So, how this article is going to help us? The question that must have hit you right now, for that keep on reading and you will finally understand the purpose of the article!
如前一節所述,處理各種元素可能會非常具有挑戰性,因此本文圍繞我們在開發網站或網頁時經常遇到的元素的一個此類方面展開討論,您必須積極意識到這個術語同樣,該術語是浮動的。 我們經常在整個網頁中放置各種元素時使用float屬性,例如,將元素設置為向右浮動,將圖像設置為向左浮動以及用于其他目的。 但是我們都知道float屬性用于什么嗎? 那么,本文將如何幫助我們? 現在一定要打動您的問題,為此繼續閱讀,您將最終了解本文的目的!
Solution:
解:
Sometimes we face a problem that many elements after a floating will tend to flow around it. If you have not to face this kind of problem yet then you might in the future. So how do we fix this problem? Well, the answer is clearfix. clearfix is a CSS property that is used or implied to resolve particularly this kind of problem. This property or method is very easy to implement as well.
有時,我們會遇到一個問題,即浮動后的許多元素將傾向于在其周圍流動。 如果您還不必面對此類問題,那么將來可能會遇到。 那么我們如何解決這個問題呢? 好吧,答案是clearfix 。 clearfix是一個CSS屬性,用于或隱含地解決此類問題。 該屬性或方法也很容易實現。
For example:
例如:
There are times when we have the elements who are taller than the elements containing it, therefore to solve this problem we use overflow: auto and add it to the containing element.
有時候我們的元素要比包含它的元素高,因此為了解決這個問題,我們使用了overflow:auto并將其添加到包含元素。
Syntax:
句法:
Element{overflow:auto;}Example:
例:
<!DOCTYPE html><html><head><style>div {border: 5px solid #ccc;padding: 5px;}.clearfix {overflow: auto;}.img {float: right;}</style> </head><body><div class="clearfix"><img class="img" src="img_forest.jpg" width="160" height="150"/> IncludeHelp is a learning wesbite for students. IncludeHelp is a learning wesbite for students.IncludeHelp is a learning wesbite for students.</div> </body></html>Output
輸出量
In the above example, the image doesn't overflow its outside container.
在上面的示例中,圖像不會溢出其外部容器。
Note: The overflow: auto will only work well as long as you have control over your margins and paddings, therefore make sure that your margins and paddings are correct otherwise you might see scrollbars.
注意:僅當您可以控制邊距和填充時,overflow:auto才能正常工作,因此請確保邊距和填充是正確的,否則可能會看到滾動條。
翻譯自: https://www.includehelp.com/code-snippets/how-to-clear-floats-clearfix-using-css.aspx
css clearfix
總結
以上是生活随笔為你收集整理的css clearfix_如何使用CSS清除浮点数(clearfix)?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在Python中使用OpenCV裁剪图像
- 下一篇: ruby array_Ruby中带有示例