+ 2

How exactly do you use percentage height correctly?

When I asign width: 40%; to a div with a paragraph it works like intended, however, if I try to do it with height:50%; it just compresess to the paragraph. I Also tried with pixels and it does changes height, so I don't understand what's wrong.

5th Jun 2018, 7:11 PM
Peter Mx
Peter Mx - avatar
24 odpowiedzi
+ 4
Try adding the following to your '.box1'. At the moment you only have it in '.box1 p'. position:absolute;
5th Jun 2018, 8:07 PM
Duncan
Duncan - avatar
+ 3
Can you post your code for us? Many reasons for why that could be happening. The % is based upon the parent container, rather than the page itself, so that could potentially be your problem. Again, it's hard to say without reading your code.
5th Jun 2018, 7:29 PM
Fata1 Err0r
Fata1 Err0r - avatar
+ 3
Bebida Roja to mention another user, if you type the '@' symbol it should pop up a list of names of people active on the post. You can also just start typing the name after the '@' symbol to reduce the list or start searching for others.
5th Jun 2018, 8:00 PM
Duncan
Duncan - avatar
+ 2
Peter Mx position absolute means you are positioning absolutely. If left:0 then the element will be in the 0th pixel on the left. But if the parent element has position relative it will be positioned based on the parent element.
5th Jun 2018, 8:18 PM
Bebida Roja
Bebida Roja - avatar
+ 2
Good to hear. I'm still learning about css and don't know enough to explain sorry.
5th Jun 2018, 8:22 PM
Duncan
Duncan - avatar
+ 1
oops sorry, I was testing whit pixels and forgot to change it
5th Jun 2018, 7:36 PM
Peter Mx
Peter Mx - avatar
+ 1
It happens sometimes Peter Mx
5th Jun 2018, 7:37 PM
Bebida Roja
Bebida Roja - avatar
+ 1
positionn in the css is miswritten.
5th Jun 2018, 7:39 PM
Bebida Roja
Bebida Roja - avatar
5th Jun 2018, 7:56 PM
Peter Mx
Peter Mx - avatar
+ 1
I was trying to mention without the @. Now its all good. Thank you Sololearners ;)
5th Jun 2018, 8:02 PM
Bebida Roja
Bebida Roja - avatar
+ 1
Duncan it worked! thanks! But mind telling me what position absolute did? I really sant to know
5th Jun 2018, 8:12 PM
Peter Mx
Peter Mx - avatar
+ 1
Its all about the better of us (Y) Peter Mx
5th Jun 2018, 8:19 PM
Bebida Roja
Bebida Roja - avatar
0
A good check is to check if margin and padding are on 0.
5th Jun 2018, 7:32 PM
Bebida Roja
Bebida Roja - avatar
0
Did you found anything I missed?
5th Jun 2018, 7:38 PM
Peter Mx
Peter Mx - avatar
0
Fata1 Err0r 50% of the parent element.
5th Jun 2018, 7:41 PM
Bebida Roja
Bebida Roja - avatar
0
Off topic. How to cite some user? its not working for me and I have the last version.
5th Jun 2018, 7:42 PM
Bebida Roja
Bebida Roja - avatar
0
For me it doesnt change, maybe is a problem with my device?
5th Jun 2018, 7:45 PM
Peter Mx
Peter Mx - avatar
0
Sololearn compiler is the same for all of us.
5th Jun 2018, 7:46 PM
Bebida Roja
Bebida Roja - avatar
0
I tried with only one div and I deleted the paragraph bit it still compresess
5th Jun 2018, 7:51 PM
Peter Mx
Peter Mx - avatar