Jump to content

[HTML & CSS] move margin, keep text same place

WillLTT
Go to solution Solved by colonel_mortis,

Moved to programming.

 

From what you've shown, you can solve it by reducing the left value in css, and adding padding-left. For example,

#toptext {
  width: 1665px;
  position: absolute;
  top: -5px;
  font-size: 25px;
  background-color: #f1f1f1;
  left: 219px;
  padding-left: 15px;
}

(you will need to change the amount that they are changed by to suit your spacing). Padding is included in the background, and you can do padding-top, -bottom, -left and -right.

 

However, using position: absolute like that is not a good idea. I would strongly recommend that you use a layout approach that will put things next to each other by default. The most up-to-date way to do that would be to use flex boxes, although they are a relatively advanced CSS concept and it sounds like you are just starting out. For some reason I'm struggling to come up with a beginner-friendly way of doing sidebars in CSS off the top of my head, but if you search around there should be examples.

i want to keep the text the same place. and move the color all the way to the white isnt visible between the sidenav and the text

 

any help will be greatly apprichiated ? 

Capture.PNG

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, WillLTT said:

--snipp--

Heres my css:

#toptext
{
width: 1665px;
position: absolute;
top: -5px;
left: 234px;
font-size: 25px;
background-color: #f1f1f1;
}

 

Link to comment
Share on other sites

Link to post
Share on other sites

Moved to programming.

 

From what you've shown, you can solve it by reducing the left value in css, and adding padding-left. For example,

#toptext {
  width: 1665px;
  position: absolute;
  top: -5px;
  font-size: 25px;
  background-color: #f1f1f1;
  left: 219px;
  padding-left: 15px;
}

(you will need to change the amount that they are changed by to suit your spacing). Padding is included in the background, and you can do padding-top, -bottom, -left and -right.

 

However, using position: absolute like that is not a good idea. I would strongly recommend that you use a layout approach that will put things next to each other by default. The most up-to-date way to do that would be to use flex boxes, although they are a relatively advanced CSS concept and it sounds like you are just starting out. For some reason I'm struggling to come up with a beginner-friendly way of doing sidebars in CSS off the top of my head, but if you search around there should be examples.

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

13 minutes ago, colonel_mortis said:

Moved to programming.

oh so this isnt going under websites?

 

Thanks! ? 

Link to comment
Share on other sites

Link to post
Share on other sites

18 minutes ago, WillLTT said:

oh so this isnt going under websites?

Programs, Apps and Websites is intended for questions about using those things, such as questions about Google Docs. Programming is for questions about making those things (and related topics like Computer Science and Software Engineering).

HTTP/2 203

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×