Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS CSS Selectors Selectors - Beyond the Basics DRY CSS

How would I center the buttons with the class .inln after the browser meets the criteria for the media query?

https://w.trhou.se/z9kimsi8p4

Above is the code. I know this has been asked before, but I am wondering if there is a "cleaner" solution. I tried adding margins/padding, however there was no change to the positioning of the submit or reset buttons.

2 Answers

I'm not sure exactly where you would like the buttons to be placed or how much spacing you want between them but you could always try flexbox. It seems cleaner to me but it's newer so not so widely supported.

ā˜… Start by wrapping your buttons in a <span> and give it a class called flex.

<span class="flex">
    <input class="btn default inln" type="submit" value="Submit">
    <input class="btn error inln" type="reset" value="Reset">
</span>

ā˜… Go to you stylesheet and add the following code:

.flex {
    display: flex;
    justify-content: space-around;
}

If you would like to see some of the options available with flexbox visit https://css-tricks.com/snippets/css/a-guide-to-flexbox/

Thank You! I haven't used flex yet. Seems to work fine. I will definitely keep this in mind for future use.

If flexbox doesn't suit you try adding:

position: relative;
left: 30%;

to the .inln class