skip to Main Content

I would like to move my button directly upward in a responsive way so that it’s inline with the iOS and Android buttons using Bootstrap.

My attempt in the code below gives me the output which’s the screenshot provided but isn’t what I want

I’ve tried a lot of things throughout SO and the web but nothing seems to be working. I would add some CSS from the outside but I feel like it wouldn’t be as responsive as it should. I must be overlooking something miniscule.

What am I doing wrong?

enter image description here

import React from 'react';

const footer = () => {
    return(
        <footer className="container">
            <div className="col-md-6 col-sm-12 center">
                <img className="iosBtn imgCenter img-responsive" src="https://website.com/images/website/Home/iphone.png?v=6.97"/>
                <img className="img-responsive" src="https://website.com/images/website/Home/google_play.png?v=6.97"/>
            </div>

            {/* I want to move this upward */}
            <form className="form-inline float-right">
                <div className="form-group mx-sm-3 mb-2">
                    <input className="form-control" placeholder="Enter Email"/>
                </div>
                <button type="submit" className="btn btn-primary mb-2">Submit</button>
            </form>

            <hr/>

            <div className="row text-center">
            <div className="col-sm">
            <a href="#">WINNERS</a>
            </div>
            <div className="col-sm">
            <a href="#">BLOG</a>
            </div>
            <div className="col-sm">
            <a href="#">FAQ</a>
            </div>
            <div className="col-sm">
            <a href="#">SWEEPSTAKES</a>
            </div>
            <div className="col-sm">
            <a href="#">CONTACT US</a>
            </div>
            <div className="col-sm">
            <a href="#">TERMS</a>
            </div>
            </div>

            <br/>

            <div className="text-center">
            <a href="#" className="btn btn-sm btn-link fa fa-facebook"></a>
            <a href="#" className="btn btn-sm btn-link fa fa-instagram"></a>
            <a href="#" className="btn btn-sm btn-link fa fa-youtube"></a>
            <a href="#" className="btn btn-sm btn-link fa fa-twitter"></a>
            <p className="text-center">website</p>
            </div>
        </footer>
    );
};

export default footer;

2

Answers


  1. Judging from your html, the form has the float: right; style applied which is causing the weird behavior.

    I’d recommend using flexbox instead:

    footer {
      display: flex;
      width: 100%;
    }
    
    form {
      display: flex;
      align-items: center;
      margin-left: auto;
    }
    <footer>
      <div>
        <img src="https://via.placeholder.com/140x100">
        <img src="https://via.placeholder.com/140x100">
      </div>
      <form>
        <input type="text">
        <input type="submit" value="submit">
      </form>
    </footer>
    Login or Signup to reply.
  2. Wrap your div with the images and your form in one div. And play with display: inline-block and float: left on the two. If nothing works, try to wrap the form also with another div and have the inline-block there.

    See sample code

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search