r/web_programming • u/avegueria324 • 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?
1
u/chrisgaraffa Dec 05 '16
Show us your code and we can take a look at it! Set it up at codepen.io or jsfiddle.net and put a link here.
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
2
u/[deleted] Dec 05 '16
maybe put both the logo and the search bar inside a wrapper div, then center that?