- Mastering CSS
- Rich Finelli
- 229字
- 2021-07-08 09:45:59
Using overflow property with hidden value
The next method we'll look at is overflow: hidden. Go to your CSS and find the .secondary-section class. What we can do is add the overflow property with the value of hidden:
.secondary-section { margin-bottom: 50px; background-color: #7EEEAF; overflow: hidden; }
overflow: hidden is a true hack. It was never meant for remedying collapsed containers; it was meant for hiding any content image or text that overflowed its container. However, magically, overflow: hidden also clears the collapse. If we save our CSS and go to our site, we will see this is evident by the background, which is now green in color:

A small problem with overflow: hidden is that you may want the content to overflow the container, for instance, a drop-down menu or tooltip. The overflow: hidden hack will hide that overflow—no surprises there! It's a solution, but it may not always be ideal. For instance, in our exact scenario, we may want this octopus to kind of creep out of its container. Let's go into Chrome DevTools and give it margin-top: -50px. As you can see, now the top of the image is no longer showing and the overflow is hidden:

So that's not a good fix for us. Let's delete that overflow: hidden declaration from our CSS file and look at the next method: the float method.
- Instant Node Package Manager
- Learning Single:page Web Application Development
- Python自然語言處理實戰:核心技術與算法
- 軟件界面交互設計基礎
- Functional Programming in JavaScript
- PostgreSQL 11從入門到精通(視頻教學版)
- 小程序,巧運營:微信小程序運營招式大全
- 學Python也可以這么有趣
- Mathematica Data Analysis
- ANSYS Fluent 二次開發指南
- Node.js全程實例
- ASP.NET開發與應用教程
- 0 bug:C/C++商用工程之道
- Unity&VR游戲美術設計實戰
- Raspberry Pi Robotic Blueprints