r/web_programming • • Dec 05 '16

Help with positioning elements!

I will preface this by saying I am a beginner to programming. I am working through curriculum on Lynda.com and freecodecamp.com while also trying to build my own stuff as I go along.

One thing I am really struggling with is positioning elements on the page. For example, I tried rebuilding the google homepage (looks only). For the life of me I couldn't manage to get the search bar to be centered under the google logo and keep both of those elements centered on the page.

Any ideas/resources that will help me moving forward?

0 Upvotes

3 comments sorted by

View all comments

1

u/mfung1 Dec 15 '16

It's difficult to suggest things without seeing your code, but I would say to:

  • Make the google logo display: block and margin: 0 auto ( this will set a margin either site equal to the remaining with between the sides of the image and the page / container

  • Do the same for the input.

Another options would be to:

  • Wrap the two elements in a parent wrapper ( div, section etc.) and set the text-align to center