What are you looking? You don't know how to catch the birds? I am a kind and sharp Huang que. I dare not peat it alone. I would like to peat it with you. Of course, in order to avoid losing face of our Huang que family, we must peat the exit field to get a glimpse of the style.
When I was peeking at this beautygirl, I thought of a serious question: who is her parent?
Please turn your eyes on me. I am not going to see this beautygirl parent, and then ask for advice and cough... what I was thinking about is how her parents' height will directly affect my next plan. Why? Because their height will affect the future beautygirl height.
1. Influence of parent element on height
Height uses PX as the unit, which is not familiar to everyone. PX is basically a dingtalk to the element board. Then, let's explore the different performance of Height: auto and Height: 100% in different situations.
Let's look at a demo with a height: 100% failure:
<textarea id="d1" class="txtdemo" name="d1"><Style type = "text/CSS"> <br/>. parent {}< br/>. beautygirl {Height: 100%; Background: # fcf59b ;} <br/> </style> <br/> <Div class = "parent"> <br/> <Div class = "beautygirl"> <br/> <br/> </div> <br/></textarea> Run
Why is it ineffective if the height of beautygirl is set to 100% in the demo? After some logical reasoning and careful consideration, I realized that the height of the parent element was not set. So when we pile up pages, sometimes we encounter Height: 100%, which does not work, probably because of this reason. To fundamentally solve this problem. We add height: 100% to the ancestor element. The modified CSS is as follows:
<Style type = "text/CSS"> HTML, body {Height: 100%; margin: 0 ;}. parent {Height: 100% ;}. beautygirl {Height: 100%; Background: # fcf59b ;}</style>
Let's look at the demo:
Wow, beautygirl is tall and straight out... after this analysis, the shoes should understand why I want to know beatygirl's parents. The quality of genes can directly affect the growth of sister paper.
Next we will discuss the question of perspective, because the perspective of perspective has a direct impact on the quality of perspective. As the saying goes, people will be squashed in the door. This is a strange angle, what do you think? No, it's so evil. This is a literary perspective. Let's look at this beautygirl from the weird perspective of gravity, floating, beautygirl!
2. Influence of float and absolute position: absolute on parent element height
Modify the CSS as follows:
<Style type = "text/CSS"> HTML, body {Height: 100%; margin: 0 ;}. parent {Background: # fcf59b ;}. beautygirl {float: Left ;}</style>
Run Demo:
Sure enough, the yellow color of the. Parent element does not appear. Why?
When the element beautygirl floats or is absolutely positioned, the height of the parent element collapsed. Then, the height of the parent element is 0. For the reason why this happens, go to the back garden to view details. After moving to the back garden,You can press Ctrl + F to enter the height collapse to quickly locate the problem. If you have not read this article, we strongly recommend that you view it.
However, floating and absolute positioning have different effects on beautygirl. If float is a rebellion, it is absolutely difficult to find it. See Demo:
Float CSS:
< Style Type = "Text/CSS" > HTML, body { Height : 100% ; Margin : 0 ; } . Parent { Width : 400px ; Height : 300px ; Border : 1px solid # f00 ; } . Beautygirl { Float : Left ; Width : 100% ; Height : 100% ; Background : # Fcf59b ; } </ Style >
:
Absolute positioning of CSS:
< Style Type = "Text/CSS" > HTML, body { Height : 100% ; Margin : 0 ; } . Parent { Width : 400px ; Height : 300px ; Border : 1px solid # f00 ; } . Beautygirl { Position : Absolute ; Width : 100% ; Height : 100% ; Background : # Fcf59b ; } </ Style >
:
It can be seen that after the height and width of the floating element are set to 100%, the child element fills up the space of the parent element, while the absolute positioning element is completely not controlled by the parent element, the child element will calculate the height and width based on the window size. Of course, there is an exception, that is, when the "dry Dad" element exists. The child element is only controlled by the absolute or relative positioning "Cognac" element.
How many beautygirl and how many good young men are indirectly harmed by the hateful father? Let's take a look at a cup question. As for why is this name, please let the masses of young people think about it.
3. Influence of line-Height on height
This problem is relatively simple. In IE6, when line-height is greater than height, the actual height of the element is equal to line-height. In many cases, this factor is the reason why the border is not aligned because the height is exceeded. Overflow: hidden can help you sometimes. The height of the element is determined by the height of other browsers.
Since we decided to have some thoughts on this beautygirl, we also need to know the sisters of beautygirl. Hey, maybe my sister is more suitable.
Iv. Min-height and max-height
When talking about these two attributes, we will be confused with IE6 again. There is nothing to say in other browsers, but maybe it's not what you think. The following are some questions:
1. beautygirl {Min-Height: 30px; Height: 60px; max-Height: 90px ;}// Beautygirl1 60px; beautygirl2 60px;
2. beautygirl {Min-Height: 60px; Height: 30px; max-Height: 90px ;}// Beautygirl1 60px; beautygirl2 60px;
3. beautygirl {Min-Height: 60px; Height: 120px; max-Height: 90px ;}// Beautygirl1 90px; beautygirl2 90px;
4. beautygirl {Min-Height: 60px; max-Height: 90px ;}// Beautygirl1 60px; beautygirl2 <90px; achieves the max-Height Effect
What is the actual height of 1, 2, 3, and 4? You can test it.Lazy ASSISTANT: select the question part with the mouse, and the answer is at the end.
Finally, the simulation of Min-height and max-height in IE6 is presented.Code:
. Min-height {Min-Height: 60px; _ Height: 60px}. Max-height {max-Height: 90px; _ Height: expression (this. offsetheight> 90? 90: True); overflow: hidden ;}
Conclusion
It takes courage to get a peek, and it is not easy to get a code word. If you think it is okay, You Can [Recommend] or [Top] Anything else.