+ 3

Why my background is not covering all page and why my login box is not in the middle?

Position:absolute; Right:50%; Left:50%; Top 50%; And the box is not in middle And background also is position:covered https://code.sololearn.com/WXxDEAuV7joS/?ref=app

10th Apr 2020, 9:34 AM
kaspars kaspars
kaspars kaspars - avatar
41 Answers
+ 10
Add this #login-box { position:absolute; top:20%; left:30%; right:20%;
11th Apr 2020, 5:20 AM
Dipendra
Dipendra - avatar
+ 9
It works good šŸ‘
11th Apr 2020, 5:20 AM
Dipendra
Dipendra - avatar
+ 1
easier to just set html, body { hieght: 100%}
10th Apr 2020, 10:49 AM
David
+ 1
#login-box { position:absolute; top: 30%; left: 30%; } keep in mind i did it on my phone and you need to code for responsiveness for it ti work on diffeent devices
10th Apr 2020, 11:41 AM
David
+ 1
I went with this so it adds a legend to your login box. You just need to play around and center it. <fieldset id="login-box"> <legend><h3>Login</h3></legend> !<-- your html --> </fieldset>
10th Apr 2020, 6:17 PM
PjCode
PjCode - avatar
+ 1
automatic centering could be achieve thanks to combination of absolute positioning and translate transform: position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%);
10th Apr 2020, 7:29 PM
visph
visph - avatar
+ 1
Use transform: translate (-50%, -50%); Really works
10th Apr 2020, 10:35 PM
A-tech-coder
A-tech-coder - avatar
+ 1
#login-box { margin:auto; padding-top:50%; width:50%; }
11th Apr 2020, 3:46 PM
Mr. Mohsen Akbarzadeh
Mr. Mohsen Akbarzadeh - avatar
0
This don't help it become even smaller with ba kground size
10th Apr 2020, 9:48 AM
kaspars kaspars
kaspars kaspars - avatar
0
Thanx but the login box ain't in middle with position static the login box is in middle with some random 30 35% numbers not with 50 in exactly middle
10th Apr 2020, 10:19 AM
kaspars kaspars
kaspars kaspars - avatar
0
as well as background
10th Apr 2020, 10:49 AM
David
0
Doesn't work
10th Apr 2020, 10:56 AM
kaspars kaspars
kaspars kaspars - avatar
0
body, html { height:100%; width:100%; background-image:url("https://image.freepik.com/free-photo/great-view-park-with-city-background_1203-651.jpg"); background-repeat:no-repeat ; font-family:sans-serif; background-size: cover; }
10th Apr 2020, 11:03 AM
David
0
that works
10th Apr 2020, 11:04 AM
David
0
You just added , html to the body {} ?
10th Apr 2020, 11:20 AM
kaspars kaspars
kaspars kaspars - avatar
0
then rotate lol thats why there is a comma and plus the order doesnt matter
10th Apr 2020, 11:24 AM
David
0
the comma seperates them
10th Apr 2020, 11:24 AM
David
0
background-size cover; as well
10th Apr 2020, 11:26 AM
David
0
But why the login box is not in the midle? https://code.sololearn.com/WXxDEAuV7joS/?ref=app
10th Apr 2020, 11:32 AM
kaspars kaspars
kaspars kaspars - avatar
0
Ah well how can i make the picture look better on page?
10th Apr 2020, 11:41 AM
kaspars kaspars
kaspars kaspars - avatar