0

Hello, I am making a website and I can't center my div on a my main computer's screen without it messing up on my smaller laptop. I am using percentages but that doesn't seem to be helping I will attach 2 different pictures and my css. Thank you in advance.

Laptop

Pc

CSS

body {
  background-color: black;
}

.box {
  position: absolute;
  border-radius: 5%;
  width: 8%;
  height: 4%;
  margin: 5%;
  background-color: #888888;
  border-style: solid;
  border-width: medium;
  border-color: orange;
}

.Forum-Block {
  position: absolute;
  border-radius: 5%;
  left: 10%;
  top: 0%;
  width: 70%;
  height: 140%;
  margin: 5%;
  background-color: #888888;
  border-style: solid;
  border-width: medium;
  border-color: orange;
}

.Top-Bar {
  position: absolute;
  height: 30px;
  width: 60%;
  top: 8%;
  left: 10%;
}

.Back-Box {
  float: right;
  padding: 3%;
  color: white;
  background-color: black;
}

.FriendsB-Box {
  float: right;
  padding: 3%;
  color: white;
  background-color: black;
}

.RequestsB-Box {
  float: right;
  padding: 3%;
  color: white;
  background-color: black;
}

.SentRequestsB-Box {
  float: right;
  padding: 3%;
  color: white;
  background-color: black;
}

.SendRequestB-Box {
  float: right;
  padding: 3%;
  color: white;
  background-color: black;
}

.PendingRequestsB-Box {
  float: right;
  padding: 3%;
  color: white;
  background-color: black;
}

.Back-Box:hover {
  background-color: #262626;
}

.FriendsB-Box:hover {
  background-color: #262626;
}

.RequestsB-Box:hover {
  background-color: #262626;
}

.SentRequestsB-Box:hover {
  background-color: #262626;
}

.SendRequestB-Box:hover {
  background-color: #262626;
}

.PendingRequestsB-Box:hover {
  background-color: #262626;
}
Shikkediel
  • 5,195
  • 16
  • 45
  • 77
Marcus Mardis
  • 83
  • 1
  • 1
  • 8

2 Answers2

0

You need create one css this genre to achieve differentiate the 16 inches laptop for a 10 per example.

@media screen and (min-width: 900px) {
    body {
        background-color: lightgreen;
    }
}

@media screen and (max-width: 901px) {
    body {
        background-color: blue;
    }
}
Jose Cerejo
  • 231
  • 1
  • 5
  • 19
0

u cannot center the div if it's in position, because it change position of the div according to the screen size.

Add Html code with ur question is better to solve the problem.